OLD | NEW |
(Empty) | |
| 1 diff -ru opencryptoki-2.2.8.ORG/work/opencryptoki-2.2.8/usr/lib/pkcs11/tpm_stdll
/new_host.c opencryptoki-2.2.8/work/opencryptoki-2.2.8/usr/lib/pkcs11/tpm_stdll/
new_host.c |
| 2 --- opencryptoki-2.2.8.ORG/work/opencryptoki-2.2.8/usr/lib/pkcs11/tpm_stdll/new_
host.c 2010-12-07 16:38:55.000000000 -0800 |
| 3 +++ opencryptoki-2.2.8/work/opencryptoki-2.2.8/usr/lib/pkcs11/tpm_stdll/new_host
.c 2010-12-07 17:05:17.000000000 -0800 |
| 4 @@ -28,6 +28,9 @@ |
| 5 4/25/03 Kapil Sood (kapil@corrent.com) |
| 6 Added DH key pair generation and DH shared key derivation |
| 7 functions. |
| 8 + 11/16/10 Nelson Araujo (nelsona@chromium.org) |
| 9 + Return default public exponent if not stored and/or returned |
| 10 + by the TPM token device |
| 11 ****************************************************************************/ |
| 12 |
| 13 |
| 14 @@ -120,6 +123,7 @@ |
| 15 |
| 16 CK_C_INITIALIZE_ARGS cinit_args = { NULL, NULL, NULL, NULL, 0, NULL }; |
| 17 |
| 18 +CK_BYTE pub_exp[] = { 0x1, 0x0, 0x1 }; // 65537 |
| 19 |
| 20 extern void stlogterm(); |
| 21 extern void stloginit(); |
| 22 @@ -1926,11 +1930,34 @@ |
| 23 goto done; |
| 24 } |
| 25 |
| 26 + for (i=0; i<ulCount; i++) { |
| 27 + if (pTemplate[i].type == CKA_PUBLIC_EXPONENT) { |
| 28 + // 'object_mgr_get_attribute_values' requires the buffer to be |
| 29 + // of the right size, otherwise it will fail with a too generic |
| 30 + // error code. if buffer is too small, return to the caller |
| 31 + // failure with more appropriate (specific) error code. |
| 32 + if (pTemplate[i].ulValueLen < sizeof(pub_exp)) { |
| 33 + rc = CKR_BUFFER_TOO_SMALL; |
| 34 + goto done; |
| 35 + } |
| 36 + } |
| 37 + } |
| 38 + |
| 39 rc = object_mgr_get_attribute_values( sess, hObject, pTemplate, ulCount ); |
| 40 if (rc != CKR_OK){ |
| 41 st_err_log(159, __FILE__, __LINE__); |
| 42 } |
| 43 |
| 44 + for (i=0; i<ulCount; i++) { |
| 45 + if (pTemplate[i].type == CKA_PUBLIC_EXPONENT) { |
| 46 + if (rc || pTemplate[i].ulValueLen == 0) { |
| 47 + // Use well-known exponent if value not stored by the device. |
| 48 + memcpy( pTemplate[i].pValue, pub_exp, sizeof(pub_exp) ); |
| 49 + pTemplate[i].ulValueLen = sizeof(pub_exp); |
| 50 + rc = 0; |
| 51 + } |
| 52 + } |
| 53 + } |
| 54 |
| 55 done: |
| 56 LLOCK; |
OLD | NEW |