mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
handling edge cases with ecc import and decrypt functions
This commit is contained in:
@ -8799,11 +8799,12 @@ int wc_ecc_import_x963_ex(const byte* in, word32 inLen, ecc_key* key,
|
|||||||
DECLARE_CURVE_SPECS(curve, 3);
|
DECLARE_CURVE_SPECS(curve, 3);
|
||||||
ALLOC_CURVE_SPECS(3, err);
|
ALLOC_CURVE_SPECS(3, err);
|
||||||
|
|
||||||
if (err == MP_OKAY &&
|
if (err == MP_OKAY) {
|
||||||
mp_init_multi(&t1, &t2, NULL, NULL, NULL, NULL) != MP_OKAY)
|
if (mp_init_multi(&t1, &t2, NULL, NULL, NULL, NULL) != MP_OKAY)
|
||||||
err = MEMORY_E;
|
err = MEMORY_E;
|
||||||
else
|
else
|
||||||
did_init = 1;
|
did_init = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* load curve info */
|
/* load curve info */
|
||||||
if (err == MP_OKAY)
|
if (err == MP_OKAY)
|
||||||
@ -12117,6 +12118,11 @@ int wc_ecc_decrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
|
|||||||
#endif
|
#endif
|
||||||
pubKey = peerKey;
|
pubKey = peerKey;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
/* if a public key was passed in we should free it here before init
|
||||||
|
* and import */
|
||||||
|
wc_ecc_free(pubKey);
|
||||||
|
}
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = wc_ecc_init_ex(pubKey, privKey->heap, INVALID_DEVID);
|
ret = wc_ecc_init_ex(pubKey, privKey->heap, INVALID_DEVID);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user