diff options
author | Werner Koch <[email protected]> | 2009-07-10 10:15:33 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2009-07-10 10:15:33 +0000 |
commit | 96abdb1386284da07a7fe129b79d08890949d2ed (patch) | |
tree | cd4b233459c2fc39cafcee035161a6e7fc6bf7d7 /scd/iso7816.c | |
parent | Support writing of existing keys with non-matching key sizes. (diff) | |
download | gnupg-96abdb1386284da07a7fe129b79d08890949d2ed.tar.gz gnupg-96abdb1386284da07a7fe129b79d08890949d2ed.zip |
Fix for card keys > 2048 bit.
Diffstat (limited to 'scd/iso7816.c')
-rw-r--r-- | scd/iso7816.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/scd/iso7816.c b/scd/iso7816.c index 3fea6c79e..f1ee0daef 100644 --- a/scd/iso7816.c +++ b/scd/iso7816.c @@ -505,9 +505,10 @@ iso7816_manage_security_env (int slot, int p1, int p2, /* Perform the security operation COMPUTE DIGITAL SIGANTURE. On success 0 is returned and the data is availavle in a newly allocated buffer stored at RESULT with its length stored at - RESULTLEN. */ + RESULTLEN. For LE see do_generate_keypair. */ gpg_error_t -iso7816_compute_ds (int slot, const unsigned char *data, size_t datalen, +iso7816_compute_ds (int slot, int extended_mode, + const unsigned char *data, size_t datalen, int le, unsigned char **result, size_t *resultlen) { int sw; @@ -517,9 +518,16 @@ iso7816_compute_ds (int slot, const unsigned char *data, size_t datalen, *result = NULL; *resultlen = 0; - sw = apdu_send (slot, 0, - 0x00, CMD_PSO, 0x9E, 0x9A, datalen, (const char*)data, - result, resultlen); + if (!extended_mode) + le = 256; /* Ignore provided Le and use what apdu_send uses. */ + else if (le >= 0 && le < 256) + le = 256; + + sw = apdu_send_le (slot, extended_mode, + 0x00, CMD_PSO, 0x9E, 0x9A, + datalen, (const char*)data, + le, + result, resultlen); if (sw != SW_SUCCESS) { /* Make sure that pending buffers are released. */ @@ -586,9 +594,11 @@ iso7816_decipher (int slot, int extended_mode, } +/* For LE see do_generate_keypair. */ gpg_error_t -iso7816_internal_authenticate (int slot, +iso7816_internal_authenticate (int slot, int extended_mode, const unsigned char *data, size_t datalen, + int le, unsigned char **result, size_t *resultlen) { int sw; @@ -598,8 +608,16 @@ iso7816_internal_authenticate (int slot, *result = NULL; *resultlen = 0; - sw = apdu_send (slot, 0, 0x00, CMD_INTERNAL_AUTHENTICATE, 0, 0, - datalen, (const char*)data, result, resultlen); + if (!extended_mode) + le = 256; /* Ignore provided Le and use what apdu_send uses. */ + else if (le >= 0 && le < 256) + le = 256; + + sw = apdu_send_le (slot, extended_mode, + 0x00, CMD_INTERNAL_AUTHENTICATE, 0, 0, + datalen, (const char*)data, + le, + result, resultlen); if (sw != SW_SUCCESS) { /* Make sure that pending buffers are released. */ |