Skip to content

Commit 1935260

Browse files
committed
Fix get size and get sig test allocation
1 parent 8352818 commit 1935260

1 file changed

Lines changed: 27 additions & 12 deletions

File tree

wolfcrypt/test/test.c

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64666,20 +64666,35 @@ static int myCryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
6466664666
#endif
6466764667
}
6466864668
else if (info->pk.type == WC_PK_TYPE_EC_GET_SIZE) {
64669-
/* Copy key to avoid const and recursive callback */
64670-
ecc_key tmpEcc;
64671-
XMEMCPY(&tmpEcc, info->pk.ecc_get_size.key, sizeof(ecc_key));
64672-
tmpEcc.devId = INVALID_DEVID;
64673-
*info->pk.ecc_get_size.keySize = wc_ecc_size(&tmpEcc);
64674-
ret = 0;
64669+
WC_DECLARE_VAR(tmpEcc, ecc_key, 1, NULL);
64670+
WC_ALLOC_VAR(tmpEcc, ecc_key, 1, NULL);
64671+
if (!WC_VAR_OK(tmpEcc)) {
64672+
ret = MEMORY_E;
64673+
}
64674+
else {
64675+
/* Copy key to avoid const and recursive callback */
64676+
XMEMCPY(tmpEcc, info->pk.ecc_get_size.key, sizeof(ecc_key));
64677+
tmpEcc->devId = INVALID_DEVID;
64678+
*info->pk.ecc_get_size.keySize = wc_ecc_size(tmpEcc);
64679+
WC_FREE_VAR(tmpEcc, NULL);
64680+
ret = 0;
64681+
}
6467564682
}
6467664683
else if (info->pk.type == WC_PK_TYPE_EC_GET_SIG_SIZE) {
64677-
/* Copy key to avoid const and recursive callback */
64678-
ecc_key tmpEcc;
64679-
XMEMCPY(&tmpEcc, info->pk.ecc_get_sig_size.key, sizeof(ecc_key));
64680-
tmpEcc.devId = INVALID_DEVID;
64681-
*info->pk.ecc_get_sig_size.sigSize = wc_ecc_sig_size(&tmpEcc);
64682-
ret = 0;
64684+
WC_DECLARE_VAR(tmpEcc, ecc_key, 1, NULL);
64685+
WC_ALLOC_VAR(tmpEcc, ecc_key, 1, NULL);
64686+
if (!WC_VAR_OK(tmpEcc)) {
64687+
ret = MEMORY_E;
64688+
}
64689+
else {
64690+
/* Copy key to avoid const and recursive callback */
64691+
XMEMCPY(tmpEcc, info->pk.ecc_get_sig_size.key,
64692+
sizeof(ecc_key));
64693+
tmpEcc->devId = INVALID_DEVID;
64694+
*info->pk.ecc_get_sig_size.sigSize = wc_ecc_sig_size(tmpEcc);
64695+
WC_FREE_VAR(tmpEcc, NULL);
64696+
ret = 0;
64697+
}
6468364698
}
6468464699
#endif /* HAVE_ECC */
6468564700
#ifdef HAVE_CURVE25519

0 commit comments

Comments
 (0)