Skip to content

Commit f4d5104

Browse files
author
tb
committed
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
1 parent f9bcf55 commit f4d5104

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/lib/libcrypto/bn/bn_exp2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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 $ */
22
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
33
* All rights reserved.
44
*
@@ -136,7 +136,7 @@ BN_mod_exp2_mont(BIGNUM *rr, const BIGNUM *a1, const BIGNUM *p1,
136136
bn_check_top(p2);
137137
bn_check_top(m);
138138

139-
if (!(m->d[0] & 1)) {
139+
if (!BN_is_odd(m)) {
140140
BNerror(BN_R_CALLED_WITH_EVEN_MODULUS);
141141
return (0);
142142
}

0 commit comments

Comments
 (0)