Merge pull request #5335 from SparkiDev/ecc_imp_exp_fix

ECC import and export fixes
This commit is contained in:
David Garske 2022-07-07 17:52:20 -07:00 committed by GitHub
commit 49d292ec4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10125,6 +10125,9 @@ static int wc_ecc_import_raw_private(ecc_key* key, const char* qx,
WOLFSSL_MSG("Invalid Qx");
err = BAD_FUNC_ARG;
}
if (mp_unsigned_bin_size(key->pubkey.y) > key->dp->size) {
err = BAD_FUNC_ARG;
}
}
/* read Qy */
@ -10139,6 +10142,9 @@ static int wc_ecc_import_raw_private(ecc_key* key, const char* qx,
WOLFSSL_MSG("Invalid Qy");
err = BAD_FUNC_ARG;
}
if (mp_unsigned_bin_size(key->pubkey.y) > key->dp->size) {
err = BAD_FUNC_ARG;
}
}
if (err == MP_OKAY) {
@ -13735,6 +13741,9 @@ static int wc_ecc_export_x963_compressed(ecc_key* key, byte* out, word32* outLen
if (out == NULL)
return BAD_FUNC_ARG;
if (mp_unsigned_bin_size(key->pubkey.x) > (int)numlen)
return ECC_BAD_ARG_E;
/* store first byte */
out[0] = mp_isodd(key->pubkey.y) == MP_YES ? ECC_POINT_COMP_ODD : ECC_POINT_COMP_EVEN;