mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
scd: New function for iso7816 PSO_CSV.
* scd/iso7816.c (iso7816_pso_csv): New.
This commit is contained in:
parent
855d14d390
commit
91dd74f3d7
@ -628,6 +628,67 @@ iso7816_decipher (int slot, int extended_mode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Perform the security operation COMPUTE SHARED SECRET. On success 0
|
||||||
|
is returned and the shared secret is available in a newly allocated
|
||||||
|
buffer stored at RESULT with its length stored at RESULTLEN. For
|
||||||
|
LE see do_generate_keypair. */
|
||||||
|
gpg_error_t
|
||||||
|
iso7816_pso_csv (int slot, int extended_mode,
|
||||||
|
const unsigned char *data, size_t datalen, int le,
|
||||||
|
unsigned char **result, size_t *resultlen)
|
||||||
|
{
|
||||||
|
int sw;
|
||||||
|
unsigned char *buf;
|
||||||
|
unsigned int nbuf;
|
||||||
|
|
||||||
|
if (!data || !datalen || !result || !resultlen)
|
||||||
|
return gpg_error (GPG_ERR_INV_VALUE);
|
||||||
|
*result = NULL;
|
||||||
|
*resultlen = 0;
|
||||||
|
|
||||||
|
if (!extended_mode)
|
||||||
|
le = 256; /* Ignore provided Le and use what apdu_send uses. */
|
||||||
|
else if (le >= 0 && le < 256)
|
||||||
|
le = 256;
|
||||||
|
|
||||||
|
/* Data needs to be in BER-TLV format. */
|
||||||
|
buf = xtrymalloc (datalen + 4);
|
||||||
|
if (!buf)
|
||||||
|
return gpg_error_from_syserror ();
|
||||||
|
nbuf = 0;
|
||||||
|
buf[nbuf++] = 0x9c;
|
||||||
|
if (datalen < 128)
|
||||||
|
buf[nbuf++] = datalen;
|
||||||
|
else if (datalen < 256)
|
||||||
|
{
|
||||||
|
buf[nbuf++] = 0x81;
|
||||||
|
buf[nbuf++] = datalen;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buf[nbuf++] = 0x82;
|
||||||
|
buf[nbuf++] = datalen << 8;
|
||||||
|
buf[nbuf++] = datalen;
|
||||||
|
}
|
||||||
|
memcpy (buf+nbuf, data, datalen);
|
||||||
|
sw = apdu_send_le (slot, extended_mode,
|
||||||
|
0x00, CMD_PSO, 0x80, 0xa6,
|
||||||
|
datalen+nbuf, (const char *)buf, le,
|
||||||
|
result, resultlen);
|
||||||
|
xfree (buf);
|
||||||
|
if (sw != SW_SUCCESS)
|
||||||
|
{
|
||||||
|
/* Make sure that pending buffers are released. */
|
||||||
|
xfree (*result);
|
||||||
|
*result = NULL;
|
||||||
|
*resultlen = 0;
|
||||||
|
return map_sw (sw);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* For LE see do_generate_keypair. */
|
/* For LE see do_generate_keypair. */
|
||||||
gpg_error_t
|
gpg_error_t
|
||||||
iso7816_internal_authenticate (int slot, int extended_mode,
|
iso7816_internal_authenticate (int slot, int extended_mode,
|
||||||
|
@ -110,6 +110,9 @@ gpg_error_t iso7816_decipher (int slot, int extended_mode,
|
|||||||
const unsigned char *data, size_t datalen,
|
const unsigned char *data, size_t datalen,
|
||||||
int le, int padind,
|
int le, int padind,
|
||||||
unsigned char **result, size_t *resultlen);
|
unsigned char **result, size_t *resultlen);
|
||||||
|
gpg_error_t iso7816_pso_csv (int slot, int extended_mode,
|
||||||
|
const unsigned char *data, size_t datalen, int le,
|
||||||
|
unsigned char **result, size_t *resultlen);
|
||||||
gpg_error_t iso7816_internal_authenticate (int slot, int extended_mode,
|
gpg_error_t iso7816_internal_authenticate (int slot, int extended_mode,
|
||||||
const unsigned char *data, size_t datalen,
|
const unsigned char *data, size_t datalen,
|
||||||
int le,
|
int le,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user