Skip to content

Commit ed3e533

Browse files
committed
Fix CI for mldsa, firefox and nss tests
1 parent 25f9b2c commit ed3e533

3 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/crypto.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,11 @@ static CK_RV SetAttributeDefaults(WP11_Object* obj, CK_OBJECT_CLASS keyType,
514514
ulCount);
515515
break;
516516
case CKO_SECRET_KEY:
517+
#ifndef WOLFPKCS11_NSS
517518
if (ret == CKR_OK)
518519
ret = SetIfNotFound(obj, CKA_SENSITIVE, trueVal, pTemplate,
519520
ulCount);
521+
#endif
520522
if (ret == CKR_OK)
521523
ret = SetIfNotFound(obj, CKA_EXTRACTABLE, trueVal, pTemplate,
522524
ulCount);
@@ -534,12 +536,19 @@ static CK_RV SetAttributeDefaults(WP11_Object* obj, CK_OBJECT_CLASS keyType,
534536
ulCount);
535537
break;
536538
case CKO_PRIVATE_KEY:
539+
#ifndef WOLFPKCS11_NSS
537540
if (ret == CKR_OK)
538541
ret = SetIfNotFound(obj, CKA_SENSITIVE, trueVal, pTemplate,
539542
ulCount);
540543
if (ret == CKR_OK)
541544
ret = SetIfNotFound(obj, CKA_EXTRACTABLE, falseVal, pTemplate,
542545
ulCount);
546+
#else
547+
/* NSS needs extractable private keys as internal crypto module */
548+
if (ret == CKR_OK)
549+
ret = SetIfNotFound(obj, CKA_EXTRACTABLE, trueVal, pTemplate,
550+
ulCount);
551+
#endif
543552
if (ret == CKR_OK)
544553
ret = SetIfNotFound(obj, CKA_DECRYPT, encrypt, pTemplate,
545554
ulCount);

src/internal.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,9 @@ static void wp11_Session_Final(WP11_Session* session)
966966
(session->init & ~WP11_INIT_DIGEST_MASK) == WP11_INIT_AES_CMAC_VERIFY) {
967967
#if (!defined(HAVE_FIPS) || FIPS_VERSION_GE(5, 3))
968968
(void)wc_CmacFree(&session->params.cmac.cmac);
969+
#else
970+
wc_ForceZero(&session->params.cmac.cmac,
971+
sizeof(session->params.cmac.cmac));
969972
#endif
970973
session->init = 0;
971974
}
@@ -12366,6 +12369,12 @@ int WP11_Mldsa_Verify(unsigned char* sig, word32 sigLen, unsigned char* data,
1236612369
params->ctxSz, params->preHashType, data, dataLen, stat,
1236712370
pub->data.mldsaKey);
1236812371
}
12372+
/* wolfCrypt may return SIG_VERIFY_E instead of stat=0 for invalid
12373+
* signatures. Map to stat=0 so caller returns CKR_SIGNATURE_INVALID. */
12374+
if (ret == SIG_VERIFY_E) {
12375+
*stat = 0;
12376+
ret = 0;
12377+
}
1236912378
}
1237012379

1237112380
XFREE(params->ctx, NULL, DYNAMIC_TYPE_TMP_BUFFER);
@@ -14258,6 +14267,8 @@ int WP11_Digest_Single(unsigned char* data, word32 dataLen,
1425814267
WP11_Digest* digest = &session->params.digest;
1425914268

1426014269
blockLen = wc_HashGetDigestSize(digest->hashType);
14270+
if (blockLen < 0)
14271+
return CKR_FUNCTION_FAILED;
1426114272

1426214273
if (dataOut == NULL) {
1426314274
*dataOutLen = (word32)blockLen;
@@ -14267,6 +14278,7 @@ int WP11_Digest_Single(unsigned char* data, word32 dataLen,
1426714278
return BUFFER_E;
1426814279
}
1426914280
ret = wc_Hash(digest->hashType, data, dataLen, dataOut, *dataOutLen);
14281+
*dataOutLen = (word32)blockLen;
1427014282

1427114283
wc_HashFree(&digest->hash, digest->hashType);
1427214284

tests/pkcs11test.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6051,6 +6051,7 @@ static CK_RV test_generate_key_pair(void* args)
60516051
return ret;
60526052
}
60536053

6054+
#ifndef WOLFPKCS11_NSS
60546055
static CK_RV test_private_key_secure_defaults(void* args)
60556056
{
60566057
CK_SESSION_HANDLE session = *(CK_SESSION_HANDLE*)args;
@@ -6104,6 +6105,7 @@ static CK_RV test_private_key_secure_defaults(void* args)
61046105

61056106
return ret;
61066107
}
6108+
#endif /* !WOLFPKCS11_NSS */
61076109
#endif
61086110

61096111
#if defined(HAVE_AES_KEYWRAP) && !defined(WOLFPKCS11_NO_STORE)
@@ -17298,8 +17300,10 @@ static TEST_FUNC testFunc[] = {
1729817300
PKCS11TEST_FUNC_SESS_DECL(test_generate_key),
1729917301
#if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN)
1730017302
PKCS11TEST_FUNC_SESS_DECL(test_generate_key_pair),
17303+
#ifndef WOLFPKCS11_NSS
1730117304
PKCS11TEST_FUNC_SESS_DECL(test_private_key_secure_defaults),
1730217305
#endif
17306+
#endif
1730317307
#if defined(HAVE_AES_KEYWRAP) && !defined(WOLFPKCS11_NO_STORE)
1730417308
PKCS11TEST_FUNC_SESS_DECL(test_aes_wrap_unwrap_key),
1730517309
PKCS11TEST_FUNC_SESS_DECL(test_aes_wrap_unwrap_pad_key),

0 commit comments

Comments
 (0)