diff options
-rw-r--r-- | src/lib/libcrypto/ec/ecp_oct.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/lib/libcrypto/ec/ecp_oct.c b/src/lib/libcrypto/ec/ecp_oct.c index 0d9a73c5b8..ce63bfadc4 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.28 2024/10/24 05:57:25 tb Exp $ */ | 1 | /* $OpenBSD: ecp_oct.c,v 1.29 2024/10/25 18:06:42 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. |
@@ -434,18 +434,22 @@ ec_GFp_simple_oct2point(const EC_GROUP *group, EC_POINT *point, | |||
434 | BN_CTX_start(ctx); | 434 | BN_CTX_start(ctx); |
435 | CBS_init(&cbs, buf, len); | 435 | CBS_init(&cbs, buf, len); |
436 | 436 | ||
437 | if ((x = BN_CTX_get(ctx)) == NULL) | ||
438 | goto err; | ||
439 | if ((y = BN_CTX_get(ctx)) == NULL) | ||
440 | goto err; | ||
441 | |||
442 | if (!ec_oct_get_leading_octet_cbs(&cbs, &form, &ybit)) | 437 | if (!ec_oct_get_leading_octet_cbs(&cbs, &form, &ybit)) |
443 | goto err; | 438 | goto err; |
444 | 439 | ||
445 | if (form == EC_OCT_POINT_AT_INFINITY) { | 440 | if (form == EC_OCT_POINT_AT_INFINITY) { |
446 | if (!EC_POINT_set_to_infinity(group, point)) | 441 | if (!EC_POINT_set_to_infinity(group, point)) |
447 | goto err; | 442 | goto err; |
448 | } else if (form == EC_OCT_POINT_COMPRESSED) { | 443 | |
444 | goto done; | ||
445 | } | ||
446 | |||
447 | if ((x = BN_CTX_get(ctx)) == NULL) | ||
448 | goto err; | ||
449 | if ((y = BN_CTX_get(ctx)) == NULL) | ||
450 | goto err; | ||
451 | |||
452 | if (form == EC_OCT_POINT_COMPRESSED) { | ||
449 | if (!ec_oct_get_field_element_cbs(&cbs, group, x)) | 453 | if (!ec_oct_get_field_element_cbs(&cbs, group, x)) |
450 | goto err; | 454 | goto err; |
451 | if (!EC_POINT_set_compressed_coordinates(group, point, x, ybit, ctx)) | 455 | if (!EC_POINT_set_compressed_coordinates(group, point, x, ybit, ctx)) |
@@ -461,6 +465,7 @@ ec_GFp_simple_oct2point(const EC_GROUP *group, EC_POINT *point, | |||
461 | goto err; | 465 | goto err; |
462 | } | 466 | } |
463 | 467 | ||
468 | done: | ||
464 | if (CBS_len(&cbs) > 0) { | 469 | if (CBS_len(&cbs) > 0) { |
465 | ECerror(EC_R_INVALID_ENCODING); | 470 | ECerror(EC_R_INVALID_ENCODING); |
466 | goto err; | 471 | goto err; |