diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/bn/bn_gf2m.c | 16 | ||||
| -rw-r--r-- | src/lib/libcrypto/man/BN_GF2m_add.3 | 14 |
2 files changed, 14 insertions, 16 deletions
diff --git a/src/lib/libcrypto/bn/bn_gf2m.c b/src/lib/libcrypto/bn/bn_gf2m.c index 1fd7105a31..b9e3ba8566 100644 --- a/src/lib/libcrypto/bn/bn_gf2m.c +++ b/src/lib/libcrypto/bn/bn_gf2m.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_gf2m.c,v 1.24 2022/11/20 22:23:43 schwarze Exp $ */ | 1 | /* $OpenBSD: bn_gf2m.c,v 1.25 2022/11/20 23:35:00 schwarze Exp $ */ |
| 2 | /* ==================================================================== | 2 | /* ==================================================================== |
| 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
| 4 | * | 4 | * |
| @@ -464,17 +464,23 @@ int | |||
| 464 | BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p) | 464 | BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p) |
| 465 | { | 465 | { |
| 466 | int ret = 0; | 466 | int ret = 0; |
| 467 | int arr[6]; | 467 | const int max = BN_num_bits(p) + 1; |
| 468 | int *arr = NULL; | ||
| 468 | 469 | ||
| 469 | bn_check_top(a); | 470 | bn_check_top(a); |
| 470 | bn_check_top(p); | 471 | bn_check_top(p); |
| 471 | ret = BN_GF2m_poly2arr(p, arr, sizeof(arr) / sizeof(arr[0])); | 472 | if ((arr = reallocarray(NULL, max, sizeof(int))) == NULL) |
| 472 | if (!ret || ret > (int)(sizeof(arr) / sizeof(arr[0]))) { | 473 | goto err; |
| 474 | ret = BN_GF2m_poly2arr(p, arr, max); | ||
| 475 | if (!ret || ret > max) { | ||
| 473 | BNerror(BN_R_INVALID_LENGTH); | 476 | BNerror(BN_R_INVALID_LENGTH); |
| 474 | return 0; | 477 | goto err; |
| 475 | } | 478 | } |
| 476 | ret = BN_GF2m_mod_arr(r, a, arr); | 479 | ret = BN_GF2m_mod_arr(r, a, arr); |
| 477 | bn_check_top(r); | 480 | bn_check_top(r); |
| 481 | |||
| 482 | err: | ||
| 483 | free(arr); | ||
| 478 | return ret; | 484 | return ret; |
| 479 | } | 485 | } |
| 480 | 486 | ||
diff --git a/src/lib/libcrypto/man/BN_GF2m_add.3 b/src/lib/libcrypto/man/BN_GF2m_add.3 index 170a7df18a..60a2a5eed4 100644 --- a/src/lib/libcrypto/man/BN_GF2m_add.3 +++ b/src/lib/libcrypto/man/BN_GF2m_add.3 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | .\" $OpenBSD: BN_GF2m_add.3,v 1.3 2022/11/18 07:28:34 tb Exp $ | 1 | .\" $OpenBSD: BN_GF2m_add.3,v 1.4 2022/11/20 23:35:00 schwarze Exp $ |
| 2 | .\" | 2 | .\" |
| 3 | .\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org> | 3 | .\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org> |
| 4 | .\" | 4 | .\" |
| @@ -14,7 +14,7 @@ | |||
| 14 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 14 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 15 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 15 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 16 | .\" | 16 | .\" |
| 17 | .Dd $Mdocdate: November 18 2022 $ | 17 | .Dd $Mdocdate: November 20 2022 $ |
| 18 | .Dt BN_GF2M_ADD 3 | 18 | .Dt BN_GF2M_ADD 3 |
| 19 | .Os | 19 | .Os |
| 20 | .Sh NAME | 20 | .Sh NAME |
| @@ -480,9 +480,7 @@ In one of the functions wrapping an | |||
| 480 | .Fn *_arr | 480 | .Fn *_arr |
| 481 | variant, the | 481 | variant, the |
| 482 | .Fa "BIGNUM *p" | 482 | .Fa "BIGNUM *p" |
| 483 | argument had a value of zero, or in | 483 | argument had a value of zero. |
| 484 | .Fn BN_GF2m_mod , | ||
| 485 | it contained more than five non-zero coefficients. | ||
| 486 | .El | 484 | .El |
| 487 | .Sh SEE ALSO | 485 | .Sh SEE ALSO |
| 488 | .Xr BN_add 3 , | 486 | .Xr BN_add 3 , |
| @@ -514,9 +512,3 @@ it contained more than five non-zero coefficients. | |||
| 514 | exponentiation algorithm A.4.1 for square roots, and\ | 512 | exponentiation algorithm A.4.1 for square roots, and\ |
| 515 | algorithms A.4.7 and A.4.6 for the quadratic equation | 513 | algorithms A.4.7 and A.4.6 for the quadratic equation |
| 516 | .Re | 514 | .Re |
| 517 | .Sh BUGS | ||
| 518 | .Fn BN_GF2m_mod | ||
| 519 | is arbitrarily limited to reducing polynomials containing at most five | ||
| 520 | non-zero coefficients and returns failure if | ||
| 521 | .Fa p | ||
| 522 | contains six or more non-zero coefficients. | ||
