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
2
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3
3
* All rights reserved.
4
4
*
60
60
#include <stdlib.h>
61
61
#include <string.h>
62
62
63
- #include <openssl/bio.h>
64
63
#include <openssl/bn.h>
65
64
#include <openssl/err.h>
66
65
@@ -74,7 +73,6 @@ main(int argc, char *argv[])
74
73
BIGNUM * r_mont , * r_mont_const , * r_recp , * r_simple ;
75
74
BIGNUM * r_mont_ct , * r_mont_nonct , * a , * b , * m ;
76
75
BN_CTX * ctx ;
77
- BIO * out = NULL ;
78
76
unsigned char c ;
79
77
int i , ret ;
80
78
@@ -104,10 +102,6 @@ main(int argc, char *argv[])
104
102
if ((m = BN_CTX_get (ctx )) == NULL )
105
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
105
for (i = 0 ; i < 200 ; i ++ ) {
112
106
arc4random_buf (& c , 1 );
113
107
c = (c % BN_BITS ) - BN_BITS2 ;
@@ -180,19 +174,19 @@ main(int argc, char *argv[])
180
174
printf ("\nmont_ct and mont_nonct results differ\n" );
181
175
182
176
printf ("a (%3d) = " , BN_num_bits (a ));
183
- BN_print ( out , a );
177
+ BN_print_fp ( stdout , a );
184
178
printf ("\nb (%3d) = " , BN_num_bits (b ));
185
- BN_print ( out , b );
179
+ BN_print_fp ( stdout , b );
186
180
printf ("\nm (%3d) = " , BN_num_bits (m ));
187
- BN_print ( out , m );
181
+ BN_print_fp ( stdout , m );
188
182
printf ("\nsimple =" );
189
- BN_print ( out , r_simple );
183
+ BN_print_fp ( stdout , r_simple );
190
184
printf ("\nrecp =" );
191
- BN_print ( out , r_recp );
185
+ BN_print_fp ( stdout , r_recp );
192
186
printf ("\nmont =" );
193
- BN_print ( out , r_mont );
187
+ BN_print_fp ( stdout , r_mont );
194
188
printf ("\nmont_ct =" );
195
- BN_print ( out , r_mont_const );
189
+ BN_print_fp ( stdout , r_mont_const );
196
190
printf ("\n" );
197
191
exit (1 );
198
192
}
@@ -201,13 +195,11 @@ main(int argc, char *argv[])
201
195
BN_CTX_end (ctx );
202
196
BN_CTX_free (ctx );
203
197
ERR_remove_thread_state (NULL );
204
- CRYPTO_mem_leaks (out );
205
- BIO_free (out );
206
198
207
199
return (0 );
208
200
209
201
err :
210
202
ERR_load_crypto_strings ();
211
- ERR_print_errors ( out );
203
+ ERR_print_errors_fp ( stdout );
212
204
return (1 );
213
205
}
0 commit comments