summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/regress/lib/libcrypto/bn/bn_mod_exp.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/regress/lib/libcrypto/bn/bn_mod_exp.c b/src/regress/lib/libcrypto/bn/bn_mod_exp.c
index dc0fe27870..d12d9f1e05 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.2 2022/12/02 17:33:38 tb Exp $ */ 1/* $OpenBSD: bn_mod_exp.c,v 1.3 2022/12/02 17:42:45 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 *
@@ -108,18 +108,23 @@ main(int argc, char *argv[])
108 for (i = 0; i < 200; i++) { 108 for (i = 0; i < 200; i++) {
109 arc4random_buf(&c, 1); 109 arc4random_buf(&c, 1);
110 c = (c % BN_BITS) - BN_BITS2; 110 c = (c % BN_BITS) - BN_BITS2;
111 BN_rand(a, NUM_BITS + c, 0, 0); 111 if (!BN_rand(a, NUM_BITS + c, 0, 0))
112 goto err;
112 113
113 arc4random_buf(&c, 1); 114 arc4random_buf(&c, 1);
114 c = (c % BN_BITS) - BN_BITS2; 115 c = (c % BN_BITS) - BN_BITS2;
115 BN_rand(b, NUM_BITS + c, 0, 0); 116 if (!BN_rand(b, NUM_BITS + c, 0, 0))
117 goto err;
116 118
117 arc4random_buf(&c, 1); 119 arc4random_buf(&c, 1);
118 c = (c % BN_BITS) - BN_BITS2; 120 c = (c % BN_BITS) - BN_BITS2;
119 BN_rand(m, NUM_BITS + c, 0, 1); 121 if (!BN_rand(m, NUM_BITS + c, 0, 1))
122 goto err;
120 123
121 BN_mod(a, a, m, ctx); 124 if (!BN_mod(a, a, m, ctx))
122 BN_mod(b, b, m, ctx); 125 goto err;
126 if (!BN_mod(b, b, m, ctx))
127 goto err;
123 128
124 ret = BN_mod_exp_mont(r_mont, a, b, m, ctx, NULL); 129 ret = BN_mod_exp_mont(r_mont, a, b, m, ctx, NULL);
125 if (ret <= 0) { 130 if (ret <= 0) {