Merge pull request #3687 from guidovranken/x963-export-reject-invalid-keys

Reject undefined keys (eg. state is ECC_STATE_NONE) from X963 export …
This commit is contained in:
toddouska
2021-01-25 14:46:59 -08:00
committed by GitHub

View File

@ -7178,9 +7178,12 @@ int wc_ecc_export_x963(ecc_key* key, byte* out, word32* outLen)
if (key->type == ECC_PRIVATEKEY_ONLY)
return ECC_PRIVATEONLY_E;
if (wc_ecc_is_valid_idx(key->idx) == 0 || key->dp == NULL) {
return ECC_BAD_ARG_E;
if (key->type == ECC_STATE_NONE ||
wc_ecc_is_valid_idx(key->idx) == 0 ||
key->dp == NULL) {
return ECC_BAD_ARG_E;
}
numlen = key->dp->size;
/* verify room in out buffer */
@ -11245,9 +11248,15 @@ static int wc_ecc_export_x963_compressed(ecc_key* key, byte* out, word32* outLen
if (key == NULL || out == NULL || outLen == NULL)
return BAD_FUNC_ARG;
if (wc_ecc_is_valid_idx(key->idx) == 0) {
return ECC_BAD_ARG_E;
if (key->type == ECC_PRIVATEKEY_ONLY)
return ECC_PRIVATEONLY_E;
if (key->type == ECC_STATE_NONE ||
wc_ecc_is_valid_idx(key->idx) == 0 ||
key->dp == NULL) {
return ECC_BAD_ARG_E;
}
numlen = key->dp->size;
if (*outLen < (1 + numlen)) {