Skip to content

Commit bfffc10

Browse files
author
tb
committed
bn_mod_exp.c: printing to stdout needs no BIO
1 parent a4daaec commit bfffc10

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

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

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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 $ */
22
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
33
* All rights reserved.
44
*
@@ -60,7 +60,6 @@
6060
#include <stdlib.h>
6161
#include <string.h>
6262

63-
#include <openssl/bio.h>
6463
#include <openssl/bn.h>
6564
#include <openssl/err.h>
6665

@@ -74,7 +73,6 @@ main(int argc, char *argv[])
7473
BIGNUM *r_mont, *r_mont_const, *r_recp, *r_simple;
7574
BIGNUM *r_mont_ct, *r_mont_nonct, *a, *b, *m;
7675
BN_CTX *ctx;
77-
BIO *out = NULL;
7876
unsigned char c;
7977
int i, ret;
8078

@@ -104,10 +102,6 @@ main(int argc, char *argv[])
104102
if ((m = BN_CTX_get(ctx)) == NULL)
105103
goto err;
106104

107-
if ((out = BIO_new(BIO_s_file())) == NULL)
108-
exit(1);
109-
BIO_set_fp(out, stdout, BIO_NOCLOSE);
110-
111105
for (i = 0; i < 200; i++) {
112106
arc4random_buf(&c, 1);
113107
c = (c % BN_BITS) - BN_BITS2;
@@ -180,19 +174,19 @@ main(int argc, char *argv[])
180174
printf("\nmont_ct and mont_nonct results differ\n");
181175

182176
printf("a (%3d) = ", BN_num_bits(a));
183-
BN_print(out, a);
177+
BN_print_fp(stdout, a);
184178
printf("\nb (%3d) = ", BN_num_bits(b));
185-
BN_print(out, b);
179+
BN_print_fp(stdout, b);
186180
printf("\nm (%3d) = ", BN_num_bits(m));
187-
BN_print(out, m);
181+
BN_print_fp(stdout, m);
188182
printf("\nsimple =");
189-
BN_print(out, r_simple);
183+
BN_print_fp(stdout, r_simple);
190184
printf("\nrecp =");
191-
BN_print(out, r_recp);
185+
BN_print_fp(stdout, r_recp);
192186
printf("\nmont =");
193-
BN_print(out, r_mont);
187+
BN_print_fp(stdout, r_mont);
194188
printf("\nmont_ct =");
195-
BN_print(out, r_mont_const);
189+
BN_print_fp(stdout, r_mont_const);
196190
printf("\n");
197191
exit(1);
198192
}
@@ -201,13 +195,11 @@ main(int argc, char *argv[])
201195
BN_CTX_end(ctx);
202196
BN_CTX_free(ctx);
203197
ERR_remove_thread_state(NULL);
204-
CRYPTO_mem_leaks(out);
205-
BIO_free(out);
206198

207199
return (0);
208200

209201
err:
210202
ERR_load_crypto_strings();
211-
ERR_print_errors(out);
203+
ERR_print_errors_fp(stdout);
212204
return (1);
213205
}

0 commit comments

Comments
 (0)