Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions wolfcrypt/src/ecc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9439,6 +9439,14 @@ int wc_ecc_import_point_der_ex(const byte* in, word32 inLen,
return ECC_BAD_ARG_E;
}

/* validate point format byte before any memory operations */
pointType = in[0];
if (pointType != ECC_POINT_UNCOMP &&
pointType != ECC_POINT_COMP_EVEN &&
pointType != ECC_POINT_COMP_ODD) {
return ASN_PARSE_E;
}
Comment on lines +9442 to +9448

/* clear if previously allocated */
mp_clear(point->x);
mp_clear(point->y);
Expand All @@ -9460,16 +9468,14 @@ int wc_ecc_import_point_der_ex(const byte* in, word32 inLen,

SAVE_VECTOR_REGISTERS(return _svr_ret;);

/* check for point type (4, 2, or 3) */
pointType = in[0];
if (pointType != ECC_POINT_UNCOMP && pointType != ECC_POINT_COMP_EVEN &&
pointType != ECC_POINT_COMP_ODD) {
err = ASN_PARSE_E;
}

/* pointType already validated above; check for compressed format */
if (pointType == ECC_POINT_COMP_EVEN || pointType == ECC_POINT_COMP_ODD) {
#ifdef HAVE_COMP_KEY
compressed = 1;
/* compressed points must be exactly 1 + field_element_size bytes */
if (inLen != 1 + (word32)ecc_sets[curve_idx].size) {
err = ECC_BAD_ARG_E;
}
Comment on lines 9474 to +9478
#else
err = NOT_COMPILED_IN;
#endif
Expand Down
Loading