diff options
Diffstat (limited to '')
| -rw-r--r-- | src/regress/lib/libcrypto/bn/bn_mod_exp.c | 27 | ||||
| -rw-r--r-- | src/regress/lib/libcrypto/bn/bn_mod_exp2_mont.c | 23 |
2 files changed, 27 insertions, 23 deletions
diff --git a/src/regress/lib/libcrypto/bn/bn_mod_exp.c b/src/regress/lib/libcrypto/bn/bn_mod_exp.c index c16959c945..10647ad3dd 100644 --- a/src/regress/lib/libcrypto/bn/bn_mod_exp.c +++ b/src/regress/lib/libcrypto/bn/bn_mod_exp.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_mod_exp.c,v 1.24 2023/03/26 20:13:26 tb Exp $ */ | 1 | /* $OpenBSD: bn_mod_exp.c,v 1.25 2023/03/26 22:09:08 tb Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * Copyright (c) 2022,2023 Theo Buehler <tb@openbsd.org> | 4 | * Copyright (c) 2022,2023 Theo Buehler <tb@openbsd.org> |
| @@ -589,6 +589,30 @@ run_bn_mod_exp2_tests(void) | |||
| 589 | return failed; | 589 | return failed; |
| 590 | } | 590 | } |
| 591 | 591 | ||
| 592 | /* | ||
| 593 | * Small test for a crash reported by Guido Vranken, fixed in bn_exp2.c r1.13. | ||
| 594 | * https://github.com/openssl/openssl/issues/17648 | ||
| 595 | */ | ||
| 596 | |||
| 597 | static int | ||
| 598 | test_bn_mod_exp2_mont_crash(void) | ||
| 599 | { | ||
| 600 | BIGNUM *m; | ||
| 601 | int failed = 0; | ||
| 602 | |||
| 603 | if ((m = BN_new()) == NULL) | ||
| 604 | errx(1, "BN_new"); | ||
| 605 | |||
| 606 | if (BN_mod_exp2_mont(NULL, NULL, NULL, NULL, NULL, m, NULL, NULL)) { | ||
| 607 | fprintf(stderr, "BN_mod_exp2_mont succeeded\n"); | ||
| 608 | failed |= 1; | ||
| 609 | } | ||
| 610 | |||
| 611 | BN_free(m); | ||
| 612 | |||
| 613 | return failed; | ||
| 614 | } | ||
| 615 | |||
| 592 | int | 616 | int |
| 593 | main(void) | 617 | main(void) |
| 594 | { | 618 | { |
| @@ -597,6 +621,7 @@ main(void) | |||
| 597 | failed |= run_bn_mod_exp_zero_tests(); | 621 | failed |= run_bn_mod_exp_zero_tests(); |
| 598 | failed |= run_bn_mod_exp_tests(); | 622 | failed |= run_bn_mod_exp_tests(); |
| 599 | failed |= run_bn_mod_exp2_tests(); | 623 | failed |= run_bn_mod_exp2_tests(); |
| 624 | failed |= test_bn_mod_exp2_mont_crash(); | ||
| 600 | 625 | ||
| 601 | return failed; | 626 | return failed; |
| 602 | } | 627 | } |
diff --git a/src/regress/lib/libcrypto/bn/bn_mod_exp2_mont.c b/src/regress/lib/libcrypto/bn/bn_mod_exp2_mont.c index aa1cd0e0cc..e529d3d4fa 100644 --- a/src/regress/lib/libcrypto/bn/bn_mod_exp2_mont.c +++ b/src/regress/lib/libcrypto/bn/bn_mod_exp2_mont.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_mod_exp2_mont.c,v 1.2 2022/12/17 23:41:29 tb Exp $ */ | 1 | /* $OpenBSD: bn_mod_exp2_mont.c,v 1.3 2023/03/26 22:09:08 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> | 3 | * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> |
| 4 | * | 4 | * |
| @@ -15,29 +15,8 @@ | |||
| 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 | 17 | ||
| 18 | #include <err.h> | ||
| 19 | |||
| 20 | #include <openssl/bn.h> | ||
| 21 | |||
| 22 | /* | ||
| 23 | * Small test for a crash reported by Guido Vranken, fixed in bn_exp2.c r1.13. | ||
| 24 | * https://github.com/openssl/openssl/issues/17648 | ||
| 25 | */ | ||
| 26 | |||
| 27 | int | 18 | int |
| 28 | main(void) | 19 | main(void) |
| 29 | { | 20 | { |
| 30 | BIGNUM *m; | ||
| 31 | |||
| 32 | if ((m = BN_new()) == NULL) | ||
| 33 | errx(1, "BN_new"); | ||
| 34 | |||
| 35 | BN_zero(m); | ||
| 36 | |||
| 37 | if (BN_mod_exp2_mont(NULL, NULL, NULL, NULL, NULL, m, NULL, NULL)) | ||
| 38 | errx(1, "BN_mod_exp2_mont succeeded"); | ||
| 39 | |||
| 40 | BN_free(m); | ||
| 41 | |||
| 42 | return 0; | 21 | return 0; |
| 43 | } | 22 | } |
