summaryrefslogtreecommitdiffstats
path: root/apps/rsautl.c
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2017-07-05 16:58:48 +0200
committerRich Salz <rsalz@openssl.org>2017-07-17 01:20:45 +0200
commit3ee1eac27a2e3120fbdc60e12db091c082b8de21 (patch)
treec34ee07aa725e2019dbce1f7621702eb2bb5fd69 /apps/rsautl.c
parentDon't use "version" in "OpenSSL Version 1.1.0" etc (diff)
downloadopenssl-3ee1eac27a2e3120fbdc60e12db091c082b8de21.tar.xz
openssl-3ee1eac27a2e3120fbdc60e12db091c082b8de21.zip
Standardize apps use of -rand, etc.
Standardized the -rand flag and added a new one: -rand file... Always reads the specified files -writerand file Always writes to the file on exit For apps that use a config file, the RANDFILE config parameter reads the file at startup (to seed the RNG) and write to it on exit if the -writerand flag isn't used. Ensured that every app that took -rand also took -writerand, and made sure all of that agreed with all the documentation. Fix error reporting in write_file and -rand Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/3862)
Diffstat (limited to 'apps/rsautl.c')
-rw-r--r--apps/rsautl.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/apps/rsautl.c b/apps/rsautl.c
index c8a2650fc8..ca9cb791c7 100644
--- a/apps/rsautl.c
+++ b/apps/rsautl.c
@@ -32,7 +32,8 @@ typedef enum OPTION_choice {
OPT_ENGINE, OPT_IN, OPT_OUT, OPT_ASN1PARSE, OPT_HEXDUMP,
OPT_RAW, OPT_OAEP, OPT_SSL, OPT_PKCS, OPT_X931,
OPT_SIGN, OPT_VERIFY, OPT_REV, OPT_ENCRYPT, OPT_DECRYPT,
- OPT_PUBIN, OPT_CERTIN, OPT_INKEY, OPT_PASSIN, OPT_KEYFORM
+ OPT_PUBIN, OPT_CERTIN, OPT_INKEY, OPT_PASSIN, OPT_KEYFORM,
+ OPT_R_ENUM
} OPTION_CHOICE;
const OPTIONS rsautl_options[] = {
@@ -57,6 +58,7 @@ const OPTIONS rsautl_options[] = {
{"encrypt", OPT_ENCRYPT, '-', "Encrypt with public key"},
{"decrypt", OPT_DECRYPT, '-', "Decrypt with private key"},
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
+ OPT_R_OPTIONS,
# ifndef OPENSSL_NO_ENGINE
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
# endif
@@ -153,6 +155,10 @@ int rsautl_main(int argc, char **argv)
case OPT_PASSIN:
passinarg = opt_arg();
break;
+ case OPT_R_CASES:
+ if (!opt_rand(o))
+ goto end;
+ break;
}
}
argc = opt_num_rest();
@@ -169,9 +175,6 @@ int rsautl_main(int argc, char **argv)
goto end;
}
-/* FIXME: seed PRNG only if needed */
- app_RAND_load_file(NULL, 0);
-
switch (key_type) {
case KEY_PRIVKEY:
pkey = load_key(keyfile, keyformat, 0, passin, e, "Private Key");