X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=apps%2Frand.c;h=c3b26c466d9e91847ade09a20c574531adc937a8;hb=761f3b403b45d3260b5c7cdfce45a57691c27c60;hp=68622165eb890b551e5c5e13081ad3754f0f3477;hpb=a661b6535744f41b428bb35a7fc3e5747900e9ef;p=oweals%2Fopenssl.git diff --git a/apps/rand.c b/apps/rand.c index 68622165eb..c3b26c466d 100644 --- a/apps/rand.c +++ b/apps/rand.c @@ -76,7 +76,9 @@ int MAIN(int, char **); int MAIN(int argc, char **argv) { +#ifndef OPENSSL_NO_ENGINE ENGINE *e = NULL; +#endif int i, r, ret = 1; int badopt; char *outfile = NULL; @@ -84,7 +86,9 @@ int MAIN(int argc, char **argv) int base64 = 0; BIO *out = NULL; int num = -1; +#ifndef OPENSSL_NO_ENGINE char *engine=NULL; +#endif apps_startup(); @@ -92,6 +96,9 @@ int MAIN(int argc, char **argv) if ((bio_err = BIO_new(BIO_s_file())) != NULL) BIO_set_fp(bio_err, stderr, BIO_NOCLOSE|BIO_FP_TEXT); + if (!load_config(bio_err, NULL)) + goto err; + badopt = 0; i = 0; while (!badopt && argv[++i] != NULL) @@ -103,6 +110,7 @@ int MAIN(int argc, char **argv) else badopt = 1; } +#ifndef OPENSSL_NO_ENGINE else if (strcmp(argv[i], "-engine") == 0) { if ((argv[i+1] != NULL) && (engine == NULL)) @@ -110,6 +118,7 @@ int MAIN(int argc, char **argv) else badopt = 1; } +#endif else if (strcmp(argv[i], "-rand") == 0) { if ((argv[i+1] != NULL) && (inrand == NULL)) @@ -147,13 +156,17 @@ int MAIN(int argc, char **argv) BIO_printf(bio_err, "Usage: rand [options] num\n"); BIO_printf(bio_err, "where options are\n"); BIO_printf(bio_err, "-out file - write to file\n"); +#ifndef OPENSSL_NO_ENGINE BIO_printf(bio_err, "-engine e - use engine e, possibly a hardware device.\n"); +#endif BIO_printf(bio_err, "-rand file%cfile%c... - seed PRNG from files\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); BIO_printf(bio_err, "-base64 - encode output\n"); goto err; } +#ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0); +#endif app_RAND_load_file(NULL, bio_err, (inrand != NULL)); if (inrand != NULL) @@ -192,7 +205,7 @@ int MAIN(int argc, char **argv) int chunk; chunk = num; - if (chunk > sizeof buf) + if (chunk > (int)sizeof(buf)) chunk = sizeof buf; r = RAND_bytes(buf, chunk); if (r <= 0) @@ -200,7 +213,7 @@ int MAIN(int argc, char **argv) BIO_write(out, buf, chunk); num -= chunk; } - BIO_flush(out); + (void)BIO_flush(out); app_RAND_write_file(NULL, bio_err); ret = 0; @@ -210,5 +223,5 @@ err: if (out) BIO_free_all(out); apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); }