summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/bn/bn_exp.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lib/libcrypto/bn/bn_exp.c b/src/lib/libcrypto/bn/bn_exp.c
index c4ca36d136..9dcbf007f7 100644
--- a/src/lib/libcrypto/bn/bn_exp.c
+++ b/src/lib/libcrypto/bn/bn_exp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_exp.c,v 1.23 2015/09/10 15:56:25 jsing Exp $ */ 1/* $OpenBSD: bn_exp.c,v 1.24 2016/09/03 14:37:52 bcook 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 *
@@ -589,13 +589,14 @@ BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
589 bn_check_top(p); 589 bn_check_top(p);
590 bn_check_top(m); 590 bn_check_top(m);
591 591
592 top = m->top; 592 if (!BN_is_odd(m)) {
593
594 if (!(m->d[0] & 1)) {
595 BNerr(BN_F_BN_MOD_EXP_MONT_CONSTTIME, 593 BNerr(BN_F_BN_MOD_EXP_MONT_CONSTTIME,
596 BN_R_CALLED_WITH_EVEN_MODULUS); 594 BN_R_CALLED_WITH_EVEN_MODULUS);
597 return (0); 595 return (0);
598 } 596 }
597
598 top = m->top;
599
599 bits = BN_num_bits(p); 600 bits = BN_num_bits(p);
600 if (bits == 0) { 601 if (bits == 0) {
601 ret = BN_one(rr); 602 ret = BN_one(rr);