summaryrefslogtreecommitdiff
path: root/src/regress/lib/libcrypto/bn/bn_mod_exp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/regress/lib/libcrypto/bn/bn_mod_exp.c')
-rw-r--r--src/regress/lib/libcrypto/bn/bn_mod_exp.c27
1 files changed, 26 insertions, 1 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
597static int
598test_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
592int 616int
593main(void) 617main(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}