dgst.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. /* apps/dgst.c */
  2. /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  3. * All rights reserved.
  4. *
  5. * This package is an SSL implementation written
  6. * by Eric Young (eay@cryptsoft.com).
  7. * The implementation was written so as to conform with Netscapes SSL.
  8. *
  9. * This library is free for commercial and non-commercial use as long as
  10. * the following conditions are aheared to. The following conditions
  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
  13. * included with this distribution is covered by the same copyright terms
  14. * except that the holder is Tim Hudson (tjh@cryptsoft.com).
  15. *
  16. * Copyright remains Eric Young's, and as such any Copyright notices in
  17. * the code are not to be removed.
  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.
  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.
  22. *
  23. * Redistribution and use in source and binary forms, with or without
  24. * modification, are permitted provided that the following conditions
  25. * are met:
  26. * 1. Redistributions of source code must retain the copyright
  27. * notice, this list of conditions and the following disclaimer.
  28. * 2. Redistributions in binary form must reproduce the above copyright
  29. * notice, this list of conditions and the following disclaimer in the
  30. * documentation and/or other materials provided with the distribution.
  31. * 3. All advertising materials mentioning features or use of this software
  32. * must display the following acknowledgement:
  33. * "This product includes cryptographic software written by
  34. * Eric Young (eay@cryptsoft.com)"
  35. * The word 'cryptographic' can be left out if the rouines from the library
  36. * being used are not cryptographic related :-).
  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:
  39. * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
  40. *
  41. * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  42. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  43. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  44. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  45. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  46. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  47. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  48. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  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
  51. * SUCH DAMAGE.
  52. *
  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
  55. * copied and put under another distribution licence
  56. * [including the GNU Public Licence.]
  57. */
  58. #include <stdio.h>
  59. #include <string.h>
  60. #include <stdlib.h>
  61. #include "apps.h"
  62. #include <openssl/bio.h>
  63. #include <openssl/err.h>
  64. #include <openssl/evp.h>
  65. #include <openssl/objects.h>
  66. #include <openssl/x509.h>
  67. #include <openssl/pem.h>
  68. #include <openssl/hmac.h>
  69. #undef BUFSIZE
  70. #define BUFSIZE 1024*8
  71. #undef PROG
  72. #define PROG dgst_main
  73. int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
  74. EVP_PKEY *key, unsigned char *sigin, int siglen,
  75. const char *sig_name, const char *md_name,
  76. const char *file,BIO *bmd);
  77. int MAIN(int, char **);
  78. int MAIN(int argc, char **argv)
  79. {
  80. ENGINE *e = NULL;
  81. unsigned char *buf=NULL;
  82. int i,err=1;
  83. const EVP_MD *md=NULL,*m;
  84. BIO *in=NULL,*inp;
  85. BIO *bmd=NULL;
  86. BIO *out = NULL;
  87. #define PROG_NAME_SIZE 39
  88. char pname[PROG_NAME_SIZE+1];
  89. int separator=0;
  90. int debug=0;
  91. int keyform=FORMAT_PEM;
  92. const char *outfile = NULL, *keyfile = NULL;
  93. const char *sigfile = NULL, *randfile = NULL;
  94. int out_bin = -1, want_pub = 0, do_verify = 0;
  95. EVP_PKEY *sigkey = NULL;
  96. unsigned char *sigbuf = NULL;
  97. int siglen = 0;
  98. char *passargin = NULL, *passin = NULL;
  99. #ifndef OPENSSL_NO_ENGINE
  100. char *engine=NULL;
  101. #endif
  102. char *hmac_key=NULL;
  103. char *mac_name=NULL;
  104. STACK *sigopts = NULL, *macopts = NULL;
  105. apps_startup();
  106. if ((buf=(unsigned char *)OPENSSL_malloc(BUFSIZE)) == NULL)
  107. {
  108. BIO_printf(bio_err,"out of memory\n");
  109. goto end;
  110. }
  111. if (bio_err == NULL)
  112. if ((bio_err=BIO_new(BIO_s_file())) != NULL)
  113. BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
  114. if (!load_config(bio_err, NULL))
  115. goto end;
  116. /* first check the program name */
  117. program_name(argv[0],pname,sizeof pname);
  118. md=EVP_get_digestbyname(pname);
  119. argc--;
  120. argv++;
  121. while (argc > 0)
  122. {
  123. if ((*argv)[0] != '-') break;
  124. if (strcmp(*argv,"-c") == 0)
  125. separator=1;
  126. else if (strcmp(*argv,"-rand") == 0)
  127. {
  128. if (--argc < 1) break;
  129. randfile=*(++argv);
  130. }
  131. else if (strcmp(*argv,"-out") == 0)
  132. {
  133. if (--argc < 1) break;
  134. outfile=*(++argv);
  135. }
  136. else if (strcmp(*argv,"-sign") == 0)
  137. {
  138. if (--argc < 1) break;
  139. keyfile=*(++argv);
  140. }
  141. else if (!strcmp(*argv,"-passin"))
  142. {
  143. if (--argc < 1)
  144. break;
  145. passargin=*++argv;
  146. }
  147. else if (strcmp(*argv,"-verify") == 0)
  148. {
  149. if (--argc < 1) break;
  150. keyfile=*(++argv);
  151. want_pub = 1;
  152. do_verify = 1;
  153. }
  154. else if (strcmp(*argv,"-prverify") == 0)
  155. {
  156. if (--argc < 1) break;
  157. keyfile=*(++argv);
  158. do_verify = 1;
  159. }
  160. else if (strcmp(*argv,"-signature") == 0)
  161. {
  162. if (--argc < 1) break;
  163. sigfile=*(++argv);
  164. }
  165. else if (strcmp(*argv,"-keyform") == 0)
  166. {
  167. if (--argc < 1) break;
  168. keyform=str2fmt(*(++argv));
  169. }
  170. #ifndef OPENSSL_NO_ENGINE
  171. else if (strcmp(*argv,"-engine") == 0)
  172. {
  173. if (--argc < 1) break;
  174. engine= *(++argv);
  175. e = setup_engine(bio_err, engine, 0);
  176. }
  177. #endif
  178. else if (strcmp(*argv,"-hex") == 0)
  179. out_bin = 0;
  180. else if (strcmp(*argv,"-binary") == 0)
  181. out_bin = 1;
  182. else if (strcmp(*argv,"-d") == 0)
  183. debug=1;
  184. else if (!strcmp(*argv,"-hmac"))
  185. {
  186. if (--argc < 1)
  187. break;
  188. hmac_key=*++argv;
  189. }
  190. else if (!strcmp(*argv,"-mac"))
  191. {
  192. if (--argc < 1)
  193. break;
  194. mac_name=*++argv;
  195. }
  196. else if (strcmp(*argv,"-sigopt") == 0)
  197. {
  198. if (--argc < 1)
  199. break;
  200. if (!sigopts)
  201. sigopts = sk_new_null();
  202. if (!sigopts || !sk_push(sigopts, *(++argv)))
  203. break;
  204. }
  205. else if (strcmp(*argv,"-macopt") == 0)
  206. {
  207. if (--argc < 1)
  208. break;
  209. if (!macopts)
  210. macopts = sk_new_null();
  211. if (!macopts || !sk_push(macopts, *(++argv)))
  212. break;
  213. }
  214. else if ((m=EVP_get_digestbyname(&((*argv)[1]))) != NULL)
  215. md=m;
  216. else
  217. break;
  218. argc--;
  219. argv++;
  220. }
  221. if(do_verify && !sigfile) {
  222. BIO_printf(bio_err, "No signature to verify: use the -signature option\n");
  223. goto end;
  224. }
  225. if ((argc > 0) && (argv[0][0] == '-')) /* bad option */
  226. {
  227. BIO_printf(bio_err,"unknown option '%s'\n",*argv);
  228. BIO_printf(bio_err,"options are\n");
  229. BIO_printf(bio_err,"-c to output the digest with separating colons\n");
  230. BIO_printf(bio_err,"-d to output debug info\n");
  231. BIO_printf(bio_err,"-hex output as hex dump\n");
  232. BIO_printf(bio_err,"-binary output in binary form\n");
  233. BIO_printf(bio_err,"-sign file sign digest using private key in file\n");
  234. BIO_printf(bio_err,"-verify file verify a signature using public key in file\n");
  235. BIO_printf(bio_err,"-prverify file verify a signature using private key in file\n");
  236. BIO_printf(bio_err,"-keyform arg key file format (PEM or ENGINE)\n");
  237. BIO_printf(bio_err,"-signature file signature to verify\n");
  238. BIO_printf(bio_err,"-sigopt nm:v signature parameter\n");
  239. BIO_printf(bio_err,"-binary output in binary form\n");
  240. BIO_printf(bio_err,"-hmac key create hashed MAC with key\n");
  241. #ifndef OPENSSL_NO_ENGINE
  242. BIO_printf(bio_err,"-engine e use engine e, possibly a hardware device.\n");
  243. #endif
  244. BIO_printf(bio_err,"-%-14s to use the %s message digest algorithm (default)\n",
  245. LN_md5,LN_md5);
  246. BIO_printf(bio_err,"-%-14s to use the %s message digest algorithm\n",
  247. LN_md4,LN_md4);
  248. BIO_printf(bio_err,"-%-14s to use the %s message digest algorithm\n",
  249. LN_md2,LN_md2);
  250. #ifndef OPENSSL_NO_SHA
  251. BIO_printf(bio_err,"-%-14s to use the %s message digest algorithm\n",
  252. LN_sha1,LN_sha1);
  253. #ifndef OPENSSL_NO_SHA256
  254. BIO_printf(bio_err,"-%-14s to use the %s message digest algorithm\n",
  255. LN_sha224,LN_sha224);
  256. BIO_printf(bio_err,"-%-14s to use the %s message digest algorithm\n",
  257. LN_sha256,LN_sha256);
  258. #endif
  259. #ifndef OPENSSL_NO_SHA512
  260. BIO_printf(bio_err,"-%-14s to use the %s message digest algorithm\n",
  261. LN_sha384,LN_sha384);
  262. BIO_printf(bio_err,"-%-14s to use the %s message digest algorithm\n",
  263. LN_sha512,LN_sha512);
  264. #endif
  265. #endif
  266. BIO_printf(bio_err,"-%-14s to use the %s message digest algorithm\n",
  267. LN_mdc2,LN_mdc2);
  268. BIO_printf(bio_err,"-%-14s to use the %s message digest algorithm\n",
  269. LN_ripemd160,LN_ripemd160);
  270. #ifndef OPENSSL_NO_WHIRLPOOL
  271. BIO_printf(bio_err,"-%-14s to use the %s message digest algorithm\n",
  272. SN_whirlpool,SN_whirlpool);
  273. #endif
  274. goto end;
  275. }
  276. in=BIO_new(BIO_s_file());
  277. bmd=BIO_new(BIO_f_md());
  278. if (debug)
  279. {
  280. BIO_set_callback(in,BIO_debug_callback);
  281. /* needed for windows 3.1 */
  282. BIO_set_callback_arg(in,(char *)bio_err);
  283. }
  284. if(!app_passwd(bio_err, passargin, NULL, &passin, NULL))
  285. {
  286. BIO_printf(bio_err, "Error getting password\n");
  287. goto end;
  288. }
  289. if ((in == NULL) || (bmd == NULL))
  290. {
  291. ERR_print_errors(bio_err);
  292. goto end;
  293. }
  294. if(out_bin == -1) {
  295. if(keyfile)
  296. out_bin = 1;
  297. else
  298. out_bin = 0;
  299. }
  300. if(randfile)
  301. app_RAND_load_file(randfile, bio_err, 0);
  302. if(outfile) {
  303. if(out_bin)
  304. out = BIO_new_file(outfile, "wb");
  305. else out = BIO_new_file(outfile, "w");
  306. } else {
  307. out = BIO_new_fp(stdout, BIO_NOCLOSE);
  308. #ifdef OPENSSL_SYS_VMS
  309. {
  310. BIO *tmpbio = BIO_new(BIO_f_linebuffer());
  311. out = BIO_push(tmpbio, out);
  312. }
  313. #endif
  314. }
  315. if(!out) {
  316. BIO_printf(bio_err, "Error opening output file %s\n",
  317. outfile ? outfile : "(stdout)");
  318. ERR_print_errors(bio_err);
  319. goto end;
  320. }
  321. if ((!!mac_name + !!keyfile + !!hmac_key) > 1)
  322. {
  323. BIO_printf(bio_err, "MAC and Signing key cannot both be specified\n");
  324. goto end;
  325. }
  326. if(keyfile)
  327. {
  328. if (want_pub)
  329. sigkey = load_pubkey(bio_err, keyfile, keyform, 0, NULL,
  330. e, "key file");
  331. else
  332. sigkey = load_key(bio_err, keyfile, keyform, 0, passin,
  333. e, "key file");
  334. if (!sigkey)
  335. {
  336. /* load_[pub]key() has already printed an appropriate
  337. message */
  338. goto end;
  339. }
  340. }
  341. if (mac_name)
  342. {
  343. EVP_PKEY_CTX *mac_ctx = NULL;
  344. int r = 0;
  345. if (!init_gen_str(bio_err, &mac_ctx, mac_name,e, 0))
  346. goto mac_end;
  347. if (macopts)
  348. {
  349. char *macopt;
  350. for (i = 0; i < sk_num(macopts); i++)
  351. {
  352. macopt = sk_value(macopts, i);
  353. if (pkey_ctrl_string(mac_ctx, macopt) <= 0)
  354. {
  355. BIO_printf(bio_err,
  356. "MAC parameter error \"%s\"\n",
  357. macopt);
  358. ERR_print_errors(bio_err);
  359. goto mac_end;
  360. }
  361. }
  362. }
  363. if (EVP_PKEY_keygen(mac_ctx, &sigkey) <= 0)
  364. {
  365. BIO_puts(bio_err, "Error generating key\n");
  366. ERR_print_errors(bio_err);
  367. goto mac_end;
  368. }
  369. r = 1;
  370. mac_end:
  371. if (mac_ctx)
  372. EVP_PKEY_CTX_free(mac_ctx);
  373. if (r == 0)
  374. goto end;
  375. }
  376. if (hmac_key)
  377. {
  378. sigkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, e,
  379. (unsigned char *)hmac_key, -1);
  380. if (!sigkey)
  381. goto end;
  382. }
  383. if (sigkey)
  384. {
  385. EVP_MD_CTX *mctx = NULL;
  386. EVP_PKEY_CTX *pctx = NULL;
  387. int r;
  388. if (!BIO_get_md_ctx(bmd, &mctx))
  389. {
  390. BIO_printf(bio_err, "Error getting context\n");
  391. ERR_print_errors(bio_err);
  392. goto end;
  393. }
  394. if (do_verify)
  395. r = EVP_DigestVerifyInit(mctx, &pctx, md, e, sigkey);
  396. else
  397. r = EVP_DigestSignInit(mctx, &pctx, md, e, sigkey);
  398. if (!r)
  399. {
  400. BIO_printf(bio_err, "Error setting context\n");
  401. ERR_print_errors(bio_err);
  402. goto end;
  403. }
  404. if (sigopts)
  405. {
  406. char *sigopt;
  407. for (i = 0; i < sk_num(sigopts); i++)
  408. {
  409. sigopt = sk_value(sigopts, i);
  410. if (pkey_ctrl_string(pctx, sigopt) <= 0)
  411. {
  412. BIO_printf(bio_err,
  413. "parameter error \"%s\"\n",
  414. sigopt);
  415. ERR_print_errors(bio_err);
  416. goto end;
  417. }
  418. }
  419. }
  420. }
  421. /* we use md as a filter, reading from 'in' */
  422. else
  423. {
  424. if (md == NULL)
  425. md = EVP_md5();
  426. if (!BIO_set_md(bmd,md))
  427. {
  428. BIO_printf(bio_err, "Error setting digest %s\n", pname);
  429. ERR_print_errors(bio_err);
  430. goto end;
  431. }
  432. }
  433. if(sigfile && sigkey) {
  434. BIO *sigbio;
  435. sigbio = BIO_new_file(sigfile, "rb");
  436. siglen = EVP_PKEY_size(sigkey);
  437. sigbuf = OPENSSL_malloc(siglen);
  438. if(!sigbio) {
  439. BIO_printf(bio_err, "Error opening signature file %s\n",
  440. sigfile);
  441. ERR_print_errors(bio_err);
  442. goto end;
  443. }
  444. siglen = BIO_read(sigbio, sigbuf, siglen);
  445. BIO_free(sigbio);
  446. if(siglen <= 0) {
  447. BIO_printf(bio_err, "Error reading signature file %s\n",
  448. sigfile);
  449. ERR_print_errors(bio_err);
  450. goto end;
  451. }
  452. }
  453. inp=BIO_push(bmd,in);
  454. if (md == NULL)
  455. {
  456. EVP_MD_CTX *tctx;
  457. BIO_get_md_ctx(bmd, &tctx);
  458. md = EVP_MD_CTX_md(tctx);
  459. }
  460. if (argc == 0)
  461. {
  462. BIO_set_fp(in,stdin,BIO_NOCLOSE);
  463. err=do_fp(out, buf,inp,separator, out_bin, sigkey, sigbuf,
  464. siglen,NULL,NULL,"stdin",bmd);
  465. }
  466. else
  467. {
  468. const char *md_name = NULL, *sig_name = NULL;
  469. if(!out_bin)
  470. {
  471. if (sigkey)
  472. {
  473. const EVP_PKEY_ASN1_METHOD *ameth;
  474. ameth = EVP_PKEY_get0_asn1(sigkey);
  475. if (ameth)
  476. EVP_PKEY_asn1_get0_info(NULL, NULL,
  477. NULL, NULL, &sig_name, ameth);
  478. }
  479. md_name = EVP_MD_name(md);
  480. }
  481. err = 0;
  482. for (i=0; i<argc; i++)
  483. {
  484. int r;
  485. if (BIO_read_filename(in,argv[i]) <= 0)
  486. {
  487. perror(argv[i]);
  488. err++;
  489. continue;
  490. }
  491. else
  492. r=do_fp(out,buf,inp,separator,out_bin,sigkey,sigbuf,
  493. siglen,sig_name,md_name, argv[i],bmd);
  494. if(r)
  495. err=r;
  496. (void)BIO_reset(bmd);
  497. }
  498. }
  499. end:
  500. if (buf != NULL)
  501. {
  502. OPENSSL_cleanse(buf,BUFSIZE);
  503. OPENSSL_free(buf);
  504. }
  505. if (in != NULL) BIO_free(in);
  506. if (passin)
  507. OPENSSL_free(passin);
  508. BIO_free_all(out);
  509. EVP_PKEY_free(sigkey);
  510. if (sigopts)
  511. sk_free(sigopts);
  512. if (macopts)
  513. sk_free(macopts);
  514. if(sigbuf) OPENSSL_free(sigbuf);
  515. if (bmd != NULL) BIO_free(bmd);
  516. apps_shutdown();
  517. OPENSSL_EXIT(err);
  518. }
  519. int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
  520. EVP_PKEY *key, unsigned char *sigin, int siglen,
  521. const char *sig_name, const char *md_name,
  522. const char *file,BIO *bmd)
  523. {
  524. size_t len;
  525. int i;
  526. for (;;)
  527. {
  528. i=BIO_read(bp,(char *)buf,BUFSIZE);
  529. if(i < 0)
  530. {
  531. BIO_printf(bio_err, "Read Error in %s\n",file);
  532. ERR_print_errors(bio_err);
  533. return 1;
  534. }
  535. if (i == 0) break;
  536. }
  537. if(sigin)
  538. {
  539. EVP_MD_CTX *ctx;
  540. BIO_get_md_ctx(bp, &ctx);
  541. i = EVP_DigestVerifyFinal(ctx, sigin, (unsigned int)siglen);
  542. if(i > 0)
  543. BIO_printf(out, "Verified OK\n");
  544. else if(i == 0)
  545. {
  546. BIO_printf(out, "Verification Failure\n");
  547. return 1;
  548. }
  549. else
  550. {
  551. BIO_printf(bio_err, "Error Verifying Data\n");
  552. ERR_print_errors(bio_err);
  553. return 1;
  554. }
  555. return 0;
  556. }
  557. if(key)
  558. {
  559. EVP_MD_CTX *ctx;
  560. BIO_get_md_ctx(bp, &ctx);
  561. len = BUFSIZE;
  562. if(!EVP_DigestSignFinal(ctx, buf, &len))
  563. {
  564. BIO_printf(bio_err, "Error Signing Data\n");
  565. ERR_print_errors(bio_err);
  566. return 1;
  567. }
  568. }
  569. else
  570. len=BIO_gets(bp,(char *)buf,BUFSIZE);
  571. if(binout) BIO_write(out, buf, len);
  572. else
  573. {
  574. if (sig_name)
  575. BIO_printf(out, "%s-%s(%s)= ", sig_name, md_name, file);
  576. else if (md_name)
  577. BIO_printf(out, "%s(%s)= ", md_name, file);
  578. else
  579. BIO_printf(out, "(%s)= ", file);
  580. for (i=0; i<(int)len; i++)
  581. {
  582. if (sep && (i != 0))
  583. BIO_printf(out, ":");
  584. BIO_printf(out, "%02x",buf[i]);
  585. }
  586. BIO_printf(out, "\n");
  587. }
  588. return 0;
  589. }