summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libcrypto/bn/bn_mod_exp.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/regress/lib/libcrypto/bn/bn_mod_exp.c b/src/regress/lib/libcrypto/bn/bn_mod_exp.c
index 591d603182..236851bc75 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.4 2022/12/02 18:24:01 tb Exp $ */ 1/* $OpenBSD: bn_mod_exp.c,v 1.5 2022/12/02 18:31:40 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 *
@@ -60,7 +60,6 @@
60#include <stdlib.h> 60#include <stdlib.h>
61#include <string.h> 61#include <string.h>
62 62
63#include <openssl/bio.h>
64#include <openssl/bn.h> 63#include <openssl/bn.h>
65#include <openssl/err.h> 64#include <openssl/err.h>
66 65
@@ -74,7 +73,6 @@ main(int argc, char *argv[])
74 BIGNUM *r_mont, *r_mont_const, *r_recp, *r_simple; 73 BIGNUM *r_mont, *r_mont_const, *r_recp, *r_simple;
75 BIGNUM *r_mont_ct, *r_mont_nonct, *a, *b, *m; 74 BIGNUM *r_mont_ct, *r_mont_nonct, *a, *b, *m;
76 BN_CTX *ctx; 75 BN_CTX *ctx;
77 BIO *out = NULL;
78 unsigned char c; 76 unsigned char c;
79 int i, ret; 77 int i, ret;
80 78
@@ -104,10 +102,6 @@ main(int argc, char *argv[])
104 if ((m = BN_CTX_get(ctx)) == NULL) 102 if ((m = BN_CTX_get(ctx)) == NULL)
105 goto err; 103 goto err;
106 104
107 if ((out = BIO_new(BIO_s_file())) == NULL)
108 exit(1);
109 BIO_set_fp(out, stdout, BIO_NOCLOSE);
110
111 for (i = 0; i < 200; i++) { 105 for (i = 0; i < 200; i++) {
112 arc4random_buf(&c, 1); 106 arc4random_buf(&c, 1);
113 c = (c % BN_BITS) - BN_BITS2; 107 c = (c % BN_BITS) - BN_BITS2;
@@ -180,19 +174,19 @@ main(int argc, char *argv[])
180 printf("\nmont_ct and mont_nonct results differ\n"); 174 printf("\nmont_ct and mont_nonct results differ\n");
181 175
182 printf("a (%3d) = ", BN_num_bits(a)); 176 printf("a (%3d) = ", BN_num_bits(a));
183 BN_print(out, a); 177 BN_print_fp(stdout, a);
184 printf("\nb (%3d) = ", BN_num_bits(b)); 178 printf("\nb (%3d) = ", BN_num_bits(b));
185 BN_print(out, b); 179 BN_print_fp(stdout, b);
186 printf("\nm (%3d) = ", BN_num_bits(m)); 180 printf("\nm (%3d) = ", BN_num_bits(m));
187 BN_print(out, m); 181 BN_print_fp(stdout, m);
188 printf("\nsimple ="); 182 printf("\nsimple =");
189 BN_print(out, r_simple); 183 BN_print_fp(stdout, r_simple);
190 printf("\nrecp ="); 184 printf("\nrecp =");
191 BN_print(out, r_recp); 185 BN_print_fp(stdout, r_recp);
192 printf("\nmont ="); 186 printf("\nmont =");
193 BN_print(out, r_mont); 187 BN_print_fp(stdout, r_mont);
194 printf("\nmont_ct ="); 188 printf("\nmont_ct =");
195 BN_print(out, r_mont_const); 189 BN_print_fp(stdout, r_mont_const);
196 printf("\n"); 190 printf("\n");
197 exit(1); 191 exit(1);
198 } 192 }
@@ -201,13 +195,11 @@ main(int argc, char *argv[])
201 BN_CTX_end(ctx); 195 BN_CTX_end(ctx);
202 BN_CTX_free(ctx); 196 BN_CTX_free(ctx);
203 ERR_remove_thread_state(NULL); 197 ERR_remove_thread_state(NULL);
204 CRYPTO_mem_leaks(out);
205 BIO_free(out);
206 198
207 return (0); 199 return (0);
208 200
209 err: 201 err:
210 ERR_load_crypto_strings(); 202 ERR_load_crypto_strings();
211 ERR_print_errors(out); 203 ERR_print_errors_fp(stdout);
212 return (1); 204 return (1);
213} 205}