summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2014-04-17 15:30:56 +0000
committerjsing <>2014-04-17 15:30:56 +0000
commitc967cb15537b403273b75572fc32e7dbf88e2533 (patch)
treef55a06f9c67e2c754243bcde3b576a7f9ece968c /src
parent8ed9918eace182e8a1648e10322ec464c4cbcd2e (diff)
downloadopenbsd-c967cb15537b403273b75572fc32e7dbf88e2533.tar.gz
openbsd-c967cb15537b403273b75572fc32e7dbf88e2533.tar.bz2
openbsd-c967cb15537b403273b75572fc32e7dbf88e2533.zip
Initial KNF.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libssl/src/apps/ec.c242
-rw-r--r--src/lib/libssl/src/apps/errstr.c64
2 files changed, 133 insertions, 173 deletions
diff --git a/src/lib/libssl/src/apps/ec.c b/src/lib/libssl/src/apps/ec.c
index b9be5d74fc..f64608e9c3 100644
--- a/src/lib/libssl/src/apps/ec.c
+++ b/src/lib/libssl/src/apps/ec.c
@@ -10,7 +10,7 @@
10 * are met: 10 * are met:
11 * 11 *
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 14 *
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in 16 * notice, this list of conditions and the following disclaimer in
@@ -83,7 +83,8 @@
83 83
84int MAIN(int, char **); 84int MAIN(int, char **);
85 85
86int MAIN(int argc, char **argv) 86int
87MAIN(int argc, char **argv)
87{ 88{
88 int ret = 1; 89 int ret = 1;
89 EC_KEY *eckey = NULL; 90 EC_KEY *eckey = NULL;
@@ -91,7 +92,7 @@ int MAIN(int argc, char **argv)
91 int i, badops = 0; 92 int i, badops = 0;
92 const EVP_CIPHER *enc = NULL; 93 const EVP_CIPHER *enc = NULL;
93 BIO *in = NULL, *out = NULL; 94 BIO *in = NULL, *out = NULL;
94 int informat, outformat, text=0, noout=0; 95 int informat, outformat, text = 0, noout = 0;
95 int pubin = 0, pubout = 0, param_out = 0; 96 int pubin = 0, pubout = 0, param_out = 0;
96 char *infile, *outfile, *prog, *engine; 97 char *infile, *outfile, *prog, *engine;
97 char *passargin = NULL, *passargout = NULL; 98 char *passargin = NULL, *passargout = NULL;
@@ -104,7 +105,7 @@ int MAIN(int argc, char **argv)
104 apps_startup(); 105 apps_startup();
105 106
106 if (bio_err == NULL) 107 if (bio_err == NULL)
107 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 108 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
108 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE|BIO_FP_TEXT); 109 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE|BIO_FP_TEXT);
109 110
110 if (!load_config(bio_err, NULL)) 111 if (!load_config(bio_err, NULL))
@@ -119,49 +120,40 @@ int MAIN(int argc, char **argv)
119 prog = argv[0]; 120 prog = argv[0];
120 argc--; 121 argc--;
121 argv++; 122 argv++;
122 while (argc >= 1) 123 while (argc >= 1) {
123 { 124 if (strcmp(*argv, "-inform") == 0) {
124 if (strcmp(*argv,"-inform") == 0) 125 if (--argc < 1)
125 { 126 goto bad;
126 if (--argc < 1) goto bad; 127 informat = str2fmt(*(++argv));
127 informat=str2fmt(*(++argv)); 128 } else if (strcmp(*argv, "-outform") == 0) {
128 } 129 if (--argc < 1)
129 else if (strcmp(*argv,"-outform") == 0) 130 goto bad;
130 { 131 outformat = str2fmt(*(++argv));
131 if (--argc < 1) goto bad; 132 } else if (strcmp(*argv, "-in") == 0) {
132 outformat=str2fmt(*(++argv)); 133 if (--argc < 1)
133 } 134 goto bad;
134 else if (strcmp(*argv,"-in") == 0)
135 {
136 if (--argc < 1) goto bad;
137 infile= *(++argv); 135 infile= *(++argv);
138 } 136 } else if (strcmp(*argv, "-out") == 0) {
139 else if (strcmp(*argv,"-out") == 0) 137 if (--argc < 1)
140 { 138 goto bad;
141 if (--argc < 1) goto bad;
142 outfile= *(++argv); 139 outfile= *(++argv);
143 } 140 } else if (strcmp(*argv, "-passin") == 0) {
144 else if (strcmp(*argv,"-passin") == 0) 141 if (--argc < 1)
145 { 142 goto bad;
146 if (--argc < 1) goto bad;
147 passargin= *(++argv); 143 passargin= *(++argv);
148 } 144 } else if (strcmp(*argv, "-passout") == 0) {
149 else if (strcmp(*argv,"-passout") == 0) 145 if (--argc < 1)
150 { 146 goto bad;
151 if (--argc < 1) goto bad;
152 passargout= *(++argv); 147 passargout= *(++argv);
153 } 148 } else if (strcmp(*argv, "-engine") == 0) {
154 else if (strcmp(*argv, "-engine") == 0) 149 if (--argc < 1)
155 { 150 goto bad;
156 if (--argc < 1) goto bad;
157 engine= *(++argv); 151 engine= *(++argv);
158 } 152 } else if (strcmp(*argv, "-noout") == 0)
159 else if (strcmp(*argv, "-noout") == 0)
160 noout = 1; 153 noout = 1;
161 else if (strcmp(*argv, "-text") == 0) 154 else if (strcmp(*argv, "-text") == 0)
162 text = 1; 155 text = 1;
163 else if (strcmp(*argv, "-conv_form") == 0) 156 else if (strcmp(*argv, "-conv_form") == 0) {
164 {
165 if (--argc < 1) 157 if (--argc < 1)
166 goto bad; 158 goto bad;
167 ++argv; 159 ++argv;
@@ -174,9 +166,7 @@ int MAIN(int argc, char **argv)
174 form = POINT_CONVERSION_HYBRID; 166 form = POINT_CONVERSION_HYBRID;
175 else 167 else
176 goto bad; 168 goto bad;
177 } 169 } else if (strcmp(*argv, "-param_enc") == 0) {
178 else if (strcmp(*argv, "-param_enc") == 0)
179 {
180 if (--argc < 1) 170 if (--argc < 1)
181 goto bad; 171 goto bad;
182 ++argv; 172 ++argv;
@@ -187,139 +177,122 @@ int MAIN(int argc, char **argv)
187 asn1_flag = 0; 177 asn1_flag = 0;
188 else 178 else
189 goto bad; 179 goto bad;
190 } 180 } else if (strcmp(*argv, "-param_out") == 0)
191 else if (strcmp(*argv, "-param_out") == 0)
192 param_out = 1; 181 param_out = 1;
193 else if (strcmp(*argv, "-pubin") == 0) 182 else if (strcmp(*argv, "-pubin") == 0)
194 pubin=1; 183 pubin = 1;
195 else if (strcmp(*argv, "-pubout") == 0) 184 else if (strcmp(*argv, "-pubout") == 0)
196 pubout=1; 185 pubout = 1;
197 else if ((enc=EVP_get_cipherbyname(&(argv[0][1]))) == NULL) 186 else if ((enc = EVP_get_cipherbyname(&(argv[0][1]))) == NULL) {
198 {
199 BIO_printf(bio_err, "unknown option %s\n", *argv); 187 BIO_printf(bio_err, "unknown option %s\n", *argv);
200 badops=1; 188 badops = 1;
201 break; 189 break;
202 } 190 }
203 argc--; 191 argc--;
204 argv++; 192 argv++;
205 } 193 }
206 194
207 if (badops) 195 if (badops) {
208 {
209bad: 196bad:
210 BIO_printf(bio_err, "%s [options] <infile >outfile\n", prog); 197 BIO_printf(bio_err, "%s [options] <infile >outfile\n", prog);
211 BIO_printf(bio_err, "where options are\n"); 198 BIO_printf(bio_err, "where options are\n");
212 BIO_printf(bio_err, " -inform arg input format - " 199 BIO_printf(bio_err, " -inform arg input format - "
213 "DER or PEM\n"); 200 "DER or PEM\n");
214 BIO_printf(bio_err, " -outform arg output format - " 201 BIO_printf(bio_err, " -outform arg output format - "
215 "DER or PEM\n"); 202 "DER or PEM\n");
216 BIO_printf(bio_err, " -in arg input file\n"); 203 BIO_printf(bio_err, " -in arg input file\n");
217 BIO_printf(bio_err, " -passin arg input file pass " 204 BIO_printf(bio_err, " -passin arg input file pass "
218 "phrase source\n"); 205 "phrase source\n");
219 BIO_printf(bio_err, " -out arg output file\n"); 206 BIO_printf(bio_err, " -out arg output file\n");
220 BIO_printf(bio_err, " -passout arg output file pass " 207 BIO_printf(bio_err, " -passout arg output file pass "
221 "phrase source\n"); 208 "phrase source\n");
222 BIO_printf(bio_err, " -engine e use engine e, " 209 BIO_printf(bio_err, " -engine e use engine e, "
223 "possibly a hardware device.\n"); 210 "possibly a hardware device.\n");
224 BIO_printf(bio_err, " -des encrypt PEM output, " 211 BIO_printf(bio_err, " -des encrypt PEM output, "
225 "instead of 'des' every other \n" 212 "instead of 'des' every other \n"
226 " cipher " 213 " cipher "
227 "supported by OpenSSL can be used\n"); 214 "supported by OpenSSL can be used\n");
228 BIO_printf(bio_err, " -text print the key\n"); 215 BIO_printf(bio_err, " -text print the key\n");
229 BIO_printf(bio_err, " -noout don't print key out\n"); 216 BIO_printf(bio_err, " -noout don't print key out\n");
230 BIO_printf(bio_err, " -param_out print the elliptic " 217 BIO_printf(bio_err, " -param_out print the elliptic "
231 "curve parameters\n"); 218 "curve parameters\n");
232 BIO_printf(bio_err, " -conv_form arg specifies the " 219 BIO_printf(bio_err, " -conv_form arg specifies the "
233 "point conversion form \n"); 220 "point conversion form \n");
234 BIO_printf(bio_err, " possible values:" 221 BIO_printf(bio_err, " possible values:"
235 " compressed\n"); 222 " compressed\n");
236 BIO_printf(bio_err, " " 223 BIO_printf(bio_err, " "
237 " uncompressed (default)\n"); 224 " uncompressed (default)\n");
238 BIO_printf(bio_err, " " 225 BIO_printf(bio_err, " "
239 " hybrid\n"); 226 " hybrid\n");
240 BIO_printf(bio_err, " -param_enc arg specifies the way" 227 BIO_printf(bio_err, " -param_enc arg specifies the way"
241 " the ec parameters are encoded\n"); 228 " the ec parameters are encoded\n");
242 BIO_printf(bio_err, " in the asn1 der " 229 BIO_printf(bio_err, " in the asn1 der "
243 "encoding\n"); 230 "encoding\n");
244 BIO_printf(bio_err, " possible values:" 231 BIO_printf(bio_err, " possible values:"
245 " named_curve (default)\n"); 232 " named_curve (default)\n");
246 BIO_printf(bio_err," " 233 BIO_printf(bio_err, " "
247 "explicit\n"); 234 "explicit\n");
248 goto end; 235 goto end;
249 } 236 }
250 237
251 ERR_load_crypto_strings(); 238 ERR_load_crypto_strings();
252 239
253#ifndef OPENSSL_NO_ENGINE 240#ifndef OPENSSL_NO_ENGINE
254 setup_engine(bio_err, engine, 0); 241 setup_engine(bio_err, engine, 0);
255#endif 242#endif
256 243
257 if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) 244 if (!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
258 {
259 BIO_printf(bio_err, "Error getting passwords\n"); 245 BIO_printf(bio_err, "Error getting passwords\n");
260 goto end; 246 goto end;
261 } 247 }
262 248
263 in = BIO_new(BIO_s_file()); 249 in = BIO_new(BIO_s_file());
264 out = BIO_new(BIO_s_file()); 250 out = BIO_new(BIO_s_file());
265 if ((in == NULL) || (out == NULL)) 251 if ((in == NULL) || (out == NULL)) {
266 {
267 ERR_print_errors(bio_err); 252 ERR_print_errors(bio_err);
268 goto end; 253 goto end;
269 } 254 }
270 255
271 if (infile == NULL) 256 if (infile == NULL)
272 BIO_set_fp(in, stdin, BIO_NOCLOSE); 257 BIO_set_fp(in, stdin, BIO_NOCLOSE);
273 else 258 else {
274 { 259 if (BIO_read_filename(in, infile) <= 0) {
275 if (BIO_read_filename(in, infile) <= 0)
276 {
277 perror(infile); 260 perror(infile);
278 goto end; 261 goto end;
279 }
280 } 262 }
263 }
281 264
282 BIO_printf(bio_err, "read EC key\n"); 265 BIO_printf(bio_err, "read EC key\n");
283 if (informat == FORMAT_ASN1) 266 if (informat == FORMAT_ASN1) {
284 { 267 if (pubin)
285 if (pubin)
286 eckey = d2i_EC_PUBKEY_bio(in, NULL); 268 eckey = d2i_EC_PUBKEY_bio(in, NULL);
287 else 269 else
288 eckey = d2i_ECPrivateKey_bio(in, NULL); 270 eckey = d2i_ECPrivateKey_bio(in, NULL);
289 } 271 } else if (informat == FORMAT_PEM) {
290 else if (informat == FORMAT_PEM) 272 if (pubin)
291 { 273 eckey = PEM_read_bio_EC_PUBKEY(in, NULL, NULL,
292 if (pubin) 274 NULL);
293 eckey = PEM_read_bio_EC_PUBKEY(in, NULL, NULL, 275 else
294 NULL);
295 else
296 eckey = PEM_read_bio_ECPrivateKey(in, NULL, NULL, 276 eckey = PEM_read_bio_ECPrivateKey(in, NULL, NULL,
297 passin); 277 passin);
298 } 278 } else {
299 else
300 {
301 BIO_printf(bio_err, "bad input format specified for key\n"); 279 BIO_printf(bio_err, "bad input format specified for key\n");
302 goto end; 280 goto end;
303 } 281 }
304 if (eckey == NULL) 282 if (eckey == NULL) {
305 { 283 BIO_printf(bio_err, "unable to load Key\n");
306 BIO_printf(bio_err,"unable to load Key\n");
307 ERR_print_errors(bio_err); 284 ERR_print_errors(bio_err);
308 goto end; 285 goto end;
309 } 286 }
310 287
311 if (outfile == NULL) 288 if (outfile == NULL) {
312 {
313 BIO_set_fp(out, stdout, BIO_NOCLOSE); 289 BIO_set_fp(out, stdout, BIO_NOCLOSE);
314 } 290 } else {
315 else 291 if (BIO_write_filename(out, outfile) <= 0) {
316 {
317 if (BIO_write_filename(out, outfile) <= 0)
318 {
319 perror(outfile); 292 perror(outfile);
320 goto end; 293 goto end;
321 }
322 } 294 }
295 }
323 296
324 group = EC_KEY_get0_group(eckey); 297 group = EC_KEY_get0_group(eckey);
325 298
@@ -329,54 +302,45 @@ bad:
329 if (new_asn1_flag) 302 if (new_asn1_flag)
330 EC_KEY_set_asn1_flag(eckey, asn1_flag); 303 EC_KEY_set_asn1_flag(eckey, asn1_flag);
331 304
332 if (text) 305 if (text)
333 if (!EC_KEY_print(out, eckey, 0)) 306 if (!EC_KEY_print(out, eckey, 0)) {
334 {
335 perror(outfile); 307 perror(outfile);
336 ERR_print_errors(bio_err); 308 ERR_print_errors(bio_err);
337 goto end; 309 goto end;
338 } 310 }
339 311
340 if (noout) 312 if (noout) {
341 {
342 ret = 0; 313 ret = 0;
343 goto end; 314 goto end;
344 } 315 }
345 316
346 BIO_printf(bio_err, "writing EC key\n"); 317 BIO_printf(bio_err, "writing EC key\n");
347 if (outformat == FORMAT_ASN1) 318 if (outformat == FORMAT_ASN1) {
348 {
349 if (param_out) 319 if (param_out)
350 i = i2d_ECPKParameters_bio(out, group); 320 i = i2d_ECPKParameters_bio(out, group);
351 else if (pubin || pubout) 321 else if (pubin || pubout)
352 i = i2d_EC_PUBKEY_bio(out, eckey); 322 i = i2d_EC_PUBKEY_bio(out, eckey);
353 else 323 else
354 i = i2d_ECPrivateKey_bio(out, eckey); 324 i = i2d_ECPrivateKey_bio(out, eckey);
355 } 325 } else if (outformat == FORMAT_PEM) {
356 else if (outformat == FORMAT_PEM)
357 {
358 if (param_out) 326 if (param_out)
359 i = PEM_write_bio_ECPKParameters(out, group); 327 i = PEM_write_bio_ECPKParameters(out, group);
360 else if (pubin || pubout) 328 else if (pubin || pubout)
361 i = PEM_write_bio_EC_PUBKEY(out, eckey); 329 i = PEM_write_bio_EC_PUBKEY(out, eckey);
362 else 330 else
363 i = PEM_write_bio_ECPrivateKey(out, eckey, enc, 331 i = PEM_write_bio_ECPrivateKey(out, eckey, enc,
364 NULL, 0, NULL, passout); 332 NULL, 0, NULL, passout);
365 } 333 } else {
366 else
367 {
368 BIO_printf(bio_err, "bad output format specified for " 334 BIO_printf(bio_err, "bad output format specified for "
369 "outfile\n"); 335 "outfile\n");
370 goto end; 336 goto end;
371 } 337 }
372 338
373 if (!i) 339 if (!i) {
374 {
375 BIO_printf(bio_err, "unable to write private key\n"); 340 BIO_printf(bio_err, "unable to write private key\n");
376 ERR_print_errors(bio_err); 341 ERR_print_errors(bio_err);
377 } 342 } else
378 else 343 ret = 0;
379 ret=0;
380end: 344end:
381 if (in) 345 if (in)
382 BIO_free(in); 346 BIO_free(in);
@@ -394,7 +358,7 @@ end:
394#else /* !OPENSSL_NO_EC */ 358#else /* !OPENSSL_NO_EC */
395 359
396# if PEDANTIC 360# if PEDANTIC
397static void *dummy=&dummy; 361static void *dummy = &dummy;
398# endif 362# endif
399 363
400#endif 364#endif
diff --git a/src/lib/libssl/src/apps/errstr.c b/src/lib/libssl/src/apps/errstr.c
index f9b4a4f093..00c489be0e 100644
--- a/src/lib/libssl/src/apps/errstr.c
+++ b/src/lib/libssl/src/apps/errstr.c
@@ -5,21 +5,21 @@
5 * This package is an SSL implementation written 5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com). 6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL. 7 * The implementation was written so as to conform with Netscapes SSL.
8 * 8 *
9 * This library is free for commercial and non-commercial use as long as 9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions 10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA, 11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation 12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms 13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com). 14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 * 15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in 16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed. 17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution 18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used. 19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or 20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package. 21 * in documentation (online or textual) provided with the package.
22 * 22 *
23 * Redistribution and use in source and binary forms, with or without 23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions 24 * modification, are permitted provided that the following conditions
25 * are met: 25 * are met:
@@ -34,10 +34,10 @@
34 * Eric Young (eay@cryptsoft.com)" 34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library 35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-). 36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from 37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement: 38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 * 40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,7 +49,7 @@
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE. 51 * SUCH DAMAGE.
52 * 52 *
53 * The licence and distribution terms for any publically available version or 53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be 54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence 55 * copied and put under another distribution licence
@@ -70,53 +70,49 @@
70 70
71int MAIN(int, char **); 71int MAIN(int, char **);
72 72
73int MAIN(int argc, char **argv) 73int
74 { 74MAIN(int argc, char **argv)
75 int i,ret=0; 75{
76 int i, ret = 0;
76 char buf[256]; 77 char buf[256];
77 unsigned long l; 78 unsigned long l;
78 79
79 apps_startup(); 80 apps_startup();
80 81
81 if (bio_err == NULL) 82 if (bio_err == NULL)
82 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 83 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
83 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 84 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE|BIO_FP_TEXT);
84 85
85 SSL_load_error_strings(); 86 SSL_load_error_strings();
86 87
87 if ((argc > 1) && (strcmp(argv[1],"-stats") == 0)) 88 if ((argc > 1) && (strcmp(argv[1], "-stats") == 0)) {
88 { 89 BIO *out = NULL;
89 BIO *out=NULL;
90 90
91 out=BIO_new(BIO_s_file()); 91 out = BIO_new(BIO_s_file());
92 if ((out != NULL) && BIO_set_fp(out,stdout,BIO_NOCLOSE)) 92 if ((out != NULL) && BIO_set_fp(out, stdout, BIO_NOCLOSE)) {
93 {
94 lh_ERR_STRING_DATA_node_stats_bio( 93 lh_ERR_STRING_DATA_node_stats_bio(
95 ERR_get_string_table(), out); 94 ERR_get_string_table(), out);
96 lh_ERR_STRING_DATA_stats_bio(ERR_get_string_table(), 95 lh_ERR_STRING_DATA_stats_bio(ERR_get_string_table(),
97 out); 96 out);
98 lh_ERR_STRING_DATA_node_usage_stats_bio( 97 lh_ERR_STRING_DATA_node_usage_stats_bio(
99 ERR_get_string_table(),out); 98 ERR_get_string_table(), out);
100 } 99 }
101 if (out != NULL) BIO_free_all(out); 100 if (out != NULL)
101 BIO_free_all(out);
102 argc--; 102 argc--;
103 argv++; 103 argv++;
104 } 104 }
105 105
106 for (i=1; i<argc; i++) 106 for (i = 1; i < argc; i++) {
107 { 107 if (sscanf(argv[i], "%lx",&l)) {
108 if (sscanf(argv[i],"%lx",&l))
109 {
110 ERR_error_string_n(l, buf, sizeof buf); 108 ERR_error_string_n(l, buf, sizeof buf);
111 printf("%s\n",buf); 109 printf("%s\n", buf);
112 } 110 } else {
113 else 111 printf("%s: bad error code\n", argv[i]);
114 {
115 printf("%s: bad error code\n",argv[i]);
116 printf("usage: errstr [-stats] <errno> ...\n"); 112 printf("usage: errstr [-stats] <errno> ...\n");
117 ret++; 113 ret++;
118 }
119 } 114 }
115 }
120 apps_shutdown(); 116 apps_shutdown();
121 OPENSSL_EXIT(ret); 117 OPENSSL_EXIT(ret);
122 } 118}