@@ -7446,9 +7446,11 @@ int wc_CreatePKCS8Key(byte* out, word32* outSz, byte* key, word32 keySz,
74467446 * privKeySz : size of private key buffer
74477447 * pubKey : buffer holding DER format public key
74487448 * pubKeySz : size of public key buffer
7449- * ks : type of key */
7449+ * ks : type of key
7450+ * heap : heap hint to use */
74507451int wc_CheckPrivateKey(const byte* privKey, word32 privKeySz,
7451- const byte* pubKey, word32 pubKeySz, enum Key_Sum ks)
7452+ const byte* pubKey, word32 pubKeySz, enum Key_Sum ks,
7453+ void* heap)
74527454{
74537455 int ret;
74547456 (void)privKeySz;
@@ -7485,14 +7487,14 @@ int wc_CheckPrivateKey(const byte* privKey, word32 privKeySz,
74857487 }
74867488 #endif
74877489
7488- if ((ret = wc_InitRsaKey(a, NULL )) < 0) {
7490+ if ((ret = wc_InitRsaKey(a, heap )) < 0) {
74897491 #ifdef WOLFSSL_SMALL_STACK
74907492 XFREE(b, NULL, DYNAMIC_TYPE_RSA);
74917493 XFREE(a, NULL, DYNAMIC_TYPE_RSA);
74927494 #endif
74937495 return ret;
74947496 }
7495- if ((ret = wc_InitRsaKey(b, NULL )) < 0) {
7497+ if ((ret = wc_InitRsaKey(b, heap )) < 0) {
74967498 wc_FreeRsaKey(a);
74977499 #ifdef WOLFSSL_SMALL_STACK
74987500 XFREE(b, NULL, DYNAMIC_TYPE_RSA);
@@ -7553,7 +7555,7 @@ int wc_CheckPrivateKey(const byte* privKey, word32 privKeySz,
75537555 }
75547556 #endif
75557557
7556- if ((ret = wc_ecc_init (key_pair)) < 0) {
7558+ if ((ret = wc_ecc_init_ex (key_pair, heap, INVALID_DEVID )) < 0) {
75577559 #ifdef WOLFSSL_SMALL_STACK
75587560 XFREE(privDer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
75597561 XFREE(key_pair, NULL, DYNAMIC_TYPE_ECC);
@@ -7571,7 +7573,7 @@ int wc_CheckPrivateKey(const byte* privKey, word32 privKeySz,
75717573 wc_MemZero_Add("wc_CheckPrivateKey privDer", privDer, privSz);
75727574 #endif
75737575 wc_ecc_free(key_pair);
7574- ret = wc_ecc_init (key_pair);
7576+ ret = wc_ecc_init_ex (key_pair, heap, INVALID_DEVID );
75757577 if (ret == 0) {
75767578 ret = wc_ecc_import_private_key(privDer,
75777579 privSz, pubKey,
@@ -7622,7 +7624,7 @@ int wc_CheckPrivateKey(const byte* privKey, word32 privKeySz,
76227624 return MEMORY_E;
76237625 #endif
76247626
7625- if ((ret = wc_ed25519_init (key_pair)) < 0) {
7627+ if ((ret = wc_ed25519_init_ex (key_pair, heap, INVALID_DEVID )) < 0) {
76267628 #ifdef WOLFSSL_SMALL_STACK
76277629 XFREE(key_pair, NULL, DYNAMIC_TYPE_ED25519);
76287630 #endif
@@ -7672,7 +7674,7 @@ int wc_CheckPrivateKey(const byte* privKey, word32 privKeySz,
76727674 return MEMORY_E;
76737675 #endif
76747676
7675- if ((ret = wc_ed448_init (key_pair)) < 0) {
7677+ if ((ret = wc_ed448_init_ex (key_pair, heap, INVALID_DEVID )) < 0) {
76767678 #ifdef WOLFSSL_SMALL_STACK
76777679 XFREE(key_pair, NULL, DYNAMIC_TYPE_ED448);
76787680 #endif
@@ -7919,6 +7921,7 @@ int wc_CheckPrivateKey(const byte* privKey, word32 privKeySz,
79197921 ret = 0;
79207922 }
79217923 (void)ks;
7924+ (void)heap;
79227925
79237926 return ret;
79247927}
@@ -7933,7 +7936,7 @@ int wc_CheckPrivateKey(const byte* privKey, word32 privKeySz,
79337936 * checkAlt : indicate if we check primary or alternative key
79347937 */
79357938int wc_CheckPrivateKeyCert(const byte* key, word32 keySz, DecodedCert* der,
7936- int checkAlt)
7939+ int checkAlt, void* heap )
79377940{
79387941 int ret = 0;
79397942
@@ -7947,7 +7950,7 @@ int wc_CheckPrivateKeyCert(const byte* key, word32 keySz, DecodedCert* der,
79477950 word32 idx = 0;
79487951 /* Dilithium has the largest public key at the moment */
79497952 word32 pubKeyLen = DILITHIUM_MAX_PUB_KEY_SIZE;
7950- byte* decodedPubKey = (byte*)XMALLOC(pubKeyLen, NULL ,
7953+ byte* decodedPubKey = (byte*)XMALLOC(pubKeyLen, heap ,
79517954 DYNAMIC_TYPE_PUBLIC_KEY);
79527955 if (decodedPubKey == NULL) {
79537956 ret = MEMORY_E;
@@ -7966,15 +7969,15 @@ int wc_CheckPrivateKeyCert(const byte* key, word32 keySz, DecodedCert* der,
79667969 }
79677970 if (ret == 0) {
79687971 ret = wc_CheckPrivateKey(key, keySz, decodedPubKey, pubKeyLen,
7969- (enum Key_Sum) der->sapkiOID);
7972+ (enum Key_Sum) der->sapkiOID, heap );
79707973 }
7971- XFREE(decodedPubKey, NULL , DYNAMIC_TYPE_PUBLIC_KEY);
7974+ XFREE(decodedPubKey, heap , DYNAMIC_TYPE_PUBLIC_KEY);
79727975 }
79737976 else
79747977#endif
79757978 {
79767979 ret = wc_CheckPrivateKey(key, keySz, der->publicKey,
7977- der->pubKeySize, (enum Key_Sum) der->keyOID);
7980+ der->pubKeySize, (enum Key_Sum) der->keyOID, heap );
79787981 }
79797982
79807983 (void)checkAlt;
0 commit comments