diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/ec/ecp_oct.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/lib/libcrypto/ec/ecp_oct.c b/src/lib/libcrypto/ec/ecp_oct.c index 0a66a5cd48..d4ef0406f5 100644 --- a/src/lib/libcrypto/ec/ecp_oct.c +++ b/src/lib/libcrypto/ec/ecp_oct.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ecp_oct.c,v 1.25 2024/10/22 21:10:45 tb Exp $ */ | 1 | /* $OpenBSD: ecp_oct.c,v 1.26 2024/10/22 21:28:53 tb Exp $ */ |
2 | /* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> | 2 | /* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> |
3 | * for the OpenSSL project. | 3 | * for the OpenSSL project. |
4 | * Includes code written by Bodo Moeller for the OpenSSL project. | 4 | * Includes code written by Bodo Moeller for the OpenSSL project. |
@@ -209,6 +209,17 @@ ec_oct_conversion_form_is_valid(uint8_t form) | |||
209 | return (form & EC_OCT_POINT_CONVERSION_MASK) == form; | 209 | return (form & EC_OCT_POINT_CONVERSION_MASK) == form; |
210 | } | 210 | } |
211 | 211 | ||
212 | static int | ||
213 | ec_oct_check_hybrid_ybit_is_consistent(uint8_t form, int ybit, const BIGNUM *y) | ||
214 | { | ||
215 | if (form == EC_OCT_POINT_HYBRID && ybit != BN_is_odd(y)) { | ||
216 | ECerror(EC_R_INVALID_ENCODING); | ||
217 | return 0; | ||
218 | } | ||
219 | |||
220 | return 1; | ||
221 | } | ||
222 | |||
212 | /* Nonzero y-bit only makes sense with compressed or hybrid encoding. */ | 223 | /* Nonzero y-bit only makes sense with compressed or hybrid encoding. */ |
213 | static int | 224 | static int |
214 | ec_oct_nonzero_ybit_allowed(uint8_t form) | 225 | ec_oct_nonzero_ybit_allowed(uint8_t form) |
@@ -437,12 +448,8 @@ ec_GFp_simple_oct2point(const EC_GROUP *group, EC_POINT *point, | |||
437 | goto err; | 448 | goto err; |
438 | if (!ec_oct_get_field_element_cbs(&cbs, group, y)) | 449 | if (!ec_oct_get_field_element_cbs(&cbs, group, y)) |
439 | goto err; | 450 | goto err; |
440 | if (form == EC_OCT_POINT_HYBRID) { | 451 | if (!ec_oct_check_hybrid_ybit_is_consistent(form, ybit, y)) |
441 | if (ybit != BN_is_odd(y)) { | 452 | goto err; |
442 | ECerror(EC_R_INVALID_ENCODING); | ||
443 | goto err; | ||
444 | } | ||
445 | } | ||
446 | if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx)) | 453 | if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx)) |
447 | goto err; | 454 | goto err; |
448 | } | 455 | } |