Skip to content

Commit 58884ff

Browse files
author
tb
committed
Add missing checks for BN_mod_exp_{non,}ct()
Someone added a few more functions to test, but forgot to check their results, so if they would not do the expected thing that would only be noticed if one of the already tested functions would break.
1 parent 8e86d9d commit 58884ff

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/regress/lib/libcrypto/bn/bn_mod_exp.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: bn_mod_exp.c,v 1.6 2022/12/03 08:05:52 tb Exp $ */
1+
/* $OpenBSD: bn_mod_exp.c,v 1.7 2022/12/03 08:21:38 tb Exp $ */
22
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
33
* All rights reserved.
44
*
@@ -157,18 +157,20 @@ main(int argc, char *argv[])
157157
}
158158

159159
if (BN_cmp(r_simple, r_mont) != 0 ||
160+
BN_cmp(r_simple, r_mont_const) ||
160161
BN_cmp(r_simple, r_recp) != 0 ||
161-
BN_cmp(r_simple, r_mont_const) != 0) {
162+
BN_cmp(r_simple, r_mont_ct) != 0 ||
163+
BN_cmp(r_simple, r_mont_nonct) != 0) {
162164
if (BN_cmp(r_simple, r_mont) != 0)
163165
printf("\nsimple and mont results differ\n");
164166
if (BN_cmp(r_simple, r_mont_const) != 0)
165167
printf("\nsimple and mont const time results differ\n");
166168
if (BN_cmp(r_simple, r_recp) != 0)
167169
printf("\nsimple and recp results differ\n");
168-
if (BN_cmp(r_mont, r_mont_ct) != 0)
169-
printf("\nmont_ct and mont results differ\n");
170-
if (BN_cmp(r_mont_ct, r_mont_nonct) != 0)
171-
printf("\nmont_ct and mont_nonct results differ\n");
170+
if (BN_cmp(r_simple, r_mont_ct) != 0)
171+
printf("\nsimple and mont results differ\n");
172+
if (BN_cmp(r_simple, r_mont_nonct) != 0)
173+
printf("\nsimple and mont_nonct results differ\n");
172174

173175
printf("a (%3d) = ", BN_num_bits(a));
174176
BN_print_fp(stdout, a);

0 commit comments

Comments
 (0)