forked from wolfSSL/wolfssl
ECC: validate ordinate length before export
This commit is contained in:
@ -7605,6 +7605,12 @@ int wc_ecc_export_point_der(const int curve_idx, ecc_point* point, byte* out,
|
||||
return BUFFER_E;
|
||||
}
|
||||
|
||||
/* Sanity check the ordinates' sizes. */
|
||||
if (((word32)mp_unsigned_bin_size(point->x) > numlen) ||
|
||||
((word32)mp_unsigned_bin_size(point->y) > numlen)) {
|
||||
return ECC_BAD_ARG_E;
|
||||
}
|
||||
|
||||
/* store byte point type */
|
||||
out[0] = ECC_POINT_UNCOMP;
|
||||
|
||||
@ -7676,6 +7682,11 @@ int wc_ecc_export_point_der_compressed(const int curve_idx, ecc_point* point,
|
||||
return BUFFER_E;
|
||||
}
|
||||
|
||||
/* Sanity check the ordinate's size. */
|
||||
if ((word32)mp_unsigned_bin_size(point->x) > numlen) {
|
||||
return ECC_BAD_ARG_E;
|
||||
}
|
||||
|
||||
/* store byte point type */
|
||||
out[0] = mp_isodd(point->y) == MP_YES ? ECC_POINT_COMP_ODD :
|
||||
ECC_POINT_COMP_EVEN;
|
||||
|
Reference in New Issue
Block a user