From 246228e410268470010dd02b842040f95bed2f16 Mon Sep 17 00:00:00 2001 From: Anthony Hu Date: Wed, 11 Sep 2024 14:39:03 -0400 Subject: [PATCH] Check for PIN before saving it. --- wolfcrypt/src/wc_pkcs11.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wolfcrypt/src/wc_pkcs11.c b/wolfcrypt/src/wc_pkcs11.c index 8ccb47187..4a3b28adb 100644 --- a/wolfcrypt/src/wc_pkcs11.c +++ b/wolfcrypt/src/wc_pkcs11.c @@ -657,7 +657,7 @@ int wc_Pkcs11Token_Init(Pkcs11Token* token, Pkcs11Dev* dev, int slotId, tokenNameSz = XSTRLEN(tokenName); } ret = Pkcs11Token_Init(token, dev, slotId, tokenName, tokenNameSz); - if (ret == 0) { + if (ret == 0 && userPin != NULL) { token->userPin = (CK_UTF8CHAR_PTR)userPin; token->userPinSz = (CK_ULONG)userPinSz; token->userPinLogin = 1; @@ -708,7 +708,7 @@ int wc_Pkcs11Token_InitName(Pkcs11Token* token, Pkcs11Dev* dev, const unsigned char* userPin, int userPinSz) { int ret = Pkcs11Token_Init(token, dev, -1, tokenName, (size_t)tokenNameSz); - if (ret == 0) { + if (ret == 0 && userPin != NULL) { token->userPin = (CK_UTF8CHAR_PTR)userPin; token->userPinSz = (CK_ULONG)userPinSz; token->userPinLogin = 1;