Skip to content

Commit a7cbf7d

Browse files
committed
fix: When PKCS11 C_Sign is passed null pSignature, it is expected to fill pulSignatureLen with required buffer length.
1 parent 50a11b1 commit a7cbf7d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/pkcs11/pkcs11_signature.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,21 @@ CK_RV pkcs11_signature_sign(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_UL
148148
return pkcs11_util_convert_rv(status);
149149
}
150150
}
151+
else
152+
{
153+
switch (pSession->active_mech)
154+
{
155+
case CKM_SHA256_HMAC:
156+
*pulSignatureLen = ATCA_SHA256_DIGEST_SIZE;
157+
break;
158+
case CKM_ECDSA:
159+
*pulSignatureLen = ATCA_SIG_SIZE;
160+
break;
161+
default:
162+
status = ATCA_GEN_FAIL;
163+
break;
164+
}
165+
}
151166
}
152167
else
153168
{

0 commit comments

Comments
 (0)