@@ -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