Skip to content

Commit c984b8c

Browse files
committed
Fix WP11_Rsa_Verify_Recover
No longer returns the length but for now NSS doesn't use it to check length
1 parent 7779ed1 commit c984b8c

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

src/internal.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9300,34 +9300,25 @@ int WP11_Rsa_Verify_Recover(CK_MECHANISM_TYPE mechanism, unsigned char* sig,
93009300
CK_ULONG_PTR outLen, WP11_Object* pub)
93019301
{
93029302
int ret;
9303-
byte* data_out = NULL;
93049303

93059304
switch (mechanism) {
93069305
case CKM_RSA_PKCS:
9307-
ret = wc_RsaSSL_VerifyInline(sig, sigLen, &data_out,
9306+
ret = wc_RsaSSL_Verify(sig, sigLen, out, (word32)*outLen,
93089307
&pub->data.rsaKey);
9308+
if (ret == RSA_BUFFER_E)
9309+
return CKR_BUFFER_TOO_SMALL;
93099310
if (ret < 0)
9310-
return ret;
9311+
return CKR_FUNCTION_FAILED;
93119312

93129313
*outLen = ret;
9313-
if (out == NULL) {
9314-
return CKR_OK;
9315-
}
9316-
else {
9317-
if (*outLen < (CK_ULONG)ret) {
9318-
return CKR_BUFFER_TOO_SMALL;
9319-
}
9320-
else {
9321-
XMEMCPY(out, data_out, ret);
9322-
}
9323-
}
93249314
break;
93259315

9326-
case CKM_RSA_X_509:
9316+
case CKM_RSA_X_509: {
9317+
byte* data_out = NULL;
93279318
ret = wc_RsaDirect(sig, sigLen, out, (word32*)outLen,
93289319
&pub->data.rsaKey, RSA_PUBLIC_DECRYPT, NULL);
93299320
if (ret < 0)
9330-
return ret;
9321+
return CKR_FUNCTION_FAILED;
93319322
/* Result is front padded with 0x00 */
93329323
for (byte* pos = out; pos < out + *outLen; pos++) {
93339324
if (*pos != 0x00) {
@@ -9340,7 +9331,7 @@ int WP11_Rsa_Verify_Recover(CK_MECHANISM_TYPE mechanism, unsigned char* sig,
93409331
XMEMMOVE(out, data_out, *outLen);
93419332
}
93429333
break;
9343-
9334+
}
93449335
default:
93459336
/* Should never happen */
93469337
return CKR_FUNCTION_FAILED;

0 commit comments

Comments
 (0)