summaryrefslogtreecommitdiffstats
path: root/apps/app_rand.c
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2015-04-24 15:26:15 -0400
committerRich Salz <rsalz@openssl.org>2015-04-24 15:26:15 -0400
commit7e1b7485706c2b11091b5fa897fe496a2faa56cc (patch)
treed008e38fda900d081a2496023625184c5c89a5ff /apps/app_rand.c
parent53dd4ddf71ad79a64be934ca19445b1cf560adab (diff)
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest change is that option parsing switch from cascasding 'else if strcmp("-foo")' to a utility routine and somethin akin to getopt. Also, an error in the command line no longer prints the full summary; use -help (or --help :) for that. There have been many other changes and code-cleanup, see bullet list below. Special thanks to Matt for the long and detailed code review. TEMPORARY: For now, comment out CRYPTO_mem_leaks() at end of main Tickets closed: RT3515: Use 3DES in pkcs12 if built with no-rc2 RT1766: s_client -reconnect and -starttls broke RT2932: Catch write errors RT2604: port should be 'unsigned short' RT2983: total_bytes undeclared #ifdef RENEG RT1523: Add -nocert to fix output in x509 app RT3508: Remove unused variable introduced by b09eb24 RT3511: doc fix; req default serial is random RT1325,2973: Add more extensions to c_rehash RT2119,3407: Updated to dgst.pod RT2379: Additional typo fix RT2693: Extra include of string.h RT2880: HFS is case-insensitive filenames RT3246: req command prints version number wrong Other changes; incompatibilities marked with *: Add SCSV support Add -misalign to speed command Make dhparam, dsaparam, ecparam, x509 output C in proper style Make some internal ocsp.c functions void Only display cert usages with -help in verify Use global bio_err, remove "BIO*err" parameter from functions For filenames, - always means stdin (or stdout as appropriate) Add aliases for -des/aes "wrap" ciphers. *Remove support for IISSGC (server gated crypto) *The undocumented OCSP -header flag is now "-header name=value" *Documented the OCSP -header flag Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'apps/app_rand.c')
-rw-r--r--apps/app_rand.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/apps/app_rand.c b/apps/app_rand.c
index 595fc7821c..906144bb6d 100644
--- a/apps/app_rand.c
+++ b/apps/app_rand.c
@@ -1,4 +1,3 @@
-/* apps/app_rand.c */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -109,25 +108,23 @@
*
*/
-#define NON_MAIN
#include "apps.h"
-#undef NON_MAIN
#include <openssl/bio.h>
#include <openssl/rand.h>
static int seeded = 0;
static int egdsocket = 0;
-int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn)
+int app_RAND_load_file(const char *file, int dont_warn)
{
int consider_randfile = (file == NULL);
char buffer[200];
#ifdef OPENSSL_SYS_WINDOWS
- BIO_printf(bio_e, "Loading 'screen' into random state -");
- BIO_flush(bio_e);
+ BIO_printf(bio_err, "Loading 'screen' into random state -");
+ BIO_flush(bio_err);
RAND_screen();
- BIO_printf(bio_e, " done\n");
+ BIO_printf(bio_err, " done\n");
#endif
if (file == NULL)
@@ -143,15 +140,15 @@ int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn)
if (file == NULL || !RAND_load_file(file, -1)) {
if (RAND_status() == 0) {
if (!dont_warn) {
- BIO_printf(bio_e, "unable to load 'random state'\n");
- BIO_printf(bio_e,
+ BIO_printf(bio_err, "unable to load 'random state'\n");
+ BIO_printf(bio_err,
"This means that the random number generator has not been seeded\n");
- BIO_printf(bio_e, "with much random data.\n");
+ BIO_printf(bio_err, "with much random data.\n");
if (consider_randfile) { /* explanation does not apply when a
* file is explicitly named */
- BIO_printf(bio_e,
+ BIO_printf(bio_err,
"Consider setting the RANDFILE environment variable to point at a file that\n");
- BIO_printf(bio_e,
+ BIO_printf(bio_err,
"'random' data can be kept in (the file will be overwritten).\n");
}
}
@@ -193,7 +190,7 @@ long app_RAND_load_files(char *name)
return (tot);
}
-int app_RAND_write_file(const char *file, BIO *bio_e)
+int app_RAND_write_file(const char *file)
{
char buffer[200];
@@ -208,7 +205,7 @@ int app_RAND_write_file(const char *file, BIO *bio_e)
if (file == NULL)
file = RAND_file_name(buffer, sizeof buffer);
if (file == NULL || !RAND_write_file(file)) {
- BIO_printf(bio_e, "unable to write 'random state'\n");
+ BIO_printf(bio_err, "unable to write 'random state'\n");
return 0;
}
return 1;