Overview
Comment: | Fixed issue with C_Sign updating buffer twice when buffer is too small. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: | 56e8c0ae091f8ca54383d26d618297a441cfc7ca |
User & Date: | rkeene on 2010-05-21 17:25:48 |
Other Links: | manifest | tags |
Context
2010-05-21
| ||
21:09 | Added support for more PC/SC errors check-in: a5be7fbdf0 user: rkeene tags: trunk | |
17:25 | Fixed issue with C_Sign updating buffer twice when buffer is too small. check-in: 56e8c0ae09 user: rkeene tags: trunk | |
15:44 | CACKey 0.5.5 check-in: c97d596fa2 user: rkeene tags: trunk, 0.5.5 | |
Changes
Modified cackey.c from [a529afaf0b] to [2531c8311d].
4985 4985 4986 4986 CACKEY_DEBUG_PRINTF("Returning CKR_OK (%i)", CKR_OK); 4987 4987 4988 4988 return(CKR_OK); 4989 4989 } 4990 4990 4991 4991 CK_DEFINE_FUNCTION(CK_RV, C_Sign)(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG ulDataLen, CK_BYTE_PTR pSignature, CK_ULONG_PTR pulSignatureLen) { 4992 + unsigned long start_sign_bufused; 4992 4993 CK_RV sign_ret; 4993 4994 4994 4995 CACKEY_DEBUG_PRINTF("Called."); 4995 4996 4996 4997 if (!cackey_initialized) { 4997 4998 CACKEY_DEBUG_PRINTF("Error. Not initialized."); 4998 4999 4999 5000 return(CKR_CRYPTOKI_NOT_INITIALIZED); 5000 5001 } 5001 5002 5003 + if (hSession == 0 || hSession >= (sizeof(cackey_sessions) / sizeof(cackey_sessions[0]))) { 5004 + CACKEY_DEBUG_PRINTF("Error. Session out of range."); 5005 + 5006 + return(CKR_SESSION_HANDLE_INVALID); 5007 + } 5008 + 5009 + start_sign_bufused = cackey_sessions[hSession].sign_bufused; 5010 + 5002 5011 sign_ret = C_SignUpdate(hSession, pData, ulDataLen); 5003 5012 if (sign_ret != CKR_OK) { 5004 5013 CACKEY_DEBUG_PRINTF("Error. SignUpdate() returned failure (rv = %lu).", (unsigned long) sign_ret); 5005 5014 5006 5015 return(sign_ret); 5007 5016 } 5008 5017 5009 5018 sign_ret = C_SignFinal(hSession, pSignature, pulSignatureLen); 5010 5019 if (sign_ret != CKR_OK) { 5020 + if (sign_ret == CKR_BUFFER_TOO_SMALL) { 5021 + CACKEY_DEBUG_PRINTF("SignFinal() returned CKR_BUFFER_TOO_SMALL (rv = %lu), undoing C_SignUpdate()", (unsigned long) sign_ret); 5022 + 5023 + cackey_sessions[hSession].sign_bufused = start_sign_bufused; 5024 + 5025 + return(sign_ret); 5026 + } 5027 + 5011 5028 CACKEY_DEBUG_PRINTF("Error. SignFinal() returned failure (rv = %lu).", (unsigned long) sign_ret); 5012 5029 5013 5030 return(sign_ret); 5014 5031 } 5015 5032 5016 5033 CACKEY_DEBUG_PRINTF("Returning CKR_OK (%i)", CKR_OK); 5017 5034