|
| 1 | +From 8dc0004e154753913f7c7fceb034db4c0e2a7784 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Tudor Ambarus < [email protected]> |
| 3 | +Date: Thu, 21 Jan 2021 15:09:44 +0200 |
| 4 | +Subject: [PATCH 2/2] pkcs11: Fix user's PIN usage |
| 5 | + |
| 6 | +1/ The PIN size is 32 bytes, update buffer length accordingly |
| 7 | +2/ Add condition to check so_pin_handle is not pointing to |
| 8 | +default value |
| 9 | +3/ Update KeyLen condition in pkcs11_token_convert_pin_to_key. |
| 10 | + |
| 11 | +Signed-off-by: Tudor Ambarus < [email protected]> |
| 12 | +--- |
| 13 | + lib/pkcs11/pkcs11_token.c | 6 +++--- |
| 14 | + 1 file changed, 3 insertions(+), 3 deletions(-) |
| 15 | + |
| 16 | +diff --git a/lib/pkcs11/pkcs11_token.c b/lib/pkcs11/pkcs11_token.c |
| 17 | +index a40f822c93ec..92b633220513 100644 |
| 18 | +--- a/lib/pkcs11/pkcs11_token.c |
| 19 | ++++ b/lib/pkcs11/pkcs11_token.c |
| 20 | +@@ -125,7 +125,7 @@ CK_RV pkcs11_token_init(CK_SLOT_ID slotID, CK_UTF8CHAR_PTR pPin, CK_ULONG ulPinL |
| 21 | + { |
| 22 | + #if PKCS11_TOKEN_INIT_SUPPORT |
| 23 | + CK_RV rv; |
| 24 | +- uint8_t buf[34]; |
| 25 | ++ uint8_t buf[32]; |
| 26 | + uint8_t * pConfig = NULL; |
| 27 | + bool lock = false; |
| 28 | + pkcs11_lib_ctx_ptr pLibCtx; |
| 29 | +@@ -255,7 +255,7 @@ CK_RV pkcs11_token_init(CK_SLOT_ID slotID, CK_UTF8CHAR_PTR pPin, CK_ULONG ulPinL |
| 30 | + rv = pkcs11_token_convert_pin_to_key(pPin, ulPinLen, NULL, 0, buf, buflen); |
| 31 | + } |
| 32 | + |
| 33 | +- if (CKR_OK == rv) |
| 34 | ++ if ((CKR_OK == rv) && (pSlotCtx->so_pin_handle != 0xFFFF)) |
| 35 | + { |
| 36 | + if (atcab_is_ca_device(pSlotCtx->interface_config.devtype)) |
| 37 | + { |
| 38 | +@@ -577,7 +577,7 @@ CK_RV pkcs11_token_convert_pin_to_key( |
| 39 | + { |
| 40 | + ATCA_STATUS status = ATCA_SUCCESS; |
| 41 | + |
| 42 | +- if (!pPin || !ulPinLen || !pKey || 32 != ulKeyLen) |
| 43 | ++ if (!pPin || !ulPinLen || !pKey || 32 > ulKeyLen) |
| 44 | + { |
| 45 | + return CKR_ARGUMENTS_BAD; |
| 46 | + } |
| 47 | +-- |
| 48 | +2.17.1 |
| 49 | + |
0 commit comments