diff options
author | tb <> | 2022-03-10 04:39:49 +0000 |
---|---|---|
committer | tb <> | 2022-03-10 04:39:49 +0000 |
commit | 745a0da49b7b262611e528bfb7f6803314c4650f (patch) | |
tree | 351fe08463ad3b52c3fc2d496ac3739a55f1e5b7 /src/regress/lib | |
parent | 982436f27471bfc068a7d9adeb753ef13a93d82d (diff) | |
download | openbsd-745a0da49b7b262611e528bfb7f6803314c4650f.tar.gz openbsd-745a0da49b7b262611e528bfb7f6803314c4650f.tar.bz2 openbsd-745a0da49b7b262611e528bfb7f6803314c4650f.zip |
Simple regress for NULL deref reported by Guido Vranken and fixed in
bn_exp2.c r1.13.
Diffstat (limited to 'src/regress/lib')
-rw-r--r-- | src/regress/lib/libcrypto/bn/general/Makefile | 7 | ||||
-rw-r--r-- | src/regress/lib/libcrypto/bn/general/bn_mod_exp2_mont.c | 45 |
2 files changed, 51 insertions, 1 deletions
diff --git a/src/regress/lib/libcrypto/bn/general/Makefile b/src/regress/lib/libcrypto/bn/general/Makefile index 6b7919eb53..fec9575d0e 100644 --- a/src/regress/lib/libcrypto/bn/general/Makefile +++ b/src/regress/lib/libcrypto/bn/general/Makefile | |||
@@ -1,8 +1,9 @@ | |||
1 | # $OpenBSD: Makefile,v 1.7 2020/12/17 00:51:11 bluhm Exp $ | 1 | # $OpenBSD: Makefile,v 1.8 2022/03/10 04:39:49 tb Exp $ |
2 | 2 | ||
3 | .include "../../Makefile.inc" | 3 | .include "../../Makefile.inc" |
4 | 4 | ||
5 | PROGS += bntest | 5 | PROGS += bntest |
6 | PROGS += bn_mod_exp2_mont | ||
6 | PROGS += bn_to_string | 7 | PROGS += bn_to_string |
7 | 8 | ||
8 | LDADD = ${CRYPTO_INT} | 9 | LDADD = ${CRYPTO_INT} |
@@ -20,6 +21,10 @@ run-bc: bntest.out | |||
20 | bc < bntest.out | tee bc.out | grep -v '^0$$' | 21 | bc < bntest.out | tee bc.out | grep -v '^0$$' |
21 | ! grep -v '^test ' <bc.out | grep -v '^0$$' | 22 | ! grep -v '^test ' <bc.out | grep -v '^0$$' |
22 | 23 | ||
24 | REGRESS_TARGETS += run-bn_mod_exp2_mont | ||
25 | run-bn_mod_exp2_mont: bn_mod_exp2_mont | ||
26 | ./bn_mod_exp2_mont | ||
27 | |||
23 | REGRESS_TARGETS += run-bn_to_string | 28 | REGRESS_TARGETS += run-bn_to_string |
24 | run-bn_to_string: bn_to_string | 29 | run-bn_to_string: bn_to_string |
25 | ./bn_to_string | 30 | ./bn_to_string |
diff --git a/src/regress/lib/libcrypto/bn/general/bn_mod_exp2_mont.c b/src/regress/lib/libcrypto/bn/general/bn_mod_exp2_mont.c new file mode 100644 index 0000000000..60bb010b62 --- /dev/null +++ b/src/regress/lib/libcrypto/bn/general/bn_mod_exp2_mont.c | |||
@@ -0,0 +1,45 @@ | |||
1 | /* $OpenBSD: bn_mod_exp2_mont.c,v 1.1 2022/03/10 04:39:49 tb Exp $ */ | ||
2 | /* | ||
3 | * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> | ||
4 | * | ||
5 | * Permission to use, copy, modify, and distribute this software for any | ||
6 | * purpose with or without fee is hereby granted, provided that the above | ||
7 | * copyright notice and this permission notice appear in all copies. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
16 | */ | ||
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 | ||
28 | main(void) | ||
29 | { | ||
30 | BIGNUM *m; | ||
31 | |||
32 | if ((m = BN_new()) == NULL) | ||
33 | errx(1, "BN_new"); | ||
34 | |||
35 | BN_zero_ex(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 | printf("SUCCESS\n"); | ||
43 | |||
44 | return 0; | ||
45 | } | ||