summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2022-02-07 19:49:56 +0000
committertb <>2022-02-07 19:49:56 +0000
commit85d4f87943d9be28ebbe3103b55c264e0570f547 (patch)
treeac6407f70fcd8e0ab79125eccf3633f4e4fa39c9 /src
parent4f6fe11c9458f94a9e6844c0eefb70e0242edd96 (diff)
downloadopenbsd-85d4f87943d9be28ebbe3103b55c264e0570f547.tar.gz
openbsd-85d4f87943d9be28ebbe3103b55c264e0570f547.tar.bz2
openbsd-85d4f87943d9be28ebbe3103b55c264e0570f547.zip
Avoid a NULL dereference in BN_mod_exp2_mont()
This is a very rarely used function and the crash is hard to reach in practice. Instead of implementing BN_is_odd() badly by hand, just call the real thing. Reported by Guido Vranken ok beck jsing
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/bn/bn_exp2.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/libcrypto/bn/bn_exp2.c b/src/lib/libcrypto/bn/bn_exp2.c
index 372e1ee4ee..c63503f941 100644
--- a/src/lib/libcrypto/bn/bn_exp2.c
+++ b/src/lib/libcrypto/bn/bn_exp2.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_exp2.c,v 1.12 2017/01/29 17:49:22 beck Exp $ */ 1/* $OpenBSD: bn_exp2.c,v 1.13 2022/02/07 19:49:56 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -136,7 +136,7 @@ BN_mod_exp2_mont(BIGNUM *rr, const BIGNUM *a1, const BIGNUM *p1,
136 bn_check_top(p2); 136 bn_check_top(p2);
137 bn_check_top(m); 137 bn_check_top(m);
138 138
139 if (!(m->d[0] & 1)) { 139 if (!BN_is_odd(m)) {
140 BNerror(BN_R_CALLED_WITH_EVEN_MODULUS); 140 BNerror(BN_R_CALLED_WITH_EVEN_MODULUS);
141 return (0); 141 return (0);
142 } 142 }