提交 3ee1eac2 编写于 作者: R Rich Salz

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: NPaul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/3862)
上级 e90fc053
...@@ -10,108 +10,82 @@ ...@@ -10,108 +10,82 @@
#include "apps.h" #include "apps.h"
#include <openssl/bio.h> #include <openssl/bio.h>
#include <openssl/rand.h> #include <openssl/rand.h>
#include <openssl/conf.h>
static int seeded = 0; static const char *save_rand_file;
static int egdsocket = 0;
int app_RAND_load_file(const char *file, int dont_warn) void app_RAND_load_conf(CONF *c, const char *section)
{ {
int consider_randfile = (file == NULL); const char *randfile = NCONF_get_string(c, section, "RANDFILE");
char buffer[200];
if (file == NULL) { if (randfile == NULL) {
file = RAND_file_name(buffer, sizeof buffer); ERR_clear_error();
#ifndef OPENSSL_NO_EGD return;
} else if (RAND_egd(file) > 0) {
/*
* we try if the given filename is an EGD socket. if it is, we don't
* write anything back to the file.
*/
egdsocket = 1;
return 1;
#endif
} }
if (RAND_load_file(randfile, -1) < 0) {
if (file == NULL || !RAND_load_file(file, -1)) { BIO_printf(bio_err, "Can't load %s into RNG\n", randfile);
if (RAND_status() == 0) { ERR_print_errors(bio_err);
if (!dont_warn) { return;
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_err, "with much random data.\n");
if (consider_randfile) { /* explanation does not apply when a
* file is explicitly named */
BIO_printf(bio_err,
"Consider setting the RANDFILE environment variable to point at a file that\n");
BIO_printf(bio_err,
"'random' data can be kept in (the file will be overwritten).\n");
}
}
return 0;
}
} }
seeded = 1; if (save_rand_file == NULL)
return 1; save_rand_file = randfile;
} }
long app_RAND_load_files(char *name) static int loadfiles(char *name)
{ {
char *p, *n; char *p, *n;
int last; int last, ret = 1;
long tot = 0;
#ifndef OPENSSL_NO_EGD
int egd;
#endif
for (;;) { for ( ; ; ) {
last = 0; last = 0;
for (p = name; ((*p != '\0') && (*p != LIST_SEPARATOR_CHAR)); p++) ; for (p = name; *p != '\0' && *p != LIST_SEPARATOR_CHAR; p++)
continue;
if (*p == '\0') if (*p == '\0')
last = 1; last = 1;
*p = '\0'; *p = '\0';
if (RAND_load_file(name, -1) < 0) {
BIO_printf(bio_err, "Can't load %s into RNG\n", name);
ERR_print_errors(bio_err);
ret = 0;
}
n = name; n = name;
name = p + 1;
if (*n == '\0')
break;
#ifndef OPENSSL_NO_EGD
egd = RAND_egd(n);
if (egd > 0)
tot += egd;
else
#endif
tot += RAND_load_file(n, -1);
if (last) if (last)
break; break;
name = p + 1;
if (*name == '\0')
break;
} }
if (tot > 512) return ret;
app_RAND_allow_write_file();
return (tot);
} }
int app_RAND_write_file(const char *file) void app_RAND_write(void)
{ {
char buffer[200]; if (save_rand_file == NULL)
return;
if (egdsocket || !seeded) { if (RAND_write_file(save_rand_file) == -1) {
/* BIO_printf(bio_err, "Cannot write random bytes:\n");
* If we didn't manage to read the seed file, don't write a ERR_print_errors(bio_err);
* file out -- it would suppress a crucial warning the next
* time we want to use it.
*/
return 0;
} }
if (file == NULL)
file = RAND_file_name(buffer, sizeof buffer);
if (file == NULL || !RAND_write_file(file)) {
BIO_printf(bio_err, "unable to write 'random state'\n");
return 0;
}
return 1;
} }
void app_RAND_allow_write_file(void)
/*
* See comments in opt_verify for explanation of this.
*/
enum r_range { OPT_R_ENUM };
int opt_rand(int opt)
{ {
seeded = 1; switch ((enum r_range)opt) {
case OPT_R__FIRST:
case OPT_R__LAST:
break;
case OPT_R_RAND:
return loadfiles(opt_arg());
break;
case OPT_R_WRITERAND:
save_rand_file = opt_arg();
break;
}
return 1;
} }
...@@ -40,16 +40,8 @@ ...@@ -40,16 +40,8 @@
*/ */
#define _UC(c) ((unsigned char)(c)) #define _UC(c) ((unsigned char)(c))
int app_RAND_load_file(const char *file, int dont_warn); void app_RAND_load_conf(CONF *c, const char *section);
int app_RAND_write_file(const char *file); void app_RAND_write(void);
/*
* When `file' is NULL, use defaults. `bio_e' is for error messages.
*/
void app_RAND_allow_write_file(void);
long app_RAND_load_files(char *file); /* `file' is a list of files to read,
* separated by LIST_SEPARATOR_CHAR
* (see e_os.h). The string is
* destroyed! */
extern char *default_config_file; extern char *default_config_file;
extern BIO *bio_in; extern BIO *bio_in;
...@@ -177,7 +169,7 @@ int set_cert_times(X509 *x, const char *startdate, const char *enddate, ...@@ -177,7 +169,7 @@ int set_cert_times(X509 *x, const char *startdate, const char *enddate,
case OPT_V_ALLOW_PROXY_CERTS case OPT_V_ALLOW_PROXY_CERTS
/* /*
* Common "extended"? options. * Common "extended validation" options.
*/ */
# define OPT_X_ENUM \ # define OPT_X_ENUM \
OPT_X__FIRST=1000, \ OPT_X__FIRST=1000, \
...@@ -299,6 +291,20 @@ int set_cert_times(X509 *x, const char *startdate, const char *enddate, ...@@ -299,6 +291,20 @@ int set_cert_times(X509 *x, const char *startdate, const char *enddate,
(o == OPT_S_NOSSL3 || o == OPT_S_NOTLS1 || o == OPT_S_NOTLS1_1 \ (o == OPT_S_NOSSL3 || o == OPT_S_NOTLS1 || o == OPT_S_NOTLS1_1 \
|| o == OPT_S_NOTLS1_2 || o == OPT_S_NOTLS1_3) || o == OPT_S_NOTLS1_2 || o == OPT_S_NOTLS1_3)
/*
* Random state options.
*/
# define OPT_R_ENUM \
OPT_R__FIRST=1500, OPT_R_RAND, OPT_R_WRITERAND, OPT_R__LAST
# define OPT_R_OPTIONS \
{"rand", OPT_R_RAND, 's', "Load the file(s) into the random number generator"}, \
{"writerand", OPT_R_WRITERAND, '>', "Write random data to the specified file"}
# define OPT_R_CASES \
OPT_R__FIRST: case OPT_R__LAST: break; \
case OPT_R_RAND: case OPT_R_WRITERAND
/* /*
* Option parsing. * Option parsing.
*/ */
...@@ -373,6 +379,7 @@ char *opt_reset(void); ...@@ -373,6 +379,7 @@ char *opt_reset(void);
char **opt_rest(void); char **opt_rest(void);
int opt_num_rest(void); int opt_num_rest(void);
int opt_verify(int i, X509_VERIFY_PARAM *vpm); int opt_verify(int i, X509_VERIFY_PARAM *vpm);
int opt_rand(int i);
void opt_help(const OPTIONS * list); void opt_help(const OPTIONS * list);
int opt_format_error(const char *s, unsigned long flags); int opt_format_error(const char *s, unsigned long flags);
......
...@@ -153,6 +153,7 @@ typedef enum OPTION_choice { ...@@ -153,6 +153,7 @@ typedef enum OPTION_choice {
OPT_GENCRL, OPT_MSIE_HACK, OPT_CRLDAYS, OPT_CRLHOURS, OPT_CRLSEC, OPT_GENCRL, OPT_MSIE_HACK, OPT_CRLDAYS, OPT_CRLHOURS, OPT_CRLSEC,
OPT_INFILES, OPT_SS_CERT, OPT_SPKAC, OPT_REVOKE, OPT_VALID, OPT_INFILES, OPT_SS_CERT, OPT_SPKAC, OPT_REVOKE, OPT_VALID,
OPT_EXTENSIONS, OPT_EXTFILE, OPT_STATUS, OPT_UPDATEDB, OPT_CRLEXTS, OPT_EXTENSIONS, OPT_EXTFILE, OPT_STATUS, OPT_UPDATEDB, OPT_CRLEXTS,
OPT_R_ENUM,
/* Do not change the order here; see related case statements below */ /* Do not change the order here; see related case statements below */
OPT_CRL_REASON, OPT_CRL_HOLD, OPT_CRL_COMPROMISE, OPT_CRL_CA_COMPROMISE OPT_CRL_REASON, OPT_CRL_HOLD, OPT_CRL_COMPROMISE, OPT_CRL_CA_COMPROMISE
} OPTION_CHOICE; } OPTION_CHOICE;
...@@ -217,6 +218,7 @@ const OPTIONS ca_options[] = { ...@@ -217,6 +218,7 @@ const OPTIONS ca_options[] = {
"sets compromise time to val and the revocation reason to keyCompromise"}, "sets compromise time to val and the revocation reason to keyCompromise"},
{"crl_CA_compromise", OPT_CRL_CA_COMPROMISE, 's', {"crl_CA_compromise", OPT_CRL_CA_COMPROMISE, 's',
"sets compromise time to val and the revocation reason to CACompromise"}, "sets compromise time to val and the revocation reason to CACompromise"},
OPT_R_OPTIONS,
#ifndef OPENSSL_NO_ENGINE #ifndef OPENSSL_NO_ENGINE
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
#endif #endif
...@@ -247,7 +249,7 @@ int ca_main(int argc, char **argv) ...@@ -247,7 +249,7 @@ int ca_main(int argc, char **argv)
char *outdir = NULL, *outfile = NULL, *rev_arg = NULL, *ser_status = NULL; char *outdir = NULL, *outfile = NULL, *rev_arg = NULL, *ser_status = NULL;
const char *serialfile = NULL, *subj = NULL; const char *serialfile = NULL, *subj = NULL;
char *prog, *startdate = NULL, *enddate = NULL; char *prog, *startdate = NULL, *enddate = NULL;
char *dbfile = NULL, *f, *randfile = NULL; char *dbfile = NULL, *f;
char new_cert[CERT_MAX + 1]; char new_cert[CERT_MAX + 1];
char tmp[10 + 1] = "\0"; char tmp[10 + 1] = "\0";
char *const *pp; char *const *pp;
...@@ -332,6 +334,10 @@ opthelp: ...@@ -332,6 +334,10 @@ opthelp:
case OPT_PASSIN: case OPT_PASSIN:
passinarg = opt_arg(); passinarg = opt_arg();
break; break;
case OPT_R_CASES:
if (!opt_rand(o))
goto end;
break;
case OPT_KEY: case OPT_KEY:
key = opt_arg(); key = opt_arg();
break; break;
...@@ -465,10 +471,7 @@ end_of_options: ...@@ -465,10 +471,7 @@ end_of_options:
} }
} }
randfile = NCONF_get_string(conf, BASE_SECTION, "RANDFILE"); app_RAND_load_conf(conf, BASE_SECTION);
if (randfile == NULL)
ERR_clear_error();
app_RAND_load_file(randfile, 0);
f = NCONF_get_string(conf, section, STRING_MASK); f = NCONF_get_string(conf, section, STRING_MASK);
if (f == NULL) if (f == NULL)
...@@ -1220,7 +1223,6 @@ end_of_options: ...@@ -1220,7 +1223,6 @@ end_of_options:
if (ret) if (ret)
ERR_print_errors(bio_err); ERR_print_errors(bio_err);
app_RAND_write_file(randfile);
if (free_key) if (free_key)
OPENSSL_free(key); OPENSSL_free(key);
BN_free(serial); BN_free(serial);
......
...@@ -76,10 +76,11 @@ typedef enum OPTION_choice { ...@@ -76,10 +76,11 @@ typedef enum OPTION_choice {
OPT_RR_ALL, OPT_RR_FIRST, OPT_RCTFORM, OPT_CERTFILE, OPT_CAFILE, OPT_RR_ALL, OPT_RR_FIRST, OPT_RCTFORM, OPT_CERTFILE, OPT_CAFILE,
OPT_CAPATH, OPT_NOCAPATH, OPT_NOCAFILE,OPT_CONTENT, OPT_PRINT, OPT_CAPATH, OPT_NOCAPATH, OPT_NOCAFILE,OPT_CONTENT, OPT_PRINT,
OPT_SECRETKEY, OPT_SECRETKEYID, OPT_PWRI_PASSWORD, OPT_ECONTENT_TYPE, OPT_SECRETKEY, OPT_SECRETKEYID, OPT_PWRI_PASSWORD, OPT_ECONTENT_TYPE,
OPT_RAND, OPT_PASSIN, OPT_TO, OPT_FROM, OPT_SUBJECT, OPT_SIGNER, OPT_RECIP, OPT_PASSIN, OPT_TO, OPT_FROM, OPT_SUBJECT, OPT_SIGNER, OPT_RECIP,
OPT_CERTSOUT, OPT_MD, OPT_INKEY, OPT_KEYFORM, OPT_KEYOPT, OPT_RR_FROM, OPT_CERTSOUT, OPT_MD, OPT_INKEY, OPT_KEYFORM, OPT_KEYOPT, OPT_RR_FROM,
OPT_RR_TO, OPT_AES128_WRAP, OPT_AES192_WRAP, OPT_AES256_WRAP, OPT_RR_TO, OPT_AES128_WRAP, OPT_AES192_WRAP, OPT_AES256_WRAP,
OPT_3DES_WRAP, OPT_ENGINE, OPT_3DES_WRAP, OPT_ENGINE,
OPT_R_ENUM,
OPT_V_ENUM, OPT_V_ENUM,
OPT_CIPHER OPT_CIPHER
} OPTION_CHOICE; } OPTION_CHOICE;
...@@ -152,8 +153,6 @@ const OPTIONS cms_options[] = { ...@@ -152,8 +153,6 @@ const OPTIONS cms_options[] = {
{"secretkeyid", OPT_SECRETKEYID, 's'}, {"secretkeyid", OPT_SECRETKEYID, 's'},
{"pwri_password", OPT_PWRI_PASSWORD, 's'}, {"pwri_password", OPT_PWRI_PASSWORD, 's'},
{"econtent_type", OPT_ECONTENT_TYPE, 's'}, {"econtent_type", OPT_ECONTENT_TYPE, 's'},
{"rand", OPT_RAND, 's',
"Load the file(s) into the random number generator"},
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"}, {"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
{"to", OPT_TO, 's', "To address"}, {"to", OPT_TO, 's', "To address"},
{"from", OPT_FROM, 's', "From address"}, {"from", OPT_FROM, 's', "From address"},
...@@ -169,6 +168,7 @@ const OPTIONS cms_options[] = { ...@@ -169,6 +168,7 @@ const OPTIONS cms_options[] = {
{"receipt_request_from", OPT_RR_FROM, 's'}, {"receipt_request_from", OPT_RR_FROM, 's'},
{"receipt_request_to", OPT_RR_TO, 's'}, {"receipt_request_to", OPT_RR_TO, 's'},
{"", OPT_CIPHER, '-', "Any supported cipher"}, {"", OPT_CIPHER, '-', "Any supported cipher"},
OPT_R_OPTIONS,
OPT_V_OPTIONS, OPT_V_OPTIONS,
{"aes128-wrap", OPT_AES128_WRAP, '-', "Use AES128 to wrap key"}, {"aes128-wrap", OPT_AES128_WRAP, '-', "Use AES128 to wrap key"},
{"aes192-wrap", OPT_AES192_WRAP, '-', "Use AES192 to wrap key"}, {"aes192-wrap", OPT_AES192_WRAP, '-', "Use AES192 to wrap key"},
...@@ -202,16 +202,13 @@ int cms_main(int argc, char **argv) ...@@ -202,16 +202,13 @@ int cms_main(int argc, char **argv)
const char *CAfile = NULL, *CApath = NULL; const char *CAfile = NULL, *CApath = NULL;
char *certsoutfile = NULL; char *certsoutfile = NULL;
int noCAfile = 0, noCApath = 0; int noCAfile = 0, noCApath = 0;
char *infile = NULL, *outfile = NULL, *rctfile = NULL, *inrand = NULL; char *infile = NULL, *outfile = NULL, *rctfile = NULL;
char *passinarg = NULL, *passin = NULL, *signerfile = NULL, *recipfile = char *passinarg = NULL, *passin = NULL, *signerfile = NULL, *recipfile = NULL;
NULL;
char *to = NULL, *from = NULL, *subject = NULL, *prog; char *to = NULL, *from = NULL, *subject = NULL, *prog;
cms_key_param *key_first = NULL, *key_param = NULL; cms_key_param *key_first = NULL, *key_param = NULL;
int flags = CMS_DETACHED, noout = 0, print = 0, keyidx = -1, vpmtouched = int flags = CMS_DETACHED, noout = 0, print = 0, keyidx = -1, vpmtouched = 0;
0;
int informat = FORMAT_SMIME, outformat = FORMAT_SMIME; int informat = FORMAT_SMIME, outformat = FORMAT_SMIME;
int need_rand = 0, operation = 0, ret = 1, rr_print = 0, rr_allorfirst = int operation = 0, ret = 1, rr_print = 0, rr_allorfirst = -1;
-1;
int verify_retcode = 0, rctformat = FORMAT_SMIME, keyform = FORMAT_PEM; int verify_retcode = 0, rctformat = FORMAT_SMIME, keyform = FORMAT_PEM;
size_t secret_keylen = 0, secret_keyidlen = 0; size_t secret_keylen = 0, secret_keyidlen = 0;
unsigned char *pwri_pass = NULL, *pwri_tmp = NULL; unsigned char *pwri_pass = NULL, *pwri_tmp = NULL;
...@@ -449,10 +446,6 @@ int cms_main(int argc, char **argv) ...@@ -449,10 +446,6 @@ int cms_main(int argc, char **argv)
goto opthelp; goto opthelp;
} }
break; break;
case OPT_RAND:
inrand = opt_arg();
need_rand = 1;
break;
case OPT_ENGINE: case OPT_ENGINE:
e = setup_engine(opt_arg(), 0); e = setup_engine(opt_arg(), 0);
break; break;
...@@ -568,6 +561,10 @@ int cms_main(int argc, char **argv) ...@@ -568,6 +561,10 @@ int cms_main(int argc, char **argv)
goto end; goto end;
vpmtouched++; vpmtouched++;
break; break;
case OPT_R_CASES:
if (!opt_rand(o))
goto end;
break;
case OPT_3DES_WRAP: case OPT_3DES_WRAP:
# ifndef OPENSSL_NO_DES # ifndef OPENSSL_NO_DES
wrap_cipher = EVP_des_ede3_wrap(); wrap_cipher = EVP_des_ede3_wrap();
...@@ -624,7 +621,6 @@ int cms_main(int argc, char **argv) ...@@ -624,7 +621,6 @@ int cms_main(int argc, char **argv)
} }
signerfile = NULL; signerfile = NULL;
keyfile = NULL; keyfile = NULL;
need_rand = 1;
} else if (operation == SMIME_DECRYPT) { } else if (operation == SMIME_DECRYPT) {
if (recipfile == NULL && keyfile == NULL if (recipfile == NULL && keyfile == NULL
&& secret_key == NULL && pwri_pass == NULL) { && secret_key == NULL && pwri_pass == NULL) {
...@@ -638,7 +634,6 @@ int cms_main(int argc, char **argv) ...@@ -638,7 +634,6 @@ int cms_main(int argc, char **argv)
BIO_printf(bio_err, "No recipient(s) certificate(s) specified\n"); BIO_printf(bio_err, "No recipient(s) certificate(s) specified\n");
goto opthelp; goto opthelp;
} }
need_rand = 1;
} else if (!operation) { } else if (!operation) {
goto opthelp; goto opthelp;
} }
...@@ -648,13 +643,6 @@ int cms_main(int argc, char **argv) ...@@ -648,13 +643,6 @@ int cms_main(int argc, char **argv)
goto end; goto end;
} }
if (need_rand) {
app_RAND_load_file(NULL, (inrand != NULL));
if (inrand != NULL)
BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
app_RAND_load_files(inrand));
}
ret = 2; ret = 2;
if (!(operation & SMIME_SIGNERS)) if (!(operation & SMIME_SIGNERS))
...@@ -1083,8 +1071,6 @@ int cms_main(int argc, char **argv) ...@@ -1083,8 +1071,6 @@ int cms_main(int argc, char **argv)
end: end:
if (ret) if (ret)
ERR_print_errors(bio_err); ERR_print_errors(bio_err);
if (need_rand)
app_RAND_write_file(NULL);
sk_X509_pop_free(encerts, X509_free); sk_X509_pop_free(encerts, X509_free);
sk_X509_pop_free(other, X509_free); sk_X509_pop_free(other, X509_free);
X509_VERIFY_PARAM_free(vpm); X509_VERIFY_PARAM_free(vpm);
......
...@@ -29,11 +29,12 @@ int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout, ...@@ -29,11 +29,12 @@ int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
typedef enum OPTION_choice { typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
OPT_C, OPT_R, OPT_RAND, OPT_OUT, OPT_SIGN, OPT_PASSIN, OPT_VERIFY, OPT_C, OPT_R, OPT_OUT, OPT_SIGN, OPT_PASSIN, OPT_VERIFY,
OPT_PRVERIFY, OPT_SIGNATURE, OPT_KEYFORM, OPT_ENGINE, OPT_ENGINE_IMPL, OPT_PRVERIFY, OPT_SIGNATURE, OPT_KEYFORM, OPT_ENGINE, OPT_ENGINE_IMPL,
OPT_HEX, OPT_BINARY, OPT_DEBUG, OPT_FIPS_FINGERPRINT, OPT_HEX, OPT_BINARY, OPT_DEBUG, OPT_FIPS_FINGERPRINT,
OPT_HMAC, OPT_MAC, OPT_SIGOPT, OPT_MACOPT, OPT_HMAC, OPT_MAC, OPT_SIGOPT, OPT_MACOPT,
OPT_DIGEST OPT_DIGEST,
OPT_R_ENUM,
} OPTION_CHOICE; } OPTION_CHOICE;
const OPTIONS dgst_options[] = { const OPTIONS dgst_options[] = {
...@@ -43,8 +44,6 @@ const OPTIONS dgst_options[] = { ...@@ -43,8 +44,6 @@ const OPTIONS dgst_options[] = {
{"help", OPT_HELP, '-', "Display this summary"}, {"help", OPT_HELP, '-', "Display this summary"},
{"c", OPT_C, '-', "Print the digest with separating colons"}, {"c", OPT_C, '-', "Print the digest with separating colons"},
{"r", OPT_R, '-', "Print the digest in coreutils format"}, {"r", OPT_R, '-', "Print the digest in coreutils format"},
{"rand", OPT_RAND, 's',
"Use file(s) containing random data to seed RNG or an EGD sock"},
{"out", OPT_OUT, '>', "Output to filename rather than stdout"}, {"out", OPT_OUT, '>', "Output to filename rather than stdout"},
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"}, {"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
{"sign", OPT_SIGN, 's', "Sign digest using private key"}, {"sign", OPT_SIGN, 's', "Sign digest using private key"},
...@@ -65,6 +64,7 @@ const OPTIONS dgst_options[] = { ...@@ -65,6 +64,7 @@ const OPTIONS dgst_options[] = {
{"sigopt", OPT_SIGOPT, 's', "Signature parameter in n:v form"}, {"sigopt", OPT_SIGOPT, 's', "Signature parameter in n:v form"},
{"macopt", OPT_MACOPT, 's', "MAC algorithm parameters in n:v form or key"}, {"macopt", OPT_MACOPT, 's', "MAC algorithm parameters in n:v form or key"},
{"", OPT_DIGEST, '-', "Any supported digest"}, {"", OPT_DIGEST, '-', "Any supported digest"},
OPT_R_OPTIONS,
#ifndef OPENSSL_NO_ENGINE #ifndef OPENSSL_NO_ENGINE
{"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"}, {"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
{"engine_impl", OPT_ENGINE_IMPL, '-', {"engine_impl", OPT_ENGINE_IMPL, '-',
...@@ -84,7 +84,7 @@ int dgst_main(int argc, char **argv) ...@@ -84,7 +84,7 @@ int dgst_main(int argc, char **argv)
char *passinarg = NULL, *passin = NULL; char *passinarg = NULL, *passin = NULL;
const EVP_MD *md = NULL, *m; const EVP_MD *md = NULL, *m;
const char *outfile = NULL, *keyfile = NULL, *prog = NULL; const char *outfile = NULL, *keyfile = NULL, *prog = NULL;
const char *sigfile = NULL, *randfile = NULL; const char *sigfile = NULL;
OPTION_CHOICE o; OPTION_CHOICE o;
int separator = 0, debug = 0, keyform = FORMAT_PEM, siglen = 0; int separator = 0, debug = 0, keyform = FORMAT_PEM, siglen = 0;
int i, ret = 1, out_bin = -1, want_pub = 0, do_verify = 0; int i, ret = 1, out_bin = -1, want_pub = 0, do_verify = 0;
...@@ -113,8 +113,9 @@ int dgst_main(int argc, char **argv) ...@@ -113,8 +113,9 @@ int dgst_main(int argc, char **argv)
case OPT_R: case OPT_R:
separator = 2; separator = 2;
break; break;
case OPT_RAND: case OPT_R_CASES:
randfile = opt_arg(); if (!opt_rand(o))
goto end;
break; break;
case OPT_OUT: case OPT_OUT:
outfile = opt_arg(); outfile = opt_arg();
...@@ -223,9 +224,6 @@ int dgst_main(int argc, char **argv) ...@@ -223,9 +224,6 @@ int dgst_main(int argc, char **argv)
out_bin = 0; out_bin = 0;
} }
if (randfile != NULL)
app_RAND_load_file(randfile, 0);
out = bio_open_default(outfile, 'w', out_bin ? FORMAT_BINARY : FORMAT_TEXT); out = bio_open_default(outfile, 'w', out_bin ? FORMAT_BINARY : FORMAT_TEXT);
if (out == NULL) if (out == NULL)
goto end; goto end;
......
...@@ -36,7 +36,8 @@ typedef enum OPTION_choice { ...@@ -36,7 +36,8 @@ typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT,
OPT_ENGINE, OPT_CHECK, OPT_TEXT, OPT_NOOUT, OPT_ENGINE, OPT_CHECK, OPT_TEXT, OPT_NOOUT,
OPT_RAND, OPT_DSAPARAM, OPT_C, OPT_2, OPT_5 OPT_DSAPARAM, OPT_C, OPT_2, OPT_5,
OPT_R_ENUM
} OPTION_CHOICE; } OPTION_CHOICE;
const OPTIONS dhparam_options[] = { const OPTIONS dhparam_options[] = {
...@@ -50,8 +51,7 @@ const OPTIONS dhparam_options[] = { ...@@ -50,8 +51,7 @@ const OPTIONS dhparam_options[] = {
{"check", OPT_CHECK, '-', "Check the DH parameters"}, {"check", OPT_CHECK, '-', "Check the DH parameters"},
{"text", OPT_TEXT, '-', "Print a text form of the DH parameters"}, {"text", OPT_TEXT, '-', "Print a text form of the DH parameters"},
{"noout", OPT_NOOUT, '-', "Don't output any DH parameters"}, {"noout", OPT_NOOUT, '-', "Don't output any DH parameters"},
{"rand", OPT_RAND, 's', OPT_R_OPTIONS,
"Load the file(s) into the random number generator"},
{"C", OPT_C, '-', "Print C code"}, {"C", OPT_C, '-', "Print C code"},
{"2", OPT_2, '-', "Generate parameters using 2 as the generator value"}, {"2", OPT_2, '-', "Generate parameters using 2 as the generator value"},
{"5", OPT_5, '-', "Generate parameters using 5 as the generator value"}, {"5", OPT_5, '-', "Generate parameters using 5 as the generator value"},
...@@ -69,7 +69,7 @@ int dhparam_main(int argc, char **argv) ...@@ -69,7 +69,7 @@ int dhparam_main(int argc, char **argv)
{ {
BIO *in = NULL, *out = NULL; BIO *in = NULL, *out = NULL;
DH *dh = NULL; DH *dh = NULL;
char *infile = NULL, *outfile = NULL, *prog, *inrand = NULL; char *infile = NULL, *outfile = NULL, *prog;
ENGINE *e = NULL; ENGINE *e = NULL;
#ifndef OPENSSL_NO_DSA #ifndef OPENSSL_NO_DSA
int dsaparam = 0; int dsaparam = 0;
...@@ -130,8 +130,9 @@ int dhparam_main(int argc, char **argv) ...@@ -130,8 +130,9 @@ int dhparam_main(int argc, char **argv)
case OPT_NOOUT: case OPT_NOOUT:
noout = 1; noout = 1;
break; break;
case OPT_RAND: case OPT_R_CASES:
inrand = opt_arg(); if (!opt_rand(o))
goto end;
break; break;
} }
} }
...@@ -165,13 +166,6 @@ int dhparam_main(int argc, char **argv) ...@@ -165,13 +166,6 @@ int dhparam_main(int argc, char **argv)
} }
BN_GENCB_set(cb, dh_cb, bio_err); BN_GENCB_set(cb, dh_cb, bio_err);
if (!app_RAND_load_file(NULL, 1) && inrand == NULL) {
BIO_printf(bio_err,
"warning, not much extra random data, consider using the -rand option\n");
}
if (inrand != NULL)
BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
app_RAND_load_files(inrand));
# ifndef OPENSSL_NO_DSA # ifndef OPENSSL_NO_DSA
if (dsaparam) { if (dsaparam) {
...@@ -211,7 +205,6 @@ int dhparam_main(int argc, char **argv) ...@@ -211,7 +205,6 @@ int dhparam_main(int argc, char **argv)
} }
BN_GENCB_free(cb); BN_GENCB_free(cb);
app_RAND_write_file(NULL);
} else { } else {
in = bio_open_default(infile, 'r', informat); in = bio_open_default(infile, 'r', informat);
......
...@@ -29,7 +29,7 @@ static int dsa_cb(int p, int n, BN_GENCB *cb); ...@@ -29,7 +29,7 @@ static int dsa_cb(int p, int n, BN_GENCB *cb);
typedef enum OPTION_choice { typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_TEXT, OPT_C, OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_TEXT, OPT_C,
OPT_NOOUT, OPT_GENKEY, OPT_RAND, OPT_ENGINE OPT_NOOUT, OPT_GENKEY, OPT_ENGINE, OPT_R_ENUM
} OPTION_CHOICE; } OPTION_CHOICE;
const OPTIONS dsaparam_options[] = { const OPTIONS dsaparam_options[] = {
...@@ -42,7 +42,7 @@ const OPTIONS dsaparam_options[] = { ...@@ -42,7 +42,7 @@ const OPTIONS dsaparam_options[] = {
{"C", OPT_C, '-', "Output C code"}, {"C", OPT_C, '-', "Output C code"},
{"noout", OPT_NOOUT, '-', "No output"}, {"noout", OPT_NOOUT, '-', "No output"},
{"genkey", OPT_GENKEY, '-', "Generate a DSA key"}, {"genkey", OPT_GENKEY, '-', "Generate a DSA key"},
{"rand", OPT_RAND, 's', "Files to use for random number input"}, OPT_R_OPTIONS,
# ifndef OPENSSL_NO_ENGINE # ifndef OPENSSL_NO_ENGINE
{"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"}, {"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
# endif # endif
...@@ -55,10 +55,10 @@ int dsaparam_main(int argc, char **argv) ...@@ -55,10 +55,10 @@ int dsaparam_main(int argc, char **argv)
DSA *dsa = NULL; DSA *dsa = NULL;
BIO *in = NULL, *out = NULL; BIO *in = NULL, *out = NULL;
BN_GENCB *cb = NULL; BN_GENCB *cb = NULL;
int numbits = -1, num = 0, genkey = 0, need_rand = 0; int numbits = -1, num = 0, genkey = 0;
int informat = FORMAT_PEM, outformat = FORMAT_PEM, noout = 0, C = 0; int informat = FORMAT_PEM, outformat = FORMAT_PEM, noout = 0, C = 0;
int ret = 1, i, text = 0, private = 0; int ret = 1, i, text = 0, private = 0;
char *infile = NULL, *outfile = NULL, *prog, *inrand = NULL; char *infile = NULL, *outfile = NULL, *prog;
OPTION_CHOICE o; OPTION_CHOICE o;
prog = opt_init(argc, argv, dsaparam_options); prog = opt_init(argc, argv, dsaparam_options);
...@@ -97,11 +97,11 @@ int dsaparam_main(int argc, char **argv) ...@@ -97,11 +97,11 @@ int dsaparam_main(int argc, char **argv)
C = 1; C = 1;
break; break;
case OPT_GENKEY: case OPT_GENKEY:
genkey = need_rand = 1; genkey = 1;
break; break;
case OPT_RAND: case OPT_R_CASES:
inrand = opt_arg(); if (!opt_rand(o))
need_rand = 1; goto end;
break; break;
case OPT_NOOUT: case OPT_NOOUT:
noout = 1; noout = 1;
...@@ -116,7 +116,6 @@ int dsaparam_main(int argc, char **argv) ...@@ -116,7 +116,6 @@ int dsaparam_main(int argc, char **argv)
goto end; goto end;
/* generate a key */ /* generate a key */
numbits = num; numbits = num;
need_rand = 1;
} }
private = genkey ? 1 : 0; private = genkey ? 1 : 0;
...@@ -127,13 +126,6 @@ int dsaparam_main(int argc, char **argv) ...@@ -127,13 +126,6 @@ int dsaparam_main(int argc, char **argv)
if (out == NULL) if (out == NULL)
goto end; goto end;
if (need_rand) {
app_RAND_load_file(NULL, (inrand != NULL));
if (inrand != NULL)
BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
app_RAND_load_files(inrand));
}
if (numbits > 0) { if (numbits > 0) {
cb = BN_GENCB_new(); cb = BN_GENCB_new();
if (cb == NULL) { if (cb == NULL) {
...@@ -141,7 +133,6 @@ int dsaparam_main(int argc, char **argv) ...@@ -141,7 +133,6 @@ int dsaparam_main(int argc, char **argv)
goto end; goto end;
} }
BN_GENCB_set(cb, dsa_cb, bio_err); BN_GENCB_set(cb, dsa_cb, bio_err);
assert(need_rand);
dsa = DSA_new(); dsa = DSA_new();
if (dsa == NULL) { if (dsa == NULL) {
BIO_printf(bio_err, "Error allocating DSA object\n"); BIO_printf(bio_err, "Error allocating DSA object\n");
...@@ -217,7 +208,6 @@ int dsaparam_main(int argc, char **argv) ...@@ -217,7 +208,6 @@ int dsaparam_main(int argc, char **argv)
if (genkey) { if (genkey) {
DSA *dsakey; DSA *dsakey;
assert(need_rand);
if ((dsakey = DSAparams_dup(dsa)) == NULL) if ((dsakey = DSAparams_dup(dsa)) == NULL)
goto end; goto end;
if (!DSA_generate_key(dsakey)) { if (!DSA_generate_key(dsakey)) {
...@@ -233,8 +223,6 @@ int dsaparam_main(int argc, char **argv) ...@@ -233,8 +223,6 @@ int dsaparam_main(int argc, char **argv)
NULL); NULL);
DSA_free(dsakey); DSA_free(dsakey);
} }
if (need_rand)
app_RAND_write_file(NULL);
ret = 0; ret = 0;
end: end:
BN_GENCB_free(cb); BN_GENCB_free(cb);
......
...@@ -29,7 +29,8 @@ typedef enum OPTION_choice { ...@@ -29,7 +29,8 @@ typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_TEXT, OPT_C, OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_TEXT, OPT_C,
OPT_CHECK, OPT_LIST_CURVES, OPT_NO_SEED, OPT_NOOUT, OPT_NAME, OPT_CHECK, OPT_LIST_CURVES, OPT_NO_SEED, OPT_NOOUT, OPT_NAME,
OPT_CONV_FORM, OPT_PARAM_ENC, OPT_GENKEY, OPT_RAND, OPT_ENGINE OPT_CONV_FORM, OPT_PARAM_ENC, OPT_GENKEY, OPT_ENGINE,
OPT_R_ENUM
} OPTION_CHOICE; } OPTION_CHOICE;
const OPTIONS ecparam_options[] = { const OPTIONS ecparam_options[] = {
...@@ -52,7 +53,7 @@ const OPTIONS ecparam_options[] = { ...@@ -52,7 +53,7 @@ const OPTIONS ecparam_options[] = {
{"param_enc", OPT_PARAM_ENC, 's', {"param_enc", OPT_PARAM_ENC, 's',
"Specifies the way the ec parameters are encoded"}, "Specifies the way the ec parameters are encoded"},
{"genkey", OPT_GENKEY, '-', "Generate ec key"}, {"genkey", OPT_GENKEY, '-', "Generate ec key"},
{"rand", OPT_RAND, 's', "Files to use for random number input"}, OPT_R_OPTIONS,
# ifndef OPENSSL_NO_ENGINE # ifndef OPENSSL_NO_ENGINE
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
# endif # endif
...@@ -80,7 +81,7 @@ int ecparam_main(int argc, char **argv) ...@@ -80,7 +81,7 @@ int ecparam_main(int argc, char **argv)
BIO *in = NULL, *out = NULL; BIO *in = NULL, *out = NULL;
EC_GROUP *group = NULL; EC_GROUP *group = NULL;
point_conversion_form_t form = POINT_CONVERSION_UNCOMPRESSED; point_conversion_form_t form = POINT_CONVERSION_UNCOMPRESSED;
char *curve_name = NULL, *inrand = NULL; char *curve_name = NULL;
char *infile = NULL, *outfile = NULL, *prog; char *infile = NULL, *outfile = NULL, *prog;
unsigned char *buffer = NULL; unsigned char *buffer = NULL;
OPTION_CHOICE o; OPTION_CHOICE o;
...@@ -88,7 +89,7 @@ int ecparam_main(int argc, char **argv) ...@@ -88,7 +89,7 @@ int ecparam_main(int argc, char **argv)
int informat = FORMAT_PEM, outformat = FORMAT_PEM, noout = 0, C = 0; int informat = FORMAT_PEM, outformat = FORMAT_PEM, noout = 0, C = 0;
int ret = 1, private = 0; int ret = 1, private = 0;
int list_curves = 0, no_seed = 0, check = 0, new_form = 0; int list_curves = 0, no_seed = 0, check = 0, new_form = 0;
int text = 0, i, need_rand = 0, genkey = 0; int text = 0, i, genkey = 0;
prog = opt_init(argc, argv, ecparam_options); prog = opt_init(argc, argv, ecparam_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
...@@ -149,11 +150,11 @@ int ecparam_main(int argc, char **argv) ...@@ -149,11 +150,11 @@ int ecparam_main(int argc, char **argv)
new_asn1_flag = 1; new_asn1_flag = 1;
break; break;
case OPT_GENKEY: case OPT_GENKEY:
genkey = need_rand = 1; genkey = 1;
break; break;
case OPT_RAND: case OPT_R_CASES:
inrand = opt_arg(); if (!opt_rand(o))
need_rand = 1; goto end;
break; break;
case OPT_ENGINE: case OPT_ENGINE:
e = setup_engine(opt_arg(), 0); e = setup_engine(opt_arg(), 0);
...@@ -395,21 +396,12 @@ int ecparam_main(int argc, char **argv) ...@@ -395,21 +396,12 @@ int ecparam_main(int argc, char **argv)
} }
} }
if (need_rand) {
app_RAND_load_file(NULL, (inrand != NULL));
if (inrand != NULL)
BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
app_RAND_load_files(inrand));
}
if (genkey) { if (genkey) {
EC_KEY *eckey = EC_KEY_new(); EC_KEY *eckey = EC_KEY_new();
if (eckey == NULL) if (eckey == NULL)
goto end; goto end;
assert(need_rand);
if (EC_KEY_set_group(eckey, group) == 0) { if (EC_KEY_set_group(eckey, group) == 0) {
BIO_printf(bio_err, "unable to set group when generating key\n"); BIO_printf(bio_err, "unable to set group when generating key\n");
EC_KEY_free(eckey); EC_KEY_free(eckey);
...@@ -432,9 +424,6 @@ int ecparam_main(int argc, char **argv) ...@@ -432,9 +424,6 @@ int ecparam_main(int argc, char **argv)
EC_KEY_free(eckey); EC_KEY_free(eckey);
} }
if (need_rand)
app_RAND_write_file(NULL);
ret = 0; ret = 0;
end: end:
BN_free(ec_p); BN_free(ec_p);
......
...@@ -43,7 +43,8 @@ typedef enum OPTION_choice { ...@@ -43,7 +43,8 @@ typedef enum OPTION_choice {
OPT_E, OPT_IN, OPT_OUT, OPT_PASS, OPT_ENGINE, OPT_D, OPT_P, OPT_V, OPT_E, OPT_IN, OPT_OUT, OPT_PASS, OPT_ENGINE, OPT_D, OPT_P, OPT_V,
OPT_NOPAD, OPT_SALT, OPT_NOSALT, OPT_DEBUG, OPT_UPPER_P, OPT_UPPER_A, OPT_NOPAD, OPT_SALT, OPT_NOSALT, OPT_DEBUG, OPT_UPPER_P, OPT_UPPER_A,
OPT_A, OPT_Z, OPT_BUFSIZE, OPT_K, OPT_KFILE, OPT_UPPER_K, OPT_NONE, OPT_A, OPT_Z, OPT_BUFSIZE, OPT_K, OPT_KFILE, OPT_UPPER_K, OPT_NONE,
OPT_UPPER_S, OPT_IV, OPT_MD, OPT_CIPHER OPT_UPPER_S, OPT_IV, OPT_MD, OPT_CIPHER,
OPT_R_ENUM
} OPTION_CHOICE; } OPTION_CHOICE;
const OPTIONS enc_options[] = { const OPTIONS enc_options[] = {
...@@ -74,6 +75,7 @@ const OPTIONS enc_options[] = { ...@@ -74,6 +75,7 @@ const OPTIONS enc_options[] = {
{"md", OPT_MD, 's', "Use specified digest to create a key from the passphrase"}, {"md", OPT_MD, 's', "Use specified digest to create a key from the passphrase"},
{"none", OPT_NONE, '-', "Don't encrypt"}, {"none", OPT_NONE, '-', "Don't encrypt"},
{"", OPT_CIPHER, '-', "Any supported cipher"}, {"", OPT_CIPHER, '-', "Any supported cipher"},
OPT_R_OPTIONS,
#ifdef ZLIB #ifdef ZLIB
{"z", OPT_Z, '-', "Use zlib as the 'encryption'"}, {"z", OPT_Z, '-', "Use zlib as the 'encryption'"},
#endif #endif
...@@ -255,6 +257,10 @@ int enc_main(int argc, char **argv) ...@@ -255,6 +257,10 @@ int enc_main(int argc, char **argv)
case OPT_NONE: case OPT_NONE:
cipher = NULL; cipher = NULL;
break; break;
case OPT_R_CASES:
if (!opt_rand(o))
goto end;
break;
} }
} }
......
...@@ -26,7 +26,8 @@ NON_EMPTY_TRANSLATION_UNIT ...@@ -26,7 +26,8 @@ NON_EMPTY_TRANSLATION_UNIT
typedef enum OPTION_choice { typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
OPT_OUT, OPT_PASSOUT, OPT_ENGINE, OPT_RAND, OPT_CIPHER OPT_OUT, OPT_PASSOUT, OPT_ENGINE, OPT_CIPHER,
OPT_R_ENUM
} OPTION_CHOICE; } OPTION_CHOICE;
const OPTIONS gendsa_options[] = { const OPTIONS gendsa_options[] = {
...@@ -35,8 +36,7 @@ const OPTIONS gendsa_options[] = { ...@@ -35,8 +36,7 @@ const OPTIONS gendsa_options[] = {
{"help", OPT_HELP, '-', "Display this summary"}, {"help", OPT_HELP, '-', "Display this summary"},
{"out", OPT_OUT, '>', "Output the key to the specified file"}, {"out", OPT_OUT, '>', "Output the key to the specified file"},
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"}, {"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
{"rand", OPT_RAND, 's', OPT_R_OPTIONS,
"Load the file(s) into the random number generator"},
{"", OPT_CIPHER, '-', "Encrypt the output with any supported cipher"}, {"", OPT_CIPHER, '-', "Encrypt the output with any supported cipher"},
# ifndef OPENSSL_NO_ENGINE # ifndef OPENSSL_NO_ENGINE
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
...@@ -50,7 +50,7 @@ int gendsa_main(int argc, char **argv) ...@@ -50,7 +50,7 @@ int gendsa_main(int argc, char **argv)
BIO *out = NULL, *in = NULL; BIO *out = NULL, *in = NULL;
DSA *dsa = NULL; DSA *dsa = NULL;
const EVP_CIPHER *enc = NULL; const EVP_CIPHER *enc = NULL;
char *inrand = NULL, *dsaparams = NULL; char *dsaparams = NULL;
char *outfile = NULL, *passoutarg = NULL, *passout = NULL, *prog; char *outfile = NULL, *passoutarg = NULL, *passout = NULL, *prog;
OPTION_CHOICE o; OPTION_CHOICE o;
int ret = 1, private = 0; int ret = 1, private = 0;
...@@ -77,8 +77,9 @@ int gendsa_main(int argc, char **argv) ...@@ -77,8 +77,9 @@ int gendsa_main(int argc, char **argv)
case OPT_ENGINE: case OPT_ENGINE:
e = setup_engine(opt_arg(), 0); e = setup_engine(opt_arg(), 0);
break; break;
case OPT_RAND: case OPT_R_CASES:
inrand = opt_arg(); if (!opt_rand(o))
goto end;
break; break;
case OPT_CIPHER: case OPT_CIPHER:
if (!opt_cipher(opt_unknown(), &enc)) if (!opt_cipher(opt_unknown(), &enc))
...@@ -114,21 +115,11 @@ int gendsa_main(int argc, char **argv) ...@@ -114,21 +115,11 @@ int gendsa_main(int argc, char **argv)
if (out == NULL) if (out == NULL)
goto end2; goto end2;
if (!app_RAND_load_file(NULL, 1) && inrand == NULL) {
BIO_printf(bio_err,
"warning, not much extra random data, consider using the -rand option\n");
}
if (inrand != NULL)
BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
app_RAND_load_files(inrand));
DSA_get0_pqg(dsa, &p, NULL, NULL); DSA_get0_pqg(dsa, &p, NULL, NULL);
BIO_printf(bio_err, "Generating DSA key, %d bits\n", BN_num_bits(p)); BIO_printf(bio_err, "Generating DSA key, %d bits\n", BN_num_bits(p));
if (!DSA_generate_key(dsa)) if (!DSA_generate_key(dsa))
goto end; goto end;
app_RAND_write_file(NULL);
assert(private); assert(private);
if (!PEM_write_bio_DSAPrivateKey(out, dsa, enc, NULL, 0, NULL, passout)) if (!PEM_write_bio_DSAPrivateKey(out, dsa, enc, NULL, 0, NULL, passout))
goto end; goto end;
......
...@@ -33,7 +33,8 @@ static int genrsa_cb(int p, int n, BN_GENCB *cb); ...@@ -33,7 +33,8 @@ static int genrsa_cb(int p, int n, BN_GENCB *cb);
typedef enum OPTION_choice { typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
OPT_3, OPT_F4, OPT_ENGINE, OPT_3, OPT_F4, OPT_ENGINE,
OPT_OUT, OPT_RAND, OPT_PASSOUT, OPT_CIPHER OPT_OUT, OPT_PASSOUT, OPT_CIPHER,
OPT_R_ENUM
} OPTION_CHOICE; } OPTION_CHOICE;
const OPTIONS genrsa_options[] = { const OPTIONS genrsa_options[] = {
...@@ -42,8 +43,7 @@ const OPTIONS genrsa_options[] = { ...@@ -42,8 +43,7 @@ const OPTIONS genrsa_options[] = {
{"F4", OPT_F4, '-', "Use F4 (0x10001) for the E value"}, {"F4", OPT_F4, '-', "Use F4 (0x10001) for the E value"},
{"f4", OPT_F4, '-', "Use F4 (0x10001) for the E value"}, {"f4", OPT_F4, '-', "Use F4 (0x10001) for the E value"},
{"out", OPT_OUT, 's', "Output the key to specified file"}, {"out", OPT_OUT, 's', "Output the key to specified file"},
{"rand", OPT_RAND, 's', OPT_R_OPTIONS,
"Load the file(s) into the random number generator"},
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"}, {"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
{"", OPT_CIPHER, '-', "Encrypt the output with any supported cipher"}, {"", OPT_CIPHER, '-', "Encrypt the output with any supported cipher"},
# ifndef OPENSSL_NO_ENGINE # ifndef OPENSSL_NO_ENGINE
...@@ -65,7 +65,7 @@ int genrsa_main(int argc, char **argv) ...@@ -65,7 +65,7 @@ int genrsa_main(int argc, char **argv)
int ret = 1, num = DEFBITS, private = 0; int ret = 1, num = DEFBITS, private = 0;
unsigned long f4 = RSA_F4; unsigned long f4 = RSA_F4;
char *outfile = NULL, *passoutarg = NULL, *passout = NULL; char *outfile = NULL, *passoutarg = NULL, *passout = NULL;
char *inrand = NULL, *prog, *hexe, *dece; char *prog, *hexe, *dece;
OPTION_CHOICE o; OPTION_CHOICE o;
if (bn == NULL || cb == NULL) if (bn == NULL || cb == NULL)
...@@ -96,8 +96,9 @@ int genrsa_main(int argc, char **argv) ...@@ -96,8 +96,9 @@ int genrsa_main(int argc, char **argv)
case OPT_ENGINE: case OPT_ENGINE:
eng = setup_engine(opt_arg(), 0); eng = setup_engine(opt_arg(), 0);
break; break;
case OPT_RAND: case OPT_R_CASES:
inrand = opt_arg(); if (!opt_rand(o))
goto end;
break; break;
case OPT_PASSOUT: case OPT_PASSOUT:
passoutarg = opt_arg(); passoutarg = opt_arg();
...@@ -124,15 +125,6 @@ int genrsa_main(int argc, char **argv) ...@@ -124,15 +125,6 @@ int genrsa_main(int argc, char **argv)
if (out == NULL) if (out == NULL)
goto end; goto end;
if (!app_RAND_load_file(NULL, 1) && inrand == NULL
&& !RAND_status()) {
BIO_printf(bio_err,
"warning, not much extra random data, consider using the -rand option\n");
}
if (inrand != NULL)
BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
app_RAND_load_files(inrand));
BIO_printf(bio_err, "Generating RSA private key, %d bit long modulus\n", BIO_printf(bio_err, "Generating RSA private key, %d bit long modulus\n",
num); num);
rsa = eng ? RSA_new_method(eng) : RSA_new(); rsa = eng ? RSA_new_method(eng) : RSA_new();
...@@ -142,8 +134,6 @@ int genrsa_main(int argc, char **argv) ...@@ -142,8 +134,6 @@ int genrsa_main(int argc, char **argv)
if (!BN_set_word(bn, f4) || !RSA_generate_key_ex(rsa, num, bn, cb)) if (!BN_set_word(bn, f4) || !RSA_generate_key_ex(rsa, num, bn, cb))
goto end; goto end;
app_RAND_write_file(NULL);
RSA_get0_key(rsa, NULL, &e, NULL); RSA_get0_key(rsa, NULL, &e, NULL);
hexe = BN_bn2hex(e); hexe = BN_bn2hex(e);
dece = BN_bn2dec(e); dece = BN_bn2dec(e);
......
...@@ -240,6 +240,7 @@ int main(int argc, char *argv[]) ...@@ -240,6 +240,7 @@ int main(int argc, char *argv[])
OPENSSL_free(default_config_file); OPENSSL_free(default_config_file);
lh_FUNCTION_free(prog); lh_FUNCTION_free(prog);
OPENSSL_free(arg.argv); OPENSSL_free(arg.argv);
app_RAND_write();
BIO_free(bio_in); BIO_free(bio_in);
BIO_free_all(bio_out); BIO_free_all(bio_out);
......
...@@ -65,7 +65,8 @@ typedef enum OPTION_choice { ...@@ -65,7 +65,8 @@ typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
OPT_IN, OPT_IN,
OPT_NOVERIFY, OPT_QUIET, OPT_TABLE, OPT_REVERSE, OPT_APR1, OPT_NOVERIFY, OPT_QUIET, OPT_TABLE, OPT_REVERSE, OPT_APR1,
OPT_1, OPT_5, OPT_6, OPT_CRYPT, OPT_AIXMD5, OPT_SALT, OPT_STDIN OPT_1, OPT_5, OPT_6, OPT_CRYPT, OPT_AIXMD5, OPT_SALT, OPT_STDIN,
OPT_R_ENUM,
} OPTION_CHOICE; } OPTION_CHOICE;
const OPTIONS passwd_options[] = { const OPTIONS passwd_options[] = {
...@@ -90,6 +91,7 @@ const OPTIONS passwd_options[] = { ...@@ -90,6 +91,7 @@ const OPTIONS passwd_options[] = {
# ifndef OPENSSL_NO_DES # ifndef OPENSSL_NO_DES
{"crypt", OPT_CRYPT, '-', "Standard Unix password algorithm (default)"}, {"crypt", OPT_CRYPT, '-', "Standard Unix password algorithm (default)"},
# endif # endif
OPT_R_OPTIONS,
{NULL} {NULL}
}; };
...@@ -182,6 +184,10 @@ int passwd_main(int argc, char **argv) ...@@ -182,6 +184,10 @@ int passwd_main(int argc, char **argv)
in_stdin = 1; in_stdin = 1;
pw_source_defined = 1; pw_source_defined = 1;
break; break;
case OPT_R_CASES:
if (!opt_rand(o))
goto end;
break;
} }
} }
argc = opt_num_rest(); argc = opt_num_rest();
......
...@@ -53,9 +53,10 @@ typedef enum OPTION_choice { ...@@ -53,9 +53,10 @@ typedef enum OPTION_choice {
OPT_CACERTS, OPT_NOOUT, OPT_INFO, OPT_CHAIN, OPT_TWOPASS, OPT_NOMACVER, OPT_CACERTS, OPT_NOOUT, OPT_INFO, OPT_CHAIN, OPT_TWOPASS, OPT_NOMACVER,
OPT_DESCERT, OPT_EXPORT, OPT_NOITER, OPT_MACITER, OPT_NOMACITER, OPT_DESCERT, OPT_EXPORT, OPT_NOITER, OPT_MACITER, OPT_NOMACITER,
OPT_NOMAC, OPT_LMK, OPT_NODES, OPT_MACALG, OPT_CERTPBE, OPT_KEYPBE, OPT_NOMAC, OPT_LMK, OPT_NODES, OPT_MACALG, OPT_CERTPBE, OPT_KEYPBE,
OPT_RAND, OPT_INKEY, OPT_CERTFILE, OPT_NAME, OPT_CSP, OPT_CANAME, OPT_INKEY, OPT_CERTFILE, OPT_NAME, OPT_CSP, OPT_CANAME,
OPT_IN, OPT_OUT, OPT_PASSIN, OPT_PASSOUT, OPT_PASSWORD, OPT_CAPATH, OPT_IN, OPT_OUT, OPT_PASSIN, OPT_PASSOUT, OPT_PASSWORD, OPT_CAPATH,
OPT_CAFILE, OPT_NOCAPATH, OPT_NOCAFILE, OPT_ENGINE OPT_CAFILE, OPT_NOCAPATH, OPT_NOCAFILE, OPT_ENGINE,
OPT_R_ENUM
} OPTION_CHOICE; } OPTION_CHOICE;
const OPTIONS pkcs12_options[] = { const OPTIONS pkcs12_options[] = {
...@@ -91,8 +92,7 @@ const OPTIONS pkcs12_options[] = { ...@@ -91,8 +92,7 @@ const OPTIONS pkcs12_options[] = {
{"macalg", OPT_MACALG, 's', {"macalg", OPT_MACALG, 's',
"Digest algorithm used in MAC (default SHA1)"}, "Digest algorithm used in MAC (default SHA1)"},
{"keypbe", OPT_KEYPBE, 's', "Private key PBE algorithm (default 3DES)"}, {"keypbe", OPT_KEYPBE, 's', "Private key PBE algorithm (default 3DES)"},
{"rand", OPT_RAND, 's', OPT_R_OPTIONS,
"Load the file(s) into the random number generator"},
{"inkey", OPT_INKEY, 's', "Private key if not infile"}, {"inkey", OPT_INKEY, 's', "Private key if not infile"},
{"certfile", OPT_CERTFILE, '<', "Load certs from file"}, {"certfile", OPT_CERTFILE, '<', "Load certs from file"},
{"name", OPT_NAME, 's', "Use name as friendly name"}, {"name", OPT_NAME, 's', "Use name as friendly name"},
...@@ -133,7 +133,7 @@ int pkcs12_main(int argc, char **argv) ...@@ -133,7 +133,7 @@ int pkcs12_main(int argc, char **argv)
int ret = 1, macver = 1, add_lmk = 0, private = 0; int ret = 1, macver = 1, add_lmk = 0, private = 0;
int noprompt = 0; int noprompt = 0;
char *passinarg = NULL, *passoutarg = NULL, *passarg = NULL; char *passinarg = NULL, *passoutarg = NULL, *passarg = NULL;
char *passin = NULL, *passout = NULL, *inrand = NULL, *macalg = NULL; char *passin = NULL, *passout = NULL, *macalg = NULL;
char *cpass = NULL, *mpass = NULL, *badpass = NULL; char *cpass = NULL, *mpass = NULL, *badpass = NULL;
const char *CApath = NULL, *CAfile = NULL, *prog; const char *CApath = NULL, *CAfile = NULL, *prog;
int noCApath = 0, noCAfile = 0; int noCApath = 0, noCAfile = 0;
...@@ -225,8 +225,9 @@ int pkcs12_main(int argc, char **argv) ...@@ -225,8 +225,9 @@ int pkcs12_main(int argc, char **argv)
if (!set_pbe(&key_pbe, opt_arg())) if (!set_pbe(&key_pbe, opt_arg()))
goto opthelp; goto opthelp;
break; break;
case OPT_RAND: case OPT_R_CASES:
inrand = opt_arg(); if (!opt_rand(o))
goto end;
break; break;
case OPT_INKEY: case OPT_INKEY:
keyname = opt_arg(); keyname = opt_arg();
...@@ -314,13 +315,6 @@ int pkcs12_main(int argc, char **argv) ...@@ -314,13 +315,6 @@ int pkcs12_main(int argc, char **argv)
mpass = macpass; mpass = macpass;
} }
if (export_cert || inrand != NULL) {
app_RAND_load_file(NULL, (inrand != NULL));
if (inrand != NULL)
BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
app_RAND_load_files(inrand));
}
if (twopass) { if (twopass) {
/* To avoid bit rot */ /* To avoid bit rot */
if (1) { if (1) {
...@@ -576,8 +570,6 @@ int pkcs12_main(int argc, char **argv) ...@@ -576,8 +570,6 @@ int pkcs12_main(int argc, char **argv)
ret = 0; ret = 0;
end: end:
PKCS12_free(p12); PKCS12_free(p12);
if (export_cert || inrand)
app_RAND_write_file(NULL);
release_engine(e); release_engine(e);
BIO_free(in); BIO_free(in);
BIO_free_all(out); BIO_free_all(out);
......
...@@ -24,7 +24,8 @@ typedef enum OPTION_choice { ...@@ -24,7 +24,8 @@ typedef enum OPTION_choice {
OPT_SCRYPT, OPT_SCRYPT_N, OPT_SCRYPT_R, OPT_SCRYPT_P, OPT_SCRYPT, OPT_SCRYPT_N, OPT_SCRYPT_R, OPT_SCRYPT_P,
#endif #endif
OPT_V2, OPT_V1, OPT_V2PRF, OPT_ITER, OPT_PASSIN, OPT_PASSOUT, OPT_V2, OPT_V1, OPT_V2PRF, OPT_ITER, OPT_PASSIN, OPT_PASSOUT,
OPT_TRADITIONAL OPT_TRADITIONAL,
OPT_R_ENUM
} OPTION_CHOICE; } OPTION_CHOICE;
const OPTIONS pkcs8_options[] = { const OPTIONS pkcs8_options[] = {
...@@ -36,6 +37,7 @@ const OPTIONS pkcs8_options[] = { ...@@ -36,6 +37,7 @@ const OPTIONS pkcs8_options[] = {
{"topk8", OPT_TOPK8, '-', "Output PKCS8 file"}, {"topk8", OPT_TOPK8, '-', "Output PKCS8 file"},
{"noiter", OPT_NOITER, '-', "Use 1 as iteration count"}, {"noiter", OPT_NOITER, '-', "Use 1 as iteration count"},
{"nocrypt", OPT_NOCRYPT, '-', "Use or expect unencrypted private key"}, {"nocrypt", OPT_NOCRYPT, '-', "Use or expect unencrypted private key"},
OPT_R_OPTIONS,
{"v2", OPT_V2, 's', "Use PKCS#5 v2.0 and cipher"}, {"v2", OPT_V2, 's', "Use PKCS#5 v2.0 and cipher"},
{"v1", OPT_V1, 's', "Use PKCS#5 v1.5 and cipher"}, {"v1", OPT_V1, 's', "Use PKCS#5 v1.5 and cipher"},
{"v2prf", OPT_V2PRF, 's', "Set the PRF algorithm to use with PKCS#5 v2.0"}, {"v2prf", OPT_V2PRF, 's', "Set the PRF algorithm to use with PKCS#5 v2.0"},
...@@ -112,6 +114,10 @@ int pkcs8_main(int argc, char **argv) ...@@ -112,6 +114,10 @@ int pkcs8_main(int argc, char **argv)
case OPT_NOCRYPT: case OPT_NOCRYPT:
nocrypt = 1; nocrypt = 1;
break; break;
case OPT_R_CASES:
if (!opt_rand(o))
goto end;
break;
case OPT_TRADITIONAL: case OPT_TRADITIONAL:
traditional = 1; traditional = 1;
break; break;
...@@ -248,7 +254,6 @@ int pkcs8_main(int argc, char **argv) ...@@ -248,7 +254,6 @@ int pkcs8_main(int argc, char **argv)
BIO_printf(bio_err, "Password required\n"); BIO_printf(bio_err, "Password required\n");
goto end; goto end;
} }
app_RAND_load_file(NULL, 0);
p8 = PKCS8_set0_pbe(p8pass, strlen(p8pass), p8inf, pbe); p8 = PKCS8_set0_pbe(p8pass, strlen(p8pass), p8inf, pbe);
if (p8 == NULL) { if (p8 == NULL) {
X509_ALGOR_free(pbe); X509_ALGOR_free(pbe);
...@@ -256,7 +261,6 @@ int pkcs8_main(int argc, char **argv) ...@@ -256,7 +261,6 @@ int pkcs8_main(int argc, char **argv)
ERR_print_errors(bio_err); ERR_print_errors(bio_err);
goto end; goto end;
} }
app_RAND_write_file(NULL);
assert(private); assert(private);
if (outformat == FORMAT_PEM) if (outformat == FORMAT_PEM)
PEM_write_bio_PKCS8(out, p8); PEM_write_bio_PKCS8(out, p8);
......
...@@ -36,7 +36,8 @@ typedef enum OPTION_choice { ...@@ -36,7 +36,8 @@ typedef enum OPTION_choice {
OPT_PUBIN, OPT_CERTIN, OPT_ASN1PARSE, OPT_HEXDUMP, OPT_SIGN, OPT_PUBIN, OPT_CERTIN, OPT_ASN1PARSE, OPT_HEXDUMP, OPT_SIGN,
OPT_VERIFY, OPT_VERIFYRECOVER, OPT_REV, OPT_ENCRYPT, OPT_DECRYPT, OPT_VERIFY, OPT_VERIFYRECOVER, OPT_REV, OPT_ENCRYPT, OPT_DECRYPT,
OPT_DERIVE, OPT_SIGFILE, OPT_INKEY, OPT_PEERKEY, OPT_PASSIN, OPT_DERIVE, OPT_SIGFILE, OPT_INKEY, OPT_PEERKEY, OPT_PASSIN,
OPT_PEERFORM, OPT_KEYFORM, OPT_PKEYOPT, OPT_KDF, OPT_KDFLEN OPT_PEERFORM, OPT_KEYFORM, OPT_PKEYOPT, OPT_KDF, OPT_KDFLEN,
OPT_R_ENUM
} OPTION_CHOICE; } OPTION_CHOICE;
const OPTIONS pkeyutl_options[] = { const OPTIONS pkeyutl_options[] = {
...@@ -64,6 +65,7 @@ const OPTIONS pkeyutl_options[] = { ...@@ -64,6 +65,7 @@ const OPTIONS pkeyutl_options[] = {
{"peerform", OPT_PEERFORM, 'E', "Peer key format - default PEM"}, {"peerform", OPT_PEERFORM, 'E', "Peer key format - default PEM"},
{"keyform", OPT_KEYFORM, 'E', "Private key format - default PEM"}, {"keyform", OPT_KEYFORM, 'E', "Private key format - default PEM"},
{"pkeyopt", OPT_PKEYOPT, 's', "Public key options as opt:value"}, {"pkeyopt", OPT_PKEYOPT, 's', "Public key options as opt:value"},
OPT_R_OPTIONS,
#ifndef OPENSSL_NO_ENGINE #ifndef OPENSSL_NO_ENGINE
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
{"engine_impl", OPT_ENGINE_IMPL, '-', {"engine_impl", OPT_ENGINE_IMPL, '-',
...@@ -134,6 +136,10 @@ int pkeyutl_main(int argc, char **argv) ...@@ -134,6 +136,10 @@ int pkeyutl_main(int argc, char **argv)
if (!opt_format(opt_arg(), OPT_FMT_PDE, &keyform)) if (!opt_format(opt_arg(), OPT_FMT_PDE, &keyform))
goto opthelp; goto opthelp;
break; break;
case OPT_R_CASES:
if (!opt_rand(o))
goto end;
break;
case OPT_ENGINE: case OPT_ENGINE:
e = setup_engine(opt_arg(), 0); e = setup_engine(opt_arg(), 0);
break; break;
...@@ -238,9 +244,6 @@ int pkeyutl_main(int argc, char **argv) ...@@ -238,9 +244,6 @@ int pkeyutl_main(int argc, char **argv)
goto end; goto end;
} }
/* FIXME: seed PRNG only if needed */
app_RAND_load_file(NULL, 0);
if (pkey_op != EVP_PKEY_OP_DERIVE) { if (pkey_op != EVP_PKEY_OP_DERIVE) {
in = bio_open_default(infile, 'r', FORMAT_BINARY); in = bio_open_default(infile, 'r', FORMAT_BINARY);
if (in == NULL) if (in == NULL)
......
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
typedef enum OPTION_choice { typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
OPT_OUT, OPT_ENGINE, OPT_RAND, OPT_BASE64, OPT_HEX OPT_OUT, OPT_ENGINE, OPT_BASE64, OPT_HEX,
OPT_R_ENUM
} OPTION_CHOICE; } OPTION_CHOICE;
const OPTIONS rand_options[] = { const OPTIONS rand_options[] = {
...@@ -27,8 +28,7 @@ const OPTIONS rand_options[] = { ...@@ -27,8 +28,7 @@ const OPTIONS rand_options[] = {
{OPT_HELP_STR, 1, '-', "Valid options are:\n"}, {OPT_HELP_STR, 1, '-', "Valid options are:\n"},
{"help", OPT_HELP, '-', "Display this summary"}, {"help", OPT_HELP, '-', "Display this summary"},
{"out", OPT_OUT, '>', "Output file"}, {"out", OPT_OUT, '>', "Output file"},
{"rand", OPT_RAND, 's', OPT_R_OPTIONS,
"Load the file(s) into the random number generator"},
{"base64", OPT_BASE64, '-', "Base64 encode output"}, {"base64", OPT_BASE64, '-', "Base64 encode output"},
{"hex", OPT_HEX, '-', "Hex encode output"}, {"hex", OPT_HEX, '-', "Hex encode output"},
#ifndef OPENSSL_NO_ENGINE #ifndef OPENSSL_NO_ENGINE
...@@ -41,7 +41,7 @@ int rand_main(int argc, char **argv) ...@@ -41,7 +41,7 @@ int rand_main(int argc, char **argv)
{ {
ENGINE *e = NULL; ENGINE *e = NULL;
BIO *out = NULL; BIO *out = NULL;
char *inrand = NULL, *outfile = NULL, *prog; char *outfile = NULL, *prog;
OPTION_CHOICE o; OPTION_CHOICE o;
int format = FORMAT_BINARY, i, num = -1, r, ret = 1; int format = FORMAT_BINARY, i, num = -1, r, ret = 1;
...@@ -63,8 +63,9 @@ int rand_main(int argc, char **argv) ...@@ -63,8 +63,9 @@ int rand_main(int argc, char **argv)
case OPT_ENGINE: case OPT_ENGINE:
e = setup_engine(opt_arg(), 0); e = setup_engine(opt_arg(), 0);
break; break;
case OPT_RAND: case OPT_R_CASES:
inrand = opt_arg(); if (!opt_rand(o))
goto end;
break; break;
case OPT_BASE64: case OPT_BASE64:
format = FORMAT_BASE64; format = FORMAT_BASE64;
...@@ -80,11 +81,6 @@ int rand_main(int argc, char **argv) ...@@ -80,11 +81,6 @@ int rand_main(int argc, char **argv)
if (argc != 1 || !opt_int(argv[0], &num) || num < 0) if (argc != 1 || !opt_int(argv[0], &num) || num < 0)
goto opthelp; goto opthelp;
app_RAND_load_file(NULL, (inrand != NULL));
if (inrand != NULL)
BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
app_RAND_load_files(inrand));
out = bio_open_default(outfile, 'w', format); out = bio_open_default(outfile, 'w', format);
if (out == NULL) if (out == NULL)
goto end; goto end;
...@@ -118,7 +114,7 @@ int rand_main(int argc, char **argv) ...@@ -118,7 +114,7 @@ int rand_main(int argc, char **argv)
} }
if (format == FORMAT_TEXT) if (format == FORMAT_TEXT)
BIO_puts(out, "\n"); BIO_puts(out, "\n");
if (BIO_flush(out) <= 0 || !app_RAND_write_file(NULL)) if (BIO_flush(out) <= 0)
goto end; goto end;
ret = 0; ret = 0;
......
...@@ -76,12 +76,13 @@ typedef enum OPTION_choice { ...@@ -76,12 +76,13 @@ typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
OPT_INFORM, OPT_OUTFORM, OPT_ENGINE, OPT_KEYGEN_ENGINE, OPT_KEY, OPT_INFORM, OPT_OUTFORM, OPT_ENGINE, OPT_KEYGEN_ENGINE, OPT_KEY,
OPT_PUBKEY, OPT_NEW, OPT_CONFIG, OPT_KEYFORM, OPT_IN, OPT_OUT, OPT_PUBKEY, OPT_NEW, OPT_CONFIG, OPT_KEYFORM, OPT_IN, OPT_OUT,
OPT_KEYOUT, OPT_PASSIN, OPT_PASSOUT, OPT_RAND, OPT_NEWKEY, OPT_KEYOUT, OPT_PASSIN, OPT_PASSOUT, OPT_NEWKEY,
OPT_PKEYOPT, OPT_SIGOPT, OPT_BATCH, OPT_NEWHDR, OPT_MODULUS, OPT_PKEYOPT, OPT_SIGOPT, OPT_BATCH, OPT_NEWHDR, OPT_MODULUS,
OPT_VERIFY, OPT_NODES, OPT_NOOUT, OPT_VERBOSE, OPT_UTF8, OPT_VERIFY, OPT_NODES, OPT_NOOUT, OPT_VERBOSE, OPT_UTF8,
OPT_NAMEOPT, OPT_REQOPT, OPT_SUBJ, OPT_SUBJECT, OPT_TEXT, OPT_X509, OPT_NAMEOPT, OPT_REQOPT, OPT_SUBJ, OPT_SUBJECT, OPT_TEXT, OPT_X509,
OPT_MULTIVALUE_RDN, OPT_DAYS, OPT_SET_SERIAL, OPT_EXTENSIONS, OPT_MULTIVALUE_RDN, OPT_DAYS, OPT_SET_SERIAL, OPT_EXTENSIONS,
OPT_REQEXTS, OPT_PRECERT, OPT_MD OPT_REQEXTS, OPT_PRECERT, OPT_MD,
OPT_R_ENUM
} OPTION_CHOICE; } OPTION_CHOICE;
const OPTIONS req_options[] = { const OPTIONS req_options[] = {
...@@ -98,8 +99,7 @@ const OPTIONS req_options[] = { ...@@ -98,8 +99,7 @@ const OPTIONS req_options[] = {
{"keyout", OPT_KEYOUT, '>', "File to send the key to"}, {"keyout", OPT_KEYOUT, '>', "File to send the key to"},
{"passin", OPT_PASSIN, 's', "Private key password source"}, {"passin", OPT_PASSIN, 's', "Private key password source"},
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"}, {"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
{"rand", OPT_RAND, 's', OPT_R_OPTIONS,
"Load the file(s) into the random number generator"},
{"newkey", OPT_NEWKEY, 's', "Specify as type:bits"}, {"newkey", OPT_NEWKEY, 's', "Specify as type:bits"},
{"pkeyopt", OPT_PKEYOPT, 's', "Public key options as opt:value"}, {"pkeyopt", OPT_PKEYOPT, 's', "Public key options as opt:value"},
{"sigopt", OPT_SIGOPT, 's', "Signature parameter in n:v form"}, {"sigopt", OPT_SIGOPT, 's', "Signature parameter in n:v form"},
...@@ -151,7 +151,7 @@ int req_main(int argc, char **argv) ...@@ -151,7 +151,7 @@ int req_main(int argc, char **argv)
const EVP_CIPHER *cipher = NULL; const EVP_CIPHER *cipher = NULL;
const EVP_MD *md_alg = NULL, *digest = NULL; const EVP_MD *md_alg = NULL, *digest = NULL;
char *extensions = NULL, *infile = NULL; char *extensions = NULL, *infile = NULL;
char *outfile = NULL, *keyfile = NULL, *inrand = NULL; char *outfile = NULL, *keyfile = NULL;
char *keyalgstr = NULL, *p, *prog, *passargin = NULL, *passargout = NULL; char *keyalgstr = NULL, *p, *prog, *passargin = NULL, *passargout = NULL;
char *passin = NULL, *passout = NULL; char *passin = NULL, *passout = NULL;
char *nofree_passin = NULL, *nofree_passout = NULL; char *nofree_passin = NULL, *nofree_passout = NULL;
...@@ -234,8 +234,9 @@ int req_main(int argc, char **argv) ...@@ -234,8 +234,9 @@ int req_main(int argc, char **argv)
case OPT_PASSOUT: case OPT_PASSOUT:
passargout = opt_arg(); passargout = opt_arg();
break; break;
case OPT_RAND: case OPT_R_CASES:
inrand = opt_arg(); if (!opt_rand(o))
goto end;
break; break;
case OPT_NEWKEY: case OPT_NEWKEY:
keyalg = opt_arg(); keyalg = opt_arg();
...@@ -454,20 +455,12 @@ int req_main(int argc, char **argv) ...@@ -454,20 +455,12 @@ int req_main(int argc, char **argv)
/* load_key() has already printed an appropriate message */ /* load_key() has already printed an appropriate message */
goto end; goto end;
} else { } else {
char *randfile = NCONF_get_string(req_conf, SECTION, "RANDFILE"); app_RAND_load_conf(req_conf, SECTION);
if (randfile == NULL)
ERR_clear_error();
app_RAND_load_file(randfile, 0);
} }
} }
if (newreq && (pkey == NULL)) { if (newreq && (pkey == NULL)) {
char *randfile = NCONF_get_string(req_conf, SECTION, "RANDFILE"); app_RAND_load_conf(req_conf, SECTION);
if (randfile == NULL)
ERR_clear_error();
app_RAND_load_file(randfile, 0);
if (inrand != NULL)
app_RAND_load_files(inrand);
if (!NCONF_get_number(req_conf, SECTION, BITS, &newkey)) { if (!NCONF_get_number(req_conf, SECTION, BITS, &newkey)) {
newkey = DEFAULT_KEY_LENGTH; newkey = DEFAULT_KEY_LENGTH;
...@@ -525,8 +518,6 @@ int req_main(int argc, char **argv) ...@@ -525,8 +518,6 @@ int req_main(int argc, char **argv)
EVP_PKEY_CTX_free(genctx); EVP_PKEY_CTX_free(genctx);
genctx = NULL; genctx = NULL;
app_RAND_write_file(randfile);
if (keyout == NULL) { if (keyout == NULL) {
keyout = NCONF_get_string(req_conf, SECTION, KEYFILE); keyout = NCONF_get_string(req_conf, SECTION, KEYFILE);
if (keyout == NULL) if (keyout == NULL)
......
...@@ -32,7 +32,8 @@ typedef enum OPTION_choice { ...@@ -32,7 +32,8 @@ typedef enum OPTION_choice {
OPT_ENGINE, OPT_IN, OPT_OUT, OPT_ASN1PARSE, OPT_HEXDUMP, OPT_ENGINE, OPT_IN, OPT_OUT, OPT_ASN1PARSE, OPT_HEXDUMP,
OPT_RAW, OPT_OAEP, OPT_SSL, OPT_PKCS, OPT_X931, OPT_RAW, OPT_OAEP, OPT_SSL, OPT_PKCS, OPT_X931,
OPT_SIGN, OPT_VERIFY, OPT_REV, OPT_ENCRYPT, OPT_DECRYPT, 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; } OPTION_CHOICE;
const OPTIONS rsautl_options[] = { const OPTIONS rsautl_options[] = {
...@@ -57,6 +58,7 @@ const OPTIONS rsautl_options[] = { ...@@ -57,6 +58,7 @@ const OPTIONS rsautl_options[] = {
{"encrypt", OPT_ENCRYPT, '-', "Encrypt with public key"}, {"encrypt", OPT_ENCRYPT, '-', "Encrypt with public key"},
{"decrypt", OPT_DECRYPT, '-', "Decrypt with private key"}, {"decrypt", OPT_DECRYPT, '-', "Decrypt with private key"},
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"}, {"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
OPT_R_OPTIONS,
# ifndef OPENSSL_NO_ENGINE # ifndef OPENSSL_NO_ENGINE
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
# endif # endif
...@@ -153,6 +155,10 @@ int rsautl_main(int argc, char **argv) ...@@ -153,6 +155,10 @@ int rsautl_main(int argc, char **argv)
case OPT_PASSIN: case OPT_PASSIN:
passinarg = opt_arg(); passinarg = opt_arg();
break; break;
case OPT_R_CASES:
if (!opt_rand(o))
goto end;
break;
} }
} }
argc = opt_num_rest(); argc = opt_num_rest();
...@@ -169,9 +175,6 @@ int rsautl_main(int argc, char **argv) ...@@ -169,9 +175,6 @@ int rsautl_main(int argc, char **argv)
goto end; goto end;
} }
/* FIXME: seed PRNG only if needed */
app_RAND_load_file(NULL, 0);
switch (key_type) { switch (key_type) {
case KEY_PRIVKEY: case KEY_PRIVKEY:
pkey = load_key(keyfile, keyformat, 0, passin, e, "Private Key"); pkey = load_key(keyfile, keyformat, 0, passin, e, "Private Key");
......
...@@ -572,7 +572,7 @@ typedef enum OPTION_choice { ...@@ -572,7 +572,7 @@ typedef enum OPTION_choice {
OPT_CERT, OPT_CRL, OPT_CRL_DOWNLOAD, OPT_SESS_OUT, OPT_SESS_IN, OPT_CERT, OPT_CRL, OPT_CRL_DOWNLOAD, OPT_SESS_OUT, OPT_SESS_IN,
OPT_CERTFORM, OPT_CRLFORM, OPT_VERIFY_RET_ERROR, OPT_VERIFY_QUIET, OPT_CERTFORM, OPT_CRLFORM, OPT_VERIFY_RET_ERROR, OPT_VERIFY_QUIET,
OPT_BRIEF, OPT_PREXIT, OPT_CRLF, OPT_QUIET, OPT_NBIO, OPT_BRIEF, OPT_PREXIT, OPT_CRLF, OPT_QUIET, OPT_NBIO,
OPT_SSL_CLIENT_ENGINE, OPT_RAND, OPT_IGN_EOF, OPT_NO_IGN_EOF, OPT_SSL_CLIENT_ENGINE, OPT_IGN_EOF, OPT_NO_IGN_EOF,
OPT_DEBUG, OPT_TLSEXTDEBUG, OPT_STATUS, OPT_WDEBUG, OPT_DEBUG, OPT_TLSEXTDEBUG, OPT_STATUS, OPT_WDEBUG,
OPT_MSG, OPT_MSGFILE, OPT_ENGINE, OPT_TRACE, OPT_SECURITY_DEBUG, OPT_MSG, OPT_MSGFILE, OPT_ENGINE, OPT_TRACE, OPT_SECURITY_DEBUG,
OPT_SECURITY_DEBUG_VERBOSE, OPT_SHOWCERTS, OPT_NBIO_TEST, OPT_STATE, OPT_SECURITY_DEBUG_VERBOSE, OPT_SHOWCERTS, OPT_NBIO_TEST, OPT_STATE,
...@@ -598,7 +598,8 @@ typedef enum OPTION_choice { ...@@ -598,7 +598,8 @@ typedef enum OPTION_choice {
#ifndef OPENSSL_NO_CT #ifndef OPENSSL_NO_CT
OPT_CT, OPT_NOCT, OPT_CTLOG_FILE, OPT_CT, OPT_NOCT, OPT_CTLOG_FILE,
#endif #endif
OPT_DANE_TLSA_RRDATA, OPT_DANE_EE_NO_NAME OPT_DANE_TLSA_RRDATA, OPT_DANE_EE_NO_NAME,
OPT_R_ENUM
} OPTION_CHOICE; } OPTION_CHOICE;
const OPTIONS s_client_options[] = { const OPTIONS s_client_options[] = {
...@@ -654,8 +655,7 @@ const OPTIONS s_client_options[] = { ...@@ -654,8 +655,7 @@ const OPTIONS s_client_options[] = {
"Use the appropriate STARTTLS command before starting TLS"}, "Use the appropriate STARTTLS command before starting TLS"},
{"xmpphost", OPT_XMPPHOST, 's', {"xmpphost", OPT_XMPPHOST, 's',
"Host to use with \"-starttls xmpp[-server]\""}, "Host to use with \"-starttls xmpp[-server]\""},
{"rand", OPT_RAND, 's', OPT_R_OPTIONS,
"Load the file(s) into the random number generator"},
{"sess_out", OPT_SESS_OUT, '>', "File to write SSL session to"}, {"sess_out", OPT_SESS_OUT, '>', "File to write SSL session to"},
{"sess_in", OPT_SESS_IN, '<', "File to read SSL session from"}, {"sess_in", OPT_SESS_IN, '<', "File to read SSL session from"},
{"use_srtp", OPT_USE_SRTP, 's', {"use_srtp", OPT_USE_SRTP, 's',
...@@ -881,7 +881,6 @@ int s_client_main(int argc, char **argv) ...@@ -881,7 +881,6 @@ int s_client_main(int argc, char **argv)
char *cert_file = NULL, *key_file = NULL, *chain_file = NULL; char *cert_file = NULL, *key_file = NULL, *chain_file = NULL;
char *chCApath = NULL, *chCAfile = NULL, *host = NULL; char *chCApath = NULL, *chCAfile = NULL, *host = NULL;
char *port = OPENSSL_strdup(PORT); char *port = OPENSSL_strdup(PORT);
char *inrand = NULL;
char *passarg = NULL, *pass = NULL, *vfyCApath = NULL, *vfyCAfile = NULL; char *passarg = NULL, *pass = NULL, *vfyCApath = NULL, *vfyCAfile = NULL;
char *ReqCAfile = NULL; char *ReqCAfile = NULL;
char *sess_in = NULL, *crl_file = NULL, *p; char *sess_in = NULL, *crl_file = NULL, *p;
...@@ -905,7 +904,6 @@ int s_client_main(int argc, char **argv) ...@@ -905,7 +904,6 @@ int s_client_main(int argc, char **argv)
#endif #endif
int read_buf_len = 0; int read_buf_len = 0;
int fallback_scsv = 0; int fallback_scsv = 0;
long randamt = 0;
OPTION_CHOICE o; OPTION_CHOICE o;
#ifndef OPENSSL_NO_DTLS #ifndef OPENSSL_NO_DTLS
int enable_timeouts = 0; int enable_timeouts = 0;
...@@ -1152,8 +1150,9 @@ int s_client_main(int argc, char **argv) ...@@ -1152,8 +1150,9 @@ int s_client_main(int argc, char **argv)
} }
#endif #endif
break; break;
case OPT_RAND: case OPT_R_CASES:
inrand = opt_arg(); if (!opt_rand(o))
goto end;
break; break;
case OPT_IGN_EOF: case OPT_IGN_EOF:
c_ign_eof = 1; c_ign_eof = 1;
...@@ -1604,16 +1603,6 @@ int s_client_main(int argc, char **argv) ...@@ -1604,16 +1603,6 @@ int s_client_main(int argc, char **argv)
if (!load_excert(&exc)) if (!load_excert(&exc))
goto end; goto end;
if (!app_RAND_load_file(NULL, 1) && inrand == NULL
&& !RAND_status()) {
BIO_printf(bio_err,
"warning, not much extra random data, consider using the -rand option\n");
}
if (inrand != NULL) {
randamt = app_RAND_load_files(inrand);
BIO_printf(bio_err, "%ld semi-random bytes loaded\n", randamt);
}
if (bio_c_out == NULL) { if (bio_c_out == NULL) {
if (c_quiet && !c_debug) { if (c_quiet && !c_debug) {
bio_c_out = BIO_new(BIO_s_null()); bio_c_out = BIO_new(BIO_s_null());
......
...@@ -745,10 +745,11 @@ typedef enum OPTION_choice { ...@@ -745,10 +745,11 @@ typedef enum OPTION_choice {
OPT_MAX_SEND_FRAG, OPT_SPLIT_SEND_FRAG, OPT_MAX_PIPELINES, OPT_READ_BUF, OPT_MAX_SEND_FRAG, OPT_SPLIT_SEND_FRAG, OPT_MAX_PIPELINES, OPT_READ_BUF,
OPT_SSL3, OPT_TLS1_3, OPT_TLS1_2, OPT_TLS1_1, OPT_TLS1, OPT_DTLS, OPT_DTLS1, OPT_SSL3, OPT_TLS1_3, OPT_TLS1_2, OPT_TLS1_1, OPT_TLS1, OPT_DTLS, OPT_DTLS1,
OPT_DTLS1_2, OPT_SCTP, OPT_TIMEOUT, OPT_MTU, OPT_LISTEN, OPT_DTLS1_2, OPT_SCTP, OPT_TIMEOUT, OPT_MTU, OPT_LISTEN,
OPT_ID_PREFIX, OPT_RAND, OPT_SERVERNAME, OPT_SERVERNAME_FATAL, OPT_ID_PREFIX, OPT_SERVERNAME, OPT_SERVERNAME_FATAL,
OPT_CERT2, OPT_KEY2, OPT_NEXTPROTONEG, OPT_ALPN, OPT_CERT2, OPT_KEY2, OPT_NEXTPROTONEG, OPT_ALPN,
OPT_SRTP_PROFILES, OPT_KEYMATEXPORT, OPT_KEYMATEXPORTLEN, OPT_SRTP_PROFILES, OPT_KEYMATEXPORT, OPT_KEYMATEXPORTLEN,
OPT_KEYLOG_FILE, OPT_MAX_EARLY, OPT_EARLY_DATA, OPT_KEYLOG_FILE, OPT_MAX_EARLY, OPT_EARLY_DATA,
OPT_R_ENUM,
OPT_S_ENUM, OPT_S_ENUM,
OPT_V_ENUM, OPT_V_ENUM,
OPT_X_ENUM OPT_X_ENUM
...@@ -825,8 +826,7 @@ const OPTIONS s_server_options[] = { ...@@ -825,8 +826,7 @@ const OPTIONS s_server_options[] = {
{"HTTP", OPT_HTTP, '-', "Like -WWW but ./path includes HTTP headers"}, {"HTTP", OPT_HTTP, '-', "Like -WWW but ./path includes HTTP headers"},
{"id_prefix", OPT_ID_PREFIX, 's', {"id_prefix", OPT_ID_PREFIX, 's',
"Generate SSL/TLS session IDs prefixed by arg"}, "Generate SSL/TLS session IDs prefixed by arg"},
{"rand", OPT_RAND, 's', OPT_R_OPTIONS,
"Load the file(s) into the random number generator"},
{"keymatexport", OPT_KEYMATEXPORT, 's', {"keymatexport", OPT_KEYMATEXPORT, 's',
"Export keying material using label"}, "Export keying material using label"},
{"keymatexportlen", OPT_KEYMATEXPORTLEN, 'p', {"keymatexportlen", OPT_KEYMATEXPORTLEN, 'p',
...@@ -974,7 +974,7 @@ int s_server_main(int argc, char *argv[]) ...@@ -974,7 +974,7 @@ int s_server_main(int argc, char *argv[])
X509 *s_cert = NULL, *s_dcert = NULL; X509 *s_cert = NULL, *s_dcert = NULL;
X509_VERIFY_PARAM *vpm = NULL; X509_VERIFY_PARAM *vpm = NULL;
const char *CApath = NULL, *CAfile = NULL, *chCApath = NULL, *chCAfile = NULL; const char *CApath = NULL, *CAfile = NULL, *chCApath = NULL, *chCAfile = NULL;
char *dpassarg = NULL, *dpass = NULL, *inrand = NULL; char *dpassarg = NULL, *dpass = NULL;
char *passarg = NULL, *pass = NULL, *vfyCApath = NULL, *vfyCAfile = NULL; char *passarg = NULL, *pass = NULL, *vfyCApath = NULL, *vfyCAfile = NULL;
char *crl_file = NULL, *prog; char *crl_file = NULL, *prog;
#ifdef AF_UNIX #ifdef AF_UNIX
...@@ -1494,8 +1494,9 @@ int s_server_main(int argc, char *argv[]) ...@@ -1494,8 +1494,9 @@ int s_server_main(int argc, char *argv[])
case OPT_ENGINE: case OPT_ENGINE:
engine = setup_engine(opt_arg(), 1); engine = setup_engine(opt_arg(), 1);
break; break;
case OPT_RAND: case OPT_R_CASES:
inrand = opt_arg(); if (!opt_rand(o))
goto end;
break; break;
case OPT_SERVERNAME: case OPT_SERVERNAME:
tlsextcbp.servername = opt_arg(); tlsextcbp.servername = opt_arg();
...@@ -1708,15 +1709,6 @@ int s_server_main(int argc, char *argv[]) ...@@ -1708,15 +1709,6 @@ int s_server_main(int argc, char *argv[])
} }
if (!app_RAND_load_file(NULL, 1) && inrand == NULL
&& !RAND_status()) {
BIO_printf(bio_err,
"warning, not much extra random data, consider using the -rand option\n");
}
if (inrand != NULL)
BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
app_RAND_load_files(inrand));
if (bio_s_out == NULL) { if (bio_s_out == NULL) {
if (s_quiet && !s_debug) { if (s_quiet && !s_debug) {
bio_s_out = BIO_new(BIO_s_null()); bio_s_out = BIO_new(BIO_s_null());
......
...@@ -37,9 +37,10 @@ typedef enum OPTION_choice { ...@@ -37,9 +37,10 @@ typedef enum OPTION_choice {
OPT_PK7OUT, OPT_TEXT, OPT_NOINTERN, OPT_NOVERIFY, OPT_NOCHAIN, OPT_PK7OUT, OPT_TEXT, OPT_NOINTERN, OPT_NOVERIFY, OPT_NOCHAIN,
OPT_NOCERTS, OPT_NOATTR, OPT_NODETACH, OPT_NOSMIMECAP, OPT_NOCERTS, OPT_NOATTR, OPT_NODETACH, OPT_NOSMIMECAP,
OPT_BINARY, OPT_NOSIGS, OPT_STREAM, OPT_INDEF, OPT_NOINDEF, OPT_BINARY, OPT_NOSIGS, OPT_STREAM, OPT_INDEF, OPT_NOINDEF,
OPT_CRLFEOL, OPT_RAND, OPT_ENGINE, OPT_PASSIN, OPT_CRLFEOL, OPT_ENGINE, OPT_PASSIN,
OPT_TO, OPT_FROM, OPT_SUBJECT, OPT_SIGNER, OPT_RECIP, OPT_MD, OPT_TO, OPT_FROM, OPT_SUBJECT, OPT_SIGNER, OPT_RECIP, OPT_MD,
OPT_CIPHER, OPT_INKEY, OPT_KEYFORM, OPT_CERTFILE, OPT_CAFILE, OPT_CIPHER, OPT_INKEY, OPT_KEYFORM, OPT_CERTFILE, OPT_CAFILE,
OPT_R_ENUM,
OPT_V_ENUM, OPT_V_ENUM,
OPT_CAPATH, OPT_NOCAFILE, OPT_NOCAPATH, OPT_IN, OPT_INFORM, OPT_OUT, OPT_CAPATH, OPT_NOCAFILE, OPT_NOCAPATH, OPT_IN, OPT_INFORM, OPT_OUT,
OPT_OUTFORM, OPT_CONTENT OPT_OUTFORM, OPT_CONTENT
...@@ -96,8 +97,7 @@ const OPTIONS smime_options[] = { ...@@ -96,8 +97,7 @@ const OPTIONS smime_options[] = {
{"indef", OPT_INDEF, '-', "Same as -stream" }, {"indef", OPT_INDEF, '-', "Same as -stream" },
{"noindef", OPT_NOINDEF, '-', "Disable CMS streaming"}, {"noindef", OPT_NOINDEF, '-', "Disable CMS streaming"},
{"crlfeol", OPT_CRLFEOL, '-', "Use CRLF as EOL termination instead of CR only"}, {"crlfeol", OPT_CRLFEOL, '-', "Use CRLF as EOL termination instead of CR only"},
{"rand", OPT_RAND, 's', OPT_R_OPTIONS,
"Load the file(s) into the random number generator"},
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"}, {"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
{"md", OPT_MD, 's', "Digest algorithm to use when signing or resigning"}, {"md", OPT_MD, 's', "Digest algorithm to use when signing or resigning"},
{"", OPT_CIPHER, '-', "Any supported cipher"}, {"", OPT_CIPHER, '-', "Any supported cipher"},
...@@ -121,15 +121,12 @@ int smime_main(int argc, char **argv) ...@@ -121,15 +121,12 @@ int smime_main(int argc, char **argv)
const EVP_CIPHER *cipher = NULL; const EVP_CIPHER *cipher = NULL;
const EVP_MD *sign_md = NULL; const EVP_MD *sign_md = NULL;
const char *CAfile = NULL, *CApath = NULL, *prog = NULL; const char *CAfile = NULL, *CApath = NULL, *prog = NULL;
char *certfile = NULL, *keyfile = NULL, *contfile = NULL, *inrand = NULL; char *certfile = NULL, *keyfile = NULL, *contfile = NULL;
char *infile = NULL, *outfile = NULL, *signerfile = NULL, *recipfile = char *infile = NULL, *outfile = NULL, *signerfile = NULL, *recipfile = NULL;
NULL; char *passinarg = NULL, *passin = NULL, *to = NULL, *from = NULL, *subject = NULL;
char *passinarg = NULL, *passin = NULL, *to = NULL, *from =
NULL, *subject = NULL;
OPTION_CHOICE o; OPTION_CHOICE o;
int noCApath = 0, noCAfile = 0; int noCApath = 0, noCAfile = 0;
int flags = PKCS7_DETACHED, operation = 0, ret = 0, need_rand = 0, indef = int flags = PKCS7_DETACHED, operation = 0, ret = 0, indef = 0;
0;
int informat = FORMAT_SMIME, outformat = FORMAT_SMIME, keyform = int informat = FORMAT_SMIME, outformat = FORMAT_SMIME, keyform =
FORMAT_PEM; FORMAT_PEM;
int vpmtouched = 0, rv = 0; int vpmtouched = 0, rv = 0;
...@@ -224,9 +221,9 @@ int smime_main(int argc, char **argv) ...@@ -224,9 +221,9 @@ int smime_main(int argc, char **argv)
flags |= PKCS7_CRLFEOL; flags |= PKCS7_CRLFEOL;
mime_eol = "\r\n"; mime_eol = "\r\n";
break; break;
case OPT_RAND: case OPT_R_CASES:
inrand = opt_arg(); if (!opt_rand(o))
need_rand = 1; goto end;
break; break;
case OPT_ENGINE: case OPT_ENGINE:
e = setup_engine(opt_arg(), 0); e = setup_engine(opt_arg(), 0);
...@@ -351,7 +348,6 @@ int smime_main(int argc, char **argv) ...@@ -351,7 +348,6 @@ int smime_main(int argc, char **argv)
} }
signerfile = NULL; signerfile = NULL;
keyfile = NULL; keyfile = NULL;
need_rand = 1;
} else if (operation == SMIME_DECRYPT) { } else if (operation == SMIME_DECRYPT) {
if (recipfile == NULL && keyfile == NULL) { if (recipfile == NULL && keyfile == NULL) {
BIO_printf(bio_err, BIO_printf(bio_err,
...@@ -363,7 +359,6 @@ int smime_main(int argc, char **argv) ...@@ -363,7 +359,6 @@ int smime_main(int argc, char **argv)
BIO_printf(bio_err, "No recipient(s) certificate(s) specified\n"); BIO_printf(bio_err, "No recipient(s) certificate(s) specified\n");
goto opthelp; goto opthelp;
} }
need_rand = 1;
} else if (!operation) { } else if (!operation) {
goto opthelp; goto opthelp;
} }
...@@ -373,13 +368,6 @@ int smime_main(int argc, char **argv) ...@@ -373,13 +368,6 @@ int smime_main(int argc, char **argv)
goto end; goto end;
} }
if (need_rand) {
app_RAND_load_file(NULL, (inrand != NULL));
if (inrand != NULL)
BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
app_RAND_load_files(inrand));
}
ret = 2; ret = 2;
if (!(operation & SMIME_SIGNERS)) if (!(operation & SMIME_SIGNERS))
...@@ -603,8 +591,6 @@ int smime_main(int argc, char **argv) ...@@ -603,8 +591,6 @@ int smime_main(int argc, char **argv)
} }
ret = 0; ret = 0;
end: end:
if (need_rand)
app_RAND_write_file(NULL);
if (ret) if (ret)
ERR_print_errors(bio_err); ERR_print_errors(bio_err);
sk_X509_pop_free(encerts, X509_free); sk_X509_pop_free(encerts, X509_free);
......
...@@ -342,7 +342,7 @@ static int found(const char *name, const OPT_PAIR *pairs, int *result) ...@@ -342,7 +342,7 @@ static int found(const char *name, const OPT_PAIR *pairs, int *result)
typedef enum OPTION_choice { typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
OPT_ELAPSED, OPT_EVP, OPT_DECRYPT, OPT_ENGINE, OPT_MULTI, OPT_ELAPSED, OPT_EVP, OPT_DECRYPT, OPT_ENGINE, OPT_MULTI,
OPT_MR, OPT_MB, OPT_MISALIGN, OPT_ASYNCJOBS OPT_MR, OPT_MB, OPT_MISALIGN, OPT_ASYNCJOBS, OPT_R_ENUM,
} OPTION_CHOICE; } OPTION_CHOICE;
const OPTIONS speed_options[] = { const OPTIONS speed_options[] = {
...@@ -365,6 +365,7 @@ const OPTIONS speed_options[] = { ...@@ -365,6 +365,7 @@ const OPTIONS speed_options[] = {
{"async_jobs", OPT_ASYNCJOBS, 'p', {"async_jobs", OPT_ASYNCJOBS, 'p',
"Enable async mode and start pnum jobs"}, "Enable async mode and start pnum jobs"},
#endif #endif
OPT_R_OPTIONS,
#ifndef OPENSSL_NO_ENGINE #ifndef OPENSSL_NO_ENGINE
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
#endif #endif
...@@ -1410,6 +1411,10 @@ int speed_main(int argc, char **argv) ...@@ -1410,6 +1411,10 @@ int speed_main(int argc, char **argv)
goto end; goto end;
#endif #endif
break; break;
case OPT_R_CASES:
if (!opt_rand(o))
goto end;
break;
} }
} }
argc = opt_num_rest(); argc = opt_num_rest();
......
...@@ -26,7 +26,6 @@ NON_EMPTY_TRANSLATION_UNIT ...@@ -26,7 +26,6 @@ NON_EMPTY_TRANSLATION_UNIT
# define BASE_SECTION "srp" # define BASE_SECTION "srp"
# define CONFIG_FILE "openssl.cnf" # define CONFIG_FILE "openssl.cnf"
# define ENV_RANDFILE "RANDFILE"
# define ENV_DATABASE "srpvfile" # define ENV_DATABASE "srpvfile"
# define ENV_DEFAULT_SRP "default_srp" # define ENV_DEFAULT_SRP "default_srp"
...@@ -189,7 +188,7 @@ typedef enum OPTION_choice { ...@@ -189,7 +188,7 @@ typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
OPT_VERBOSE, OPT_CONFIG, OPT_NAME, OPT_SRPVFILE, OPT_ADD, OPT_VERBOSE, OPT_CONFIG, OPT_NAME, OPT_SRPVFILE, OPT_ADD,
OPT_DELETE, OPT_MODIFY, OPT_LIST, OPT_GN, OPT_USERINFO, OPT_DELETE, OPT_MODIFY, OPT_LIST, OPT_GN, OPT_USERINFO,
OPT_PASSIN, OPT_PASSOUT, OPT_ENGINE OPT_PASSIN, OPT_PASSOUT, OPT_ENGINE, OPT_R_ENUM,
} OPTION_CHOICE; } OPTION_CHOICE;
const OPTIONS srp_options[] = { const OPTIONS srp_options[] = {
...@@ -207,6 +206,7 @@ const OPTIONS srp_options[] = { ...@@ -207,6 +206,7 @@ const OPTIONS srp_options[] = {
{"userinfo", OPT_USERINFO, 's', "Additional info to be set for user"}, {"userinfo", OPT_USERINFO, 's', "Additional info to be set for user"},
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"}, {"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"}, {"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
OPT_R_OPTIONS,
# ifndef OPENSSL_NO_ENGINE # ifndef OPENSSL_NO_ENGINE
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
# endif # endif
...@@ -222,7 +222,7 @@ int srp_main(int argc, char **argv) ...@@ -222,7 +222,7 @@ int srp_main(int argc, char **argv)
int doupdatedb = 0, mode = OPT_ERR; int doupdatedb = 0, mode = OPT_ERR;
char *user = NULL, *passinarg = NULL, *passoutarg = NULL; char *user = NULL, *passinarg = NULL, *passoutarg = NULL;
char *passin = NULL, *passout = NULL, *gN = NULL, *userinfo = NULL; char *passin = NULL, *passout = NULL, *gN = NULL, *userinfo = NULL;
char *randfile = NULL, *section = NULL; char *section = NULL;
char **gNrow = NULL, *configfile = NULL; char **gNrow = NULL, *configfile = NULL;
char *srpvfile = NULL, **pp, *prog; char *srpvfile = NULL, **pp, *prog;
OPTION_CHOICE o; OPTION_CHOICE o;
...@@ -278,6 +278,10 @@ int srp_main(int argc, char **argv) ...@@ -278,6 +278,10 @@ int srp_main(int argc, char **argv)
case OPT_ENGINE: case OPT_ENGINE:
e = setup_engine(opt_arg(), 0); e = setup_engine(opt_arg(), 0);
break; break;
case OPT_R_CASES:
if (!opt_rand(o))
goto end;
break;
} }
} }
argc = opt_num_rest(); argc = opt_num_rest();
...@@ -335,8 +339,7 @@ int srp_main(int argc, char **argv) ...@@ -335,8 +339,7 @@ int srp_main(int argc, char **argv)
goto end; goto end;
} }
if (randfile == NULL) app_RAND_load_conf(conf, BASE_SECTION);
randfile = NCONF_get_string(conf, BASE_SECTION, "RANDFILE");
if (verbose) if (verbose)
BIO_printf(bio_err, BIO_printf(bio_err,
...@@ -347,10 +350,6 @@ int srp_main(int argc, char **argv) ...@@ -347,10 +350,6 @@ int srp_main(int argc, char **argv)
if (srpvfile == NULL) if (srpvfile == NULL)
goto end; goto end;
} }
if (randfile == NULL)
ERR_clear_error();
else
app_RAND_load_file(randfile, 0);
if (verbose) if (verbose)
BIO_printf(bio_err, "Trying to read SRP verifier file \"%s\"\n", BIO_printf(bio_err, "Trying to read SRP verifier file \"%s\"\n",
...@@ -604,8 +603,6 @@ int srp_main(int argc, char **argv) ...@@ -604,8 +603,6 @@ int srp_main(int argc, char **argv)
OPENSSL_free(passout); OPENSSL_free(passout);
if (ret) if (ret)
ERR_print_errors(bio_err); ERR_print_errors(bio_err);
if (randfile != NULL)
app_RAND_write_file(randfile);
NCONF_free(conf); NCONF_free(conf);
free_index(db); free_index(db);
release_engine(e); release_engine(e);
......
...@@ -79,11 +79,11 @@ static int verify_cb(int ok, X509_STORE_CTX *ctx); ...@@ -79,11 +79,11 @@ static int verify_cb(int ok, X509_STORE_CTX *ctx);
typedef enum OPTION_choice { typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
OPT_ENGINE, OPT_CONFIG, OPT_SECTION, OPT_QUERY, OPT_DATA, OPT_ENGINE, OPT_CONFIG, OPT_SECTION, OPT_QUERY, OPT_DATA,
OPT_DIGEST, OPT_RAND, OPT_TSPOLICY, OPT_NO_NONCE, OPT_CERT, OPT_DIGEST, OPT_TSPOLICY, OPT_NO_NONCE, OPT_CERT,
OPT_IN, OPT_TOKEN_IN, OPT_OUT, OPT_TOKEN_OUT, OPT_TEXT, OPT_IN, OPT_TOKEN_IN, OPT_OUT, OPT_TOKEN_OUT, OPT_TEXT,
OPT_REPLY, OPT_QUERYFILE, OPT_PASSIN, OPT_INKEY, OPT_SIGNER, OPT_REPLY, OPT_QUERYFILE, OPT_PASSIN, OPT_INKEY, OPT_SIGNER,
OPT_CHAIN, OPT_VERIFY, OPT_CAPATH, OPT_CAFILE, OPT_UNTRUSTED, OPT_CHAIN, OPT_VERIFY, OPT_CAPATH, OPT_CAFILE, OPT_UNTRUSTED,
OPT_MD, OPT_V_ENUM OPT_MD, OPT_V_ENUM, OPT_R_ENUM
} OPTION_CHOICE; } OPTION_CHOICE;
const OPTIONS ts_options[] = { const OPTIONS ts_options[] = {
...@@ -93,8 +93,7 @@ const OPTIONS ts_options[] = { ...@@ -93,8 +93,7 @@ const OPTIONS ts_options[] = {
{"query", OPT_QUERY, '-', "Generate a TS query"}, {"query", OPT_QUERY, '-', "Generate a TS query"},
{"data", OPT_DATA, '<', "File to hash"}, {"data", OPT_DATA, '<', "File to hash"},
{"digest", OPT_DIGEST, 's', "Digest (as a hex string)"}, {"digest", OPT_DIGEST, 's', "Digest (as a hex string)"},
{"rand", OPT_RAND, 's', OPT_R_OPTIONS,
"Load the file(s) into the random number generator"},
{"tspolicy", OPT_TSPOLICY, 's', "Policy OID to use"}, {"tspolicy", OPT_TSPOLICY, 's', "Policy OID to use"},
{"no_nonce", OPT_NO_NONCE, '-', "Do not include a nonce"}, {"no_nonce", OPT_NO_NONCE, '-', "Do not include a nonce"},
{"cert", OPT_CERT, '-', "Put cert request into query"}, {"cert", OPT_CERT, '-', "Put cert request into query"},
...@@ -158,7 +157,7 @@ int ts_main(int argc, char **argv) ...@@ -158,7 +157,7 @@ int ts_main(int argc, char **argv)
const char *section = NULL; const char *section = NULL;
char **helpp; char **helpp;
char *password = NULL; char *password = NULL;
char *data = NULL, *digest = NULL, *rnd = NULL, *policy = NULL; char *data = NULL, *digest = NULL, *policy = NULL;
char *in = NULL, *out = NULL, *queryfile = NULL, *passin = NULL; char *in = NULL, *out = NULL, *queryfile = NULL, *passin = NULL;
char *inkey = NULL, *signer = NULL, *chain = NULL, *CApath = NULL; char *inkey = NULL, *signer = NULL, *chain = NULL, *CApath = NULL;
const EVP_MD *md = NULL; const EVP_MD *md = NULL;
...@@ -207,8 +206,9 @@ int ts_main(int argc, char **argv) ...@@ -207,8 +206,9 @@ int ts_main(int argc, char **argv)
case OPT_DIGEST: case OPT_DIGEST:
digest = opt_arg(); digest = opt_arg();
break; break;
case OPT_RAND: case OPT_R_CASES:
rnd = opt_arg(); if (!opt_rand(o))
goto end;
break; break;
case OPT_TSPOLICY: case OPT_TSPOLICY:
policy = opt_arg(); policy = opt_arg();
...@@ -275,16 +275,6 @@ int ts_main(int argc, char **argv) ...@@ -275,16 +275,6 @@ int ts_main(int argc, char **argv)
if (mode == OPT_ERR || opt_num_rest() != 0) if (mode == OPT_ERR || opt_num_rest() != 0)
goto opthelp; goto opthelp;
/* Seed the random number generator if it is going to be used. */
if (mode == OPT_QUERY && !no_nonce) {
if (!app_RAND_load_file(NULL, 1) && rnd == NULL)
BIO_printf(bio_err, "warning, not much extra random "
"data, consider using the -rand option\n");
if (rnd != NULL)
BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
app_RAND_load_files(rnd));
}
if (mode == OPT_REPLY && passin && if (mode == OPT_REPLY && passin &&
!app_passwd(passin, NULL, &password, NULL)) { !app_passwd(passin, NULL, &password, NULL)) {
BIO_printf(bio_err, "Error getting password.\n"); BIO_printf(bio_err, "Error getting password.\n");
...@@ -328,7 +318,6 @@ int ts_main(int argc, char **argv) ...@@ -328,7 +318,6 @@ int ts_main(int argc, char **argv)
end: end:
X509_VERIFY_PARAM_free(vpm); X509_VERIFY_PARAM_free(vpm);
app_RAND_write_file(NULL);
NCONF_free(conf); NCONF_free(conf);
OPENSSL_free(password); OPENSSL_free(password);
return (ret); return (ret);
......
...@@ -58,7 +58,8 @@ typedef enum OPTION_choice { ...@@ -58,7 +58,8 @@ typedef enum OPTION_choice {
OPT_CLRREJECT, OPT_ALIAS, OPT_CACREATESERIAL, OPT_CLREXT, OPT_OCSPID, OPT_CLRREJECT, OPT_ALIAS, OPT_CACREATESERIAL, OPT_CLREXT, OPT_OCSPID,
OPT_SUBJECT_HASH_OLD, OPT_SUBJECT_HASH_OLD,
OPT_ISSUER_HASH_OLD, OPT_ISSUER_HASH_OLD,
OPT_BADSIG, OPT_MD, OPT_ENGINE, OPT_NOCERT, OPT_PRESERVE_DATES OPT_BADSIG, OPT_MD, OPT_ENGINE, OPT_NOCERT, OPT_PRESERVE_DATES,
OPT_R_ENUM
} OPTION_CHOICE; } OPTION_CHOICE;
const OPTIONS x509_options[] = { const OPTIONS x509_options[] = {
...@@ -118,6 +119,7 @@ const OPTIONS x509_options[] = { ...@@ -118,6 +119,7 @@ const OPTIONS x509_options[] = {
{"text", OPT_TEXT, '-', "Print the certificate in text form"}, {"text", OPT_TEXT, '-', "Print the certificate in text form"},
{"C", OPT_C, '-', "Print out C code forms"}, {"C", OPT_C, '-', "Print out C code forms"},
{"extfile", OPT_EXTFILE, '<', "File with X509V3 extensions to add"}, {"extfile", OPT_EXTFILE, '<', "File with X509V3 extensions to add"},
OPT_R_OPTIONS,
{"extensions", OPT_EXTENSIONS, 's', "Section from config file to use"}, {"extensions", OPT_EXTENSIONS, 's', "Section from config file to use"},
{"nameopt", OPT_NAMEOPT, 's', "Various certificate name options"}, {"nameopt", OPT_NAMEOPT, 's', "Various certificate name options"},
{"certopt", OPT_CERTOPT, 's', "Various certificate text options"}, {"certopt", OPT_CERTOPT, 's', "Various certificate text options"},
...@@ -166,7 +168,7 @@ int x509_main(int argc, char **argv) ...@@ -166,7 +168,7 @@ int x509_main(int argc, char **argv)
char *prog; char *prog;
int x509req = 0, days = DEF_DAYS, modulus = 0, pubkey = 0, pprint = 0; int x509req = 0, days = DEF_DAYS, modulus = 0, pubkey = 0, pprint = 0;
int C = 0, CAformat = FORMAT_PEM, CAkeyformat = FORMAT_PEM; int C = 0, CAformat = FORMAT_PEM, CAkeyformat = FORMAT_PEM;
int fingerprint = 0, reqfile = 0, need_rand = 0, checkend = 0; int fingerprint = 0, reqfile = 0, checkend = 0;
int informat = FORMAT_PEM, outformat = FORMAT_PEM, keyformat = FORMAT_PEM; int informat = FORMAT_PEM, outformat = FORMAT_PEM, keyformat = FORMAT_PEM;
int next_serial = 0, subject_hash = 0, issuer_hash = 0, ocspid = 0; int next_serial = 0, subject_hash = 0, issuer_hash = 0, ocspid = 0;
int noout = 0, sign_flag = 0, CA_flag = 0, CA_createserial = 0, email = 0; int noout = 0, sign_flag = 0, CA_flag = 0, CA_createserial = 0, email = 0;
...@@ -227,7 +229,7 @@ int x509_main(int argc, char **argv) ...@@ -227,7 +229,7 @@ int x509_main(int argc, char **argv)
outfile = opt_arg(); outfile = opt_arg();
break; break;
case OPT_REQ: case OPT_REQ:
reqfile = need_rand = 1; reqfile = 1;
break; break;
case OPT_SIGOPT: case OPT_SIGOPT:
...@@ -247,18 +249,20 @@ int x509_main(int argc, char **argv) ...@@ -247,18 +249,20 @@ int x509_main(int argc, char **argv)
case OPT_EXTFILE: case OPT_EXTFILE:
extfile = opt_arg(); extfile = opt_arg();
break; break;
case OPT_R_CASES:
if (!opt_rand(o))
goto end;
break;
case OPT_EXTENSIONS: case OPT_EXTENSIONS:
extsect = opt_arg(); extsect = opt_arg();
break; break;
case OPT_SIGNKEY: case OPT_SIGNKEY:
keyfile = opt_arg(); keyfile = opt_arg();
sign_flag = ++num; sign_flag = ++num;
need_rand = 1;
break; break;
case OPT_CA: case OPT_CA:
CAfile = opt_arg(); CAfile = opt_arg();
CA_flag = ++num; CA_flag = ++num;
need_rand = 1;
break; break;
case OPT_CAKEY: case OPT_CAKEY:
CAkeyfile = opt_arg(); CAkeyfile = opt_arg();
...@@ -460,9 +464,6 @@ int x509_main(int argc, char **argv) ...@@ -460,9 +464,6 @@ int x509_main(int argc, char **argv)
if (out == NULL) if (out == NULL)
goto end; goto end;
if (need_rand)
app_RAND_load_file(NULL, 0);
if (!app_passwd(passinarg, NULL, &passin, NULL)) { if (!app_passwd(passinarg, NULL, &passin, NULL)) {
BIO_printf(bio_err, "Error getting password\n"); BIO_printf(bio_err, "Error getting password\n");
goto end; goto end;
...@@ -793,7 +794,6 @@ int x509_main(int argc, char **argv) ...@@ -793,7 +794,6 @@ int x509_main(int argc, char **argv)
goto end; goto end;
} }
assert(need_rand);
if (!sign(x, Upkey, days, clrext, digest, extconf, extsect, preserve_dates)) if (!sign(x, Upkey, days, clrext, digest, extconf, extsect, preserve_dates))
goto end; goto end;
} else if (CA_flag == i) { } else if (CA_flag == i) {
...@@ -805,7 +805,6 @@ int x509_main(int argc, char **argv) ...@@ -805,7 +805,6 @@ int x509_main(int argc, char **argv)
goto end; goto end;
} }
assert(need_rand);
if (!x509_certify(ctx, CAfile, digest, x, xca, if (!x509_certify(ctx, CAfile, digest, x, xca,
CApkey, sigopts, CApkey, sigopts,
CAserial, CA_createserial, days, clrext, CAserial, CA_createserial, days, clrext,
...@@ -882,8 +881,6 @@ int x509_main(int argc, char **argv) ...@@ -882,8 +881,6 @@ int x509_main(int argc, char **argv)
} }
ret = 0; ret = 0;
end: end:
if (need_rand)
app_RAND_write_file(NULL);
NCONF_free(extconf); NCONF_free(extconf);
BIO_free_all(out); BIO_free_all(out);
X509_STORE_free(ctx); X509_STORE_free(ctx);
......
...@@ -175,8 +175,11 @@ int RAND_write_file(const char *file) ...@@ -175,8 +175,11 @@ int RAND_write_file(const char *file)
if (out == NULL) if (out == NULL)
out = openssl_fopen(file, "wb"); out = openssl_fopen(file, "wb");
if (out == NULL) if (out == NULL) {
RANDerr(RAND_F_RAND_LOAD_FILE, RAND_R_CANNOT_OPEN_FILE);
ERR_add_error_data(2, "Filename=", file);
return -1; return -1;
}
#if !defined(NO_CHMOD) && !defined(OPENSSL_NO_POSIX_IO) #if !defined(NO_CHMOD) && !defined(OPENSSL_NO_POSIX_IO)
/* /*
......
...@@ -52,6 +52,8 @@ B<openssl> B<ca> ...@@ -52,6 +52,8 @@ B<openssl> B<ca>
[B<-utf8>] [B<-utf8>]
[B<-create_serial>] [B<-create_serial>]
[B<-multivalue-rdn>] [B<-multivalue-rdn>]
[B<-rand file...>]
[B<-writerand file>]
=head1 DESCRIPTION =head1 DESCRIPTION
...@@ -266,6 +268,19 @@ I</DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe> ...@@ -266,6 +268,19 @@ I</DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe>
If -multi-rdn is not used then the UID value is I<123456+CN=John Doe>. If -multi-rdn is not used then the UID value is I<123456+CN=John Doe>.
=item B<-rand file...>
A file or files containing random data used to seed the random number
generator.
Multiple files can be specified separated by an OS-dependent character.
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
all others.
=item [B<-writerand file>]
Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.
=back =back
=head1 CRL OPTIONS =head1 CRL OPTIONS
...@@ -397,8 +412,8 @@ CA private key. Mandatory. ...@@ -397,8 +412,8 @@ CA private key. Mandatory.
=item B<RANDFILE> =item B<RANDFILE>
A file used to read and write random number seed information, or At startup the specified file is loaded into the random number generator,
an EGD socket (see L<RAND_egd(3)>). and at exit 256 bytes will be written to it.
=item B<default_days> =item B<default_days>
......
...@@ -92,7 +92,8 @@ B<openssl> B<cms> ...@@ -92,7 +92,8 @@ B<openssl> B<cms>
[B<-inkey file>] [B<-inkey file>]
[B<-keyopt name:parameter>] [B<-keyopt name:parameter>]
[B<-passin arg>] [B<-passin arg>]
[B<-rand file(s)>] [B<-rand file...>]
[B<-writerand file>]
[B<cert.pem...>] [B<cert.pem...>]
[B<-to addr>] [B<-to addr>]
[B<-from addr>] [B<-from addr>]
...@@ -461,14 +462,19 @@ or to modify default parameters for ECDH. ...@@ -461,14 +462,19 @@ or to modify default parameters for ECDH.
The private key password source. For more information about the format of B<arg> The private key password source. For more information about the format of B<arg>
see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)>. see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)>.
=item B<-rand file(s)> =item B<-rand file...>
A file or files containing random data used to seed the random number A file or files containing random data used to seed the random number
generator, or an EGD socket (see L<RAND_egd(3)>). generator.
Multiple files can be specified separated by an OS-dependent character. Multiple files can be specified separated by an OS-dependent character.
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
all others. all others.
=item [B<-writerand file>]
Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.
=item B<cert.pem...> =item B<cert.pem...>
One or more certificates of message recipients: used when encrypting One or more certificates of message recipients: used when encrypting
......
...@@ -23,6 +23,7 @@ B<openssl> B<dgst> ...@@ -23,6 +23,7 @@ B<openssl> B<dgst>
[B<-signature filename>] [B<-signature filename>]
[B<-hmac key>] [B<-hmac key>]
[B<-fips-fingerprint>] [B<-fips-fingerprint>]
[B<-rand file...>]
[B<-engine id>] [B<-engine id>]
[B<-engine_impl>] [B<-engine_impl>]
[B<file...>] [B<file...>]
...@@ -149,14 +150,19 @@ for example exactly 32 chars for gost-mac. ...@@ -149,14 +150,19 @@ for example exactly 32 chars for gost-mac.
=back =back
=item B<-rand file(s)> =item B<-rand file...>
A file or files containing random data used to seed the random number A file or files containing random data used to seed the random number
generator, or an EGD socket (see L<RAND_egd(3)>). generator.
Multiple files can be specified separated by an OS-dependent character. Multiple files can be specified separated by an OS-dependent character.
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
all others. all others.
=item [B<-writerand file>]
Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.
=item B<-fips-fingerprint> =item B<-fips-fingerprint>
Compute HMAC using a specific key for certain OpenSSL-FIPS operations. Compute HMAC using a specific key for certain OpenSSL-FIPS operations.
......
...@@ -19,7 +19,8 @@ B<openssl dhparam> ...@@ -19,7 +19,8 @@ B<openssl dhparam>
[B<-C>] [B<-C>]
[B<-2>] [B<-2>]
[B<-5>] [B<-5>]
[B<-rand> I<file(s)>] [B<-rand file...>]
[B<-writerand file>]
[B<-engine id>] [B<-engine id>]
[I<numbits>] [I<numbits>]
...@@ -82,14 +83,19 @@ input file is ignored and parameters are generated instead. If not ...@@ -82,14 +83,19 @@ input file is ignored and parameters are generated instead. If not
present but B<numbits> is present, parameters are generated with the present but B<numbits> is present, parameters are generated with the
default generator 2. default generator 2.
=item B<-rand> I<file(s)> =item B<-rand file...>
A file or files containing random data used to seed the random number A file or files containing random data used to seed the random number
generator, or an EGD socket (see L<RAND_egd(3)>). generator.
Multiple files can be specified separated by an OS-dependent character. Multiple files can be specified separated by an OS-dependent character.
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
all others. all others.
=item [B<-writerand file>]
Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.
=item I<numbits> =item I<numbits>
This option specifies that a parameter set should be generated of size This option specifies that a parameter set should be generated of size
......
...@@ -15,7 +15,8 @@ B<openssl dsaparam> ...@@ -15,7 +15,8 @@ B<openssl dsaparam>
[B<-noout>] [B<-noout>]
[B<-text>] [B<-text>]
[B<-C>] [B<-C>]
[B<-rand file(s)>] [B<-rand file...>]
[B<-writerand file>]
[B<-genkey>] [B<-genkey>]
[B<-engine id>] [B<-engine id>]
[B<numbits>] [B<numbits>]
...@@ -74,14 +75,19 @@ be loaded by calling the get_dsaXXX() function. ...@@ -74,14 +75,19 @@ be loaded by calling the get_dsaXXX() function.
This option will generate a DSA either using the specified or generated This option will generate a DSA either using the specified or generated
parameters. parameters.
=item B<-rand file(s)> =item B<-rand file...>
A file or files containing random data used to seed the random number A file or files containing random data used to seed the random number
generator, or an EGD socket (see L<RAND_egd(3)>). generator.
Multiple files can be specified separated by an OS-dependent character. Multiple files can be specified separated by an OS-dependent character.
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
all others. all others.
=item [B<-writerand file>]
Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.
=item B<numbits> =item B<numbits>
This option specifies that a parameter set should be generated of size This option specifies that a parameter set should be generated of size
......
...@@ -21,7 +21,8 @@ B<openssl ecparam> ...@@ -21,7 +21,8 @@ B<openssl ecparam>
[B<-conv_form arg>] [B<-conv_form arg>]
[B<-param_enc arg>] [B<-param_enc arg>]
[B<-no_seed>] [B<-no_seed>]
[B<-rand file(s)>] [B<-rand file...>]
[B<-writerand file>]
[B<-genkey>] [B<-genkey>]
[B<-engine id>] [B<-engine id>]
...@@ -116,14 +117,19 @@ is included in the ECParameters structure (see RFC 3279). ...@@ -116,14 +117,19 @@ is included in the ECParameters structure (see RFC 3279).
This option will generate an EC private key using the specified parameters. This option will generate an EC private key using the specified parameters.
=item B<-rand file(s)> =item B<-rand file...>
A file or files containing random data used to seed the random number A file or files containing random data used to seed the random number
generator, or an EGD socket (see L<RAND_egd(3)>). generator.
Multiple files can be specified separated by an OS-dependent character. Multiple files can be specified separated by an OS-dependent character.
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
all others. all others.
=item [B<-writerand file>]
Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.
=item B<-engine id> =item B<-engine id>
Specifying an engine (by its unique B<id> string) will cause B<ecparam> Specifying an engine (by its unique B<id> string) will cause B<ecparam>
......
...@@ -31,6 +31,8 @@ B<openssl enc -ciphername> ...@@ -31,6 +31,8 @@ B<openssl enc -ciphername>
[B<-nopad>] [B<-nopad>]
[B<-debug>] [B<-debug>]
[B<-none>] [B<-none>]
[B<-rand file...>]
[B<-writerand file>]
[B<-engine id>] [B<-engine id>]
=head1 DESCRIPTION =head1 DESCRIPTION
...@@ -165,6 +167,19 @@ or zlib-dynamic option. ...@@ -165,6 +167,19 @@ or zlib-dynamic option.
Use NULL cipher (no encryption or decryption of input). Use NULL cipher (no encryption or decryption of input).
=item B<-rand file...>
A file or files containing random data used to seed the random number
generator.
Multiple files can be specified separated by an OS-dependent character.
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
all others.
=item [B<-writerand file>]
Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.
=back =back
=head1 NOTES =head1 NOTES
......
...@@ -21,7 +21,8 @@ B<openssl> B<gendsa> ...@@ -21,7 +21,8 @@ B<openssl> B<gendsa>
[B<-des>] [B<-des>]
[B<-des3>] [B<-des3>]
[B<-idea>] [B<-idea>]
[B<-rand file(s)>] [B<-rand file...>]
[B<-writerand file>]
[B<-engine id>] [B<-engine id>]
[B<paramfile>] [B<paramfile>]
...@@ -49,14 +50,19 @@ These options encrypt the private key with specified ...@@ -49,14 +50,19 @@ These options encrypt the private key with specified
cipher before outputting it. A pass phrase is prompted for. cipher before outputting it. A pass phrase is prompted for.
If none of these options is specified no encryption is used. If none of these options is specified no encryption is used.
=item B<-rand file(s)> =item B<-rand file...>
A file or files containing random data used to seed the random number A file or files containing random data used to seed the random number
generator, or an EGD socket (see L<RAND_egd(3)>). generator.
Multiple files can be specified separated by an OS-dependent character. Multiple files can be specified separated by an OS-dependent character.
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
all others. all others.
=item [B<-writerand file>]
Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.
=item B<-engine id> =item B<-engine id>
Specifying an engine (by its unique B<id> string) will cause B<gendsa> Specifying an engine (by its unique B<id> string) will cause B<gendsa>
......
...@@ -24,7 +24,8 @@ B<openssl> B<genrsa> ...@@ -24,7 +24,8 @@ B<openssl> B<genrsa>
[B<-idea>] [B<-idea>]
[B<-f4>] [B<-f4>]
[B<-3>] [B<-3>]
[B<-rand file(s)>] [B<-rand file...>]
[B<-writerand file>]
[B<-engine id>] [B<-engine id>]
[B<numbits>] [B<numbits>]
...@@ -61,14 +62,19 @@ for if it is not supplied via the B<-passout> argument. ...@@ -61,14 +62,19 @@ for if it is not supplied via the B<-passout> argument.
The public exponent to use, either 65537 or 3. The default is 65537. The public exponent to use, either 65537 or 3. The default is 65537.
=item B<-rand file(s)> =item B<-rand file...>
A file or files containing random data used to seed the random number A file or files containing random data used to seed the random number
generator, or an EGD socket (see L<RAND_egd(3)>). generator.
Multiple files can be specified separated by an OS-dependent character. Multiple files can be specified separated by an OS-dependent character.
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
all others. all others.
=item [B<-writerand file>]
Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.
=item B<-engine id> =item B<-engine id>
Specifying an engine (by its unique B<id> string) will cause B<genrsa> Specifying an engine (by its unique B<id> string) will cause B<genrsa>
......
...@@ -20,6 +20,8 @@ B<openssl passwd> ...@@ -20,6 +20,8 @@ B<openssl passwd>
[B<-noverify>] [B<-noverify>]
[B<-quiet>] [B<-quiet>]
[B<-table>] [B<-table>]
[B<-rand file...>]
[B<-writerand file>]
{I<password>} {I<password>}
=head1 DESCRIPTION =head1 DESCRIPTION
...@@ -88,6 +90,19 @@ Don't output warnings when passwords given at the command line are truncated. ...@@ -88,6 +90,19 @@ Don't output warnings when passwords given at the command line are truncated.
In the output list, prepend the cleartext password and a TAB character In the output list, prepend the cleartext password and a TAB character
to each password hash. to each password hash.
=item B<-rand file...>
A file or files containing random data used to seed the random number
generator.
Multiple files can be specified separated by an OS-dependent character.
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
all others.
=item [B<-writerand file>]
Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.
=back =back
=head1 EXAMPLES =head1 EXAMPLES
......
...@@ -36,7 +36,8 @@ B<openssl> B<pkcs12> ...@@ -36,7 +36,8 @@ B<openssl> B<pkcs12>
[B<-password arg>] [B<-password arg>]
[B<-passin arg>] [B<-passin arg>]
[B<-passout arg>] [B<-passout arg>]
[B<-rand file(s)>] [B<-rand file...>]
[B<-writerand file>]
[B<-CAfile file>] [B<-CAfile file>]
[B<-CApath dir>] [B<-CApath dir>]
[B<-no-CAfile>] [B<-no-CAfile>]
...@@ -275,14 +276,19 @@ to be needed to use MAC iterations counts but they are now used by default. ...@@ -275,14 +276,19 @@ to be needed to use MAC iterations counts but they are now used by default.
Don't attempt to provide the MAC integrity. Don't attempt to provide the MAC integrity.
=item B<-rand file(s)> =item B<-rand file...>
A file or files containing random data used to seed the random number A file or files containing random data used to seed the random number
generator, or an EGD socket (see L<RAND_egd(3)>). generator.
Multiple files can be specified separated by an OS-dependent character. Multiple files can be specified separated by an OS-dependent character.
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
all others. all others.
=item [B<-writerand file>]
Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.
=item B<-CAfile file> =item B<-CAfile file>
CA storage as a file. CA storage as a file.
......
...@@ -17,6 +17,8 @@ B<openssl> B<pkcs8> ...@@ -17,6 +17,8 @@ B<openssl> B<pkcs8>
[B<-passout arg>] [B<-passout arg>]
[B<-iter count>] [B<-iter count>]
[B<-noiter>] [B<-noiter>]
[B<-rand file...>]
[B<-writerand file>]
[B<-nocrypt>] [B<-nocrypt>]
[B<-traditional>] [B<-traditional>]
[B<-v2 alg>] [B<-v2 alg>]
...@@ -99,6 +101,19 @@ This option does not encrypt private keys at all and should only be used ...@@ -99,6 +101,19 @@ This option does not encrypt private keys at all and should only be used
when absolutely necessary. Certain software such as some versions of Java when absolutely necessary. Certain software such as some versions of Java
code signing software used unencrypted private keys. code signing software used unencrypted private keys.
=item B<-rand file...>
A file or files containing random data used to seed the random number
generator.
Multiple files can be specified separated by an OS-dependent character.
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
all others.
=item [B<-writerand file>]
Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.
=item B<-v2 alg> =item B<-v2 alg>
This option sets the PKCS#5 v2.0 algorithm. This option sets the PKCS#5 v2.0 algorithm.
......
...@@ -30,6 +30,8 @@ B<openssl> B<pkeyutl> ...@@ -30,6 +30,8 @@ B<openssl> B<pkeyutl>
[B<-pkeyopt opt:value>] [B<-pkeyopt opt:value>]
[B<-hexdump>] [B<-hexdump>]
[B<-asn1parse>] [B<-asn1parse>]
[B<-rand file...>]
[B<-writerand file>]
[B<-engine id>] [B<-engine id>]
[B<-engine_impl>] [B<-engine_impl>]
...@@ -146,6 +148,19 @@ hex dump the output data. ...@@ -146,6 +148,19 @@ hex dump the output data.
Parse the ASN.1 output data, this is useful when combined with the Parse the ASN.1 output data, this is useful when combined with the
B<-verifyrecover> option when an ASN1 structure is signed. B<-verifyrecover> option when an ASN1 structure is signed.
=item B<-rand file...>
A file or files containing random data used to seed the random number
generator.
Multiple files can be specified separated by an OS-dependent character.
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
all others.
=item [B<-writerand file>]
Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.
=item B<-engine id> =item B<-engine id>
Specifying an engine (by its unique B<id> string) will cause B<pkeyutl> Specifying an engine (by its unique B<id> string) will cause B<pkeyutl>
......
...@@ -9,7 +9,8 @@ rand - generate pseudo-random bytes ...@@ -9,7 +9,8 @@ rand - generate pseudo-random bytes
B<openssl rand> B<openssl rand>
[B<-help>] [B<-help>]
[B<-out> I<file>] [B<-out> I<file>]
[B<-rand> I<file(s)>] [B<-rand file...>]
[B<-writerand file>]
[B<-base64>] [B<-base64>]
[B<-hex>] [B<-hex>]
I<num> I<num>
...@@ -31,18 +32,23 @@ seeding was obtained from these sources. ...@@ -31,18 +32,23 @@ seeding was obtained from these sources.
Print out a usage message. Print out a usage message.
=item B<-out> I<file> =item B<-out file>
Write to I<file> instead of standard output. Write to I<file> instead of standard output.
=item B<-rand> I<file(s)> =item B<-rand file...>
Use specified file or files or EGD socket (see L<RAND_egd(3)>) A file or files containing random data used to seed the random number
for seeding the random number generator. generator.
Multiple files can be specified separated by an OS-dependent character. Multiple files can be specified separated by an OS-dependent character.
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
all others. all others.
=item [B<-writerand file>]
Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.
=item B<-base64> =item B<-base64>
Perform base64 encoding on the output. Perform base64 encoding on the output.
......
...@@ -20,7 +20,8 @@ B<openssl> B<req> ...@@ -20,7 +20,8 @@ B<openssl> B<req>
[B<-verify>] [B<-verify>]
[B<-modulus>] [B<-modulus>]
[B<-new>] [B<-new>]
[B<-rand file(s)>] [B<-rand file...>]
[B<-writerand file>]
[B<-newkey rsa:bits>] [B<-newkey rsa:bits>]
[B<-newkey alg:file>] [B<-newkey alg:file>]
[B<-nodes>] [B<-nodes>]
...@@ -130,14 +131,19 @@ in the configuration file and any requested extensions. ...@@ -130,14 +131,19 @@ in the configuration file and any requested extensions.
If the B<-key> option is not used it will generate a new RSA private If the B<-key> option is not used it will generate a new RSA private
key using information specified in the configuration file. key using information specified in the configuration file.
=item B<-rand file(s)> =item B<-rand file...>
A file or files containing random data used to seed the random number A file or files containing random data used to seed the random number
generator, or an EGD socket (see L<RAND_egd(3)>). generator.
Multiple files can be specified separated by an OS-dependent character. Multiple files can be specified separated by an OS-dependent character.
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
all others. all others.
=item [B<-writerand file>]
Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.
=item B<-newkey arg> =item B<-newkey arg>
This option creates a new certificate request and a new private This option creates a new certificate request and a new private
...@@ -365,8 +371,8 @@ and long names are the same when this option is used. ...@@ -365,8 +371,8 @@ and long names are the same when this option is used.
=item B<RANDFILE> =item B<RANDFILE>
This specifies a filename in which random number seed information is At startup the specified file is loaded into the random number generator,
placed and read from, or an EGD socket (see L<RAND_egd(3)>). and at exit 256 bytes will be written to it.
It is used for private key generation. It is used for private key generation.
=item B<encrypt_key> =item B<encrypt_key>
......
...@@ -18,6 +18,8 @@ B<openssl> B<rsautl> ...@@ -18,6 +18,8 @@ B<openssl> B<rsautl>
[B<-verify>] [B<-verify>]
[B<-encrypt>] [B<-encrypt>]
[B<-decrypt>] [B<-decrypt>]
[B<-rand file...>]
[B<-writerand file>]
[B<-pkcs>] [B<-pkcs>]
[B<-ssl>] [B<-ssl>]
[B<-raw>] [B<-raw>]
...@@ -80,6 +82,19 @@ Encrypt the input data using an RSA public key. ...@@ -80,6 +82,19 @@ Encrypt the input data using an RSA public key.
Decrypt the input data using an RSA private key. Decrypt the input data using an RSA private key.
=item B<-rand file...>
A file or files containing random data used to seed the random number
generator.
Multiple files can be specified separated by an OS-dependent character.
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
all others.
=item [B<-writerand file>]
Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.
=item B<-pkcs, -oaep, -ssl, -raw> =item B<-pkcs, -oaep, -ssl, -raw>
The padding to use: PKCS#1 v1.5 (the default), PKCS#1 OAEP, The padding to use: PKCS#1 v1.5 (the default), PKCS#1 OAEP,
......
...@@ -105,7 +105,8 @@ B<openssl> B<s_client> ...@@ -105,7 +105,8 @@ B<openssl> B<s_client>
[B<-no_ticket>] [B<-no_ticket>]
[B<-sess_out filename>] [B<-sess_out filename>]
[B<-sess_in filename>] [B<-sess_in filename>]
[B<-rand file(s)>] [B<-rand file...>]
[B<-writerand file>]
[B<-serverinfo types>] [B<-serverinfo types>]
[B<-status>] [B<-status>]
[B<-alpn protocols>] [B<-alpn protocols>]
...@@ -536,14 +537,19 @@ to attempt to obtain a functional reference to the specified engine, ...@@ -536,14 +537,19 @@ to attempt to obtain a functional reference to the specified engine,
thus initialising it if needed. The engine will then be set as the default thus initialising it if needed. The engine will then be set as the default
for all available algorithms. for all available algorithms.
=item B<-rand file(s)> =item B<-rand file...>
A file or files containing random data used to seed the random number A file or files containing random data used to seed the random number
generator, or an EGD socket (see L<RAND_egd(3)>). generator.
Multiple files can be specified separated by an OS-dependent character. Multiple files can be specified separated by an OS-dependent character.
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
all others. all others.
=item [B<-writerand file>]
Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.
=item B<-serverinfo types> =item B<-serverinfo types>
A list of comma-separated TLS Extension Types (numbers between 0 and A list of comma-separated TLS Extension Types (numbers between 0 and
......
...@@ -52,7 +52,8 @@ B<openssl> B<s_server> ...@@ -52,7 +52,8 @@ B<openssl> B<s_server>
[B<-tlsextdebug>] [B<-tlsextdebug>]
[B<-HTTP>] [B<-HTTP>]
[B<-id_prefix val>] [B<-id_prefix val>]
[B<-rand val>] [B<-rand file...>]
[B<-writerand file>]
[B<-keymatexport val>] [B<-keymatexport val>]
[B<-keymatexportlen +int>] [B<-keymatexportlen +int>]
[B<-CRL infile>] [B<-CRL infile>]
...@@ -381,14 +382,19 @@ for testing any SSL/TLS code (eg. proxies) that wish to deal with multiple ...@@ -381,14 +382,19 @@ for testing any SSL/TLS code (eg. proxies) that wish to deal with multiple
servers, when each of which might be generating a unique range of session servers, when each of which might be generating a unique range of session
IDs (eg. with a certain prefix). IDs (eg. with a certain prefix).
=item B<-rand val> =item B<-rand file...>
A file or files containing random data used to seed the random number A file or files containing random data used to seed the random number
generator, or an EGD socket (see L<RAND_egd(3)>). generator.
Multiple files can be specified separated by an OS-dependent character. Multiple files can be specified separated by an OS-dependent character.
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
all others. all others.
=item [B<-writerand file>]
Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.
=item B<-verify_return_error> =item B<-verify_return_error>
Verification errors normally just print a message but allow the Verification errors normally just print a message but allow the
......
...@@ -65,7 +65,8 @@ B<openssl> B<smime> ...@@ -65,7 +65,8 @@ B<openssl> B<smime>
[B<-indef>] [B<-indef>]
[B<-noindef>] [B<-noindef>]
[B<-stream>] [B<-stream>]
[B<-rand file(s)>] [B<-rand file...>]
[B<-writerand file>]
[B<-md digest>] [B<-md digest>]
[cert.pem]... [cert.pem]...
...@@ -295,14 +296,19 @@ specified, the argument is given to the engine as a key identifier. ...@@ -295,14 +296,19 @@ specified, the argument is given to the engine as a key identifier.
The private key password source. For more information about the format of B<arg> The private key password source. For more information about the format of B<arg>
see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)>. see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)>.
=item B<-rand file(s)> =item B<-rand file...>
A file or files containing random data used to seed the random number A file or files containing random data used to seed the random number
generator, or an EGD socket (see L<RAND_egd(3)>). generator.
Multiple files can be specified separated by an OS-dependent character. Multiple files can be specified separated by an OS-dependent character.
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
all others. all others.
=item [B<-writerand file>]
Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.
=item B<cert.pem...> =item B<cert.pem...>
One or more certificates of message recipients: used when encrypting One or more certificates of message recipients: used when encrypting
......
...@@ -12,6 +12,8 @@ B<openssl speed> ...@@ -12,6 +12,8 @@ B<openssl speed>
[B<-elapsed>] [B<-elapsed>]
[B<-evp algo>] [B<-evp algo>]
[B<-decrypt>] [B<-decrypt>]
[B<-rand file...>]
[B<-writerand file>]
[B<algorithm...>] [B<algorithm...>]
=head1 DESCRIPTION =head1 DESCRIPTION
...@@ -48,6 +50,19 @@ Use the specified cipher or message digest algorithm via the EVP interface. ...@@ -48,6 +50,19 @@ Use the specified cipher or message digest algorithm via the EVP interface.
Time the decryption instead of encryption. Affects only the EVP testing. Time the decryption instead of encryption. Affects only the EVP testing.
=item B<-rand file...>
A file or files containing random data used to seed the random number
generator.
Multiple files can be specified separated by an OS-dependent character.
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
all others.
=item [B<-writerand file>]
Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.
=item B<[zero or more test algorithms]> =item B<[zero or more test algorithms]>
If any options are given, B<speed> tests those algorithms, otherwise all of If any options are given, B<speed> tests those algorithms, otherwise all of
......
...@@ -8,7 +8,8 @@ ts - Time Stamping Authority tool (client/server) ...@@ -8,7 +8,8 @@ ts - Time Stamping Authority tool (client/server)
B<openssl> B<ts> B<openssl> B<ts>
B<-query> B<-query>
[B<-rand> file:file...] [B<-rand file...>]
[B<-writerand file>]
[B<-config> configfile] [B<-config> configfile]
[B<-data> file_to_hash] [B<-data> file_to_hash]
[B<-digest> digest_bytes] [B<-digest> digest_bytes]
...@@ -131,11 +132,18 @@ request with the following options: ...@@ -131,11 +132,18 @@ request with the following options:
=over 4 =over 4
=item B<-rand> file:file... =item B<-rand file...>
The files containing random data for seeding the random number A file or files containing random data used to seed the random number
generator. Multiple files can be specified, the separator is B<;> for generator.
MS-Windows, B<,> for VMS and B<:> for all other platforms. (Optional) Multiple files can be specified separated by an OS-dependent character.
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
all others.
=item [B<-writerand file>]
Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.
=item B<-config> configfile =item B<-config> configfile
......
...@@ -59,6 +59,8 @@ B<openssl> B<x509> ...@@ -59,6 +59,8 @@ B<openssl> B<x509>
[B<-clrext>] [B<-clrext>]
[B<-extfile filename>] [B<-extfile filename>]
[B<-extensions section>] [B<-extensions section>]
[B<-rand file...>]
[B<-writerand file>]
[B<-engine id>] [B<-engine id>]
[B<-preserve_dates>] [B<-preserve_dates>]
...@@ -115,6 +117,19 @@ Any digest supported by the OpenSSL B<dgst> command can be used. ...@@ -115,6 +117,19 @@ Any digest supported by the OpenSSL B<dgst> command can be used.
If not specified then SHA1 is used with B<-fingerprint> or If not specified then SHA1 is used with B<-fingerprint> or
the default digest for the signing algorithm is used, typically SHA256. the default digest for the signing algorithm is used, typically SHA256.
=item B<-rand file...>
A file or files containing random data used to seed the random number
generator.
Multiple files can be specified separated by an OS-dependent character.
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
all others.
=item [B<-writerand file>]
Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.
=item B<-engine id> =item B<-engine id>
Specifying an engine (by its unique B<id> string) will cause B<x509> Specifying an engine (by its unique B<id> string) will cause B<x509>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册