@@ -46997,7 +46997,7 @@ static wc_test_ret_t dilithium_param_vfy_test(int param, const byte* pubKey,
4699746997 msg[i] = (byte)i;
4699846998 }
4699946999
47000- ret = wc_dilithium_init (key);
47000+ ret = wc_dilithium_init_ex (key, NULL, devId );
4700147001 if (ret != 0) {
4700247002 ret = WC_TEST_RET_ENC_EC(ret);
4700347003 return ret;
@@ -50158,7 +50158,7 @@ static wc_test_ret_t dilithium_param_test(int param, WC_RNG* rng)
5015850158 }
5015950159#endif
5016050160
50161- ret = wc_dilithium_init (key);
50161+ ret = wc_dilithium_init_ex (key, NULL, devId );
5016250162 if (ret != 0) {
5016350163 ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
5016450164 }
@@ -50250,7 +50250,7 @@ static wc_test_ret_t test_dilithium_decode_level(const byte* rawKey,
5025050250
5025150251 /* Initialize key */
5025250252 if (ret == 0) {
50253- ret = wc_dilithium_init (key);
50253+ ret = wc_dilithium_init_ex (key, NULL, devId );
5025450254 }
5025550255
5025650256 /* Import raw key, setting the security level */
@@ -50293,7 +50293,7 @@ static wc_test_ret_t test_dilithium_decode_level(const byte* rawKey,
5029350293 /* Free and reinit key to test fresh decode */
5029450294 if (ret == 0) {
5029550295 wc_dilithium_free(key);
50296- ret = wc_dilithium_init (key);
50296+ ret = wc_dilithium_init_ex (key, NULL, devId );
5029750297 }
5029850298
5029950299 /* First test decoding when security level is set externally */
@@ -50318,7 +50318,7 @@ static wc_test_ret_t test_dilithium_decode_level(const byte* rawKey,
5031850318 /* Free and reinit key to test fresh decode */
5031950319 if (ret == 0) {
5032050320 wc_dilithium_free(key);
50321- ret = wc_dilithium_init (key);
50321+ ret = wc_dilithium_init_ex (key, NULL, devId );
5032250322 }
5032350323
5032450324#ifndef WOLFSSL_DILITHIUM_FIPS204_DRAFT
@@ -65407,6 +65407,37 @@ static int myCryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
6540765407 ret = 0;
6540865408 break;
6540965409 }
65410+ #endif
65411+ default:
65412+ ret = WC_NO_ERR_TRACE(NOT_COMPILED_IN);
65413+ break;
65414+ }
65415+ }
65416+ else if (info->free.algo == WC_ALGO_TYPE_PK) {
65417+ switch (info->free.type) {
65418+ #ifdef HAVE_ECC
65419+ case WC_PK_TYPE_EC_KEYGEN:
65420+ {
65421+ ecc_key* ecc = (ecc_key*)info->free.obj;
65422+ ecc->devId = INVALID_DEVID;
65423+ wc_ecc_free(ecc);
65424+ ret = 0;
65425+ break;
65426+ }
65427+ #endif
65428+ #ifdef HAVE_DILITHIUM
65429+ case WC_PK_TYPE_PQC_SIG_KEYGEN:
65430+ {
65431+ if (info->free.subType ==
65432+ WC_PQC_SIG_TYPE_DILITHIUM) {
65433+ dilithium_key* dil =
65434+ (dilithium_key*)info->free.obj;
65435+ dil->devId = INVALID_DEVID;
65436+ wc_dilithium_free(dil);
65437+ ret = 0;
65438+ }
65439+ break;
65440+ }
6541065441#endif
6541165442 default:
6541265443 ret = WC_NO_ERR_TRACE(NOT_COMPILED_IN);
@@ -65600,6 +65631,10 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t cryptocb_test(void)
6560065631 ret = ecc_onlycb_test(&myCtx);
6560165632 PRIVATE_KEY_LOCK();
6560265633#endif
65634+ #ifdef HAVE_DILITHIUM
65635+ if (ret == 0)
65636+ ret = dilithium_test();
65637+ #endif
6560365638#ifdef HAVE_ED25519
6560465639 PRIVATE_KEY_UNLOCK();
6560565640 if (ret == 0)
0 commit comments