mirror of https://github.com/openssl/openssl
APPS: Improve diagnostics on missing/extra args and unknown cipher/digest
Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16450)
This commit is contained in:
parent
b0be101326
commit
d9f073575f
|
@ -159,8 +159,7 @@ int asn1parse_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra args. */
|
/* No extra args. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
if (oidfile != NULL) {
|
if (oidfile != NULL) {
|
||||||
|
|
|
@ -174,10 +174,9 @@ int ciphers_main(int argc, char **argv)
|
||||||
|
|
||||||
/* Optional arg is cipher name. */
|
/* Optional arg is cipher name. */
|
||||||
argv = opt_rest();
|
argv = opt_rest();
|
||||||
argc = opt_num_rest();
|
if (opt_num_rest() == 1)
|
||||||
if (argc == 1)
|
|
||||||
ciphers = argv[0];
|
ciphers = argv[0];
|
||||||
else if (argc != 0)
|
else if (!opt_check_rest_arg(NULL))
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
if (convert != NULL) {
|
if (convert != NULL) {
|
||||||
|
|
|
@ -2552,9 +2552,7 @@ static int get_opts(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra args. */
|
/* No extra args. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
argv = opt_rest();
|
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -697,10 +697,8 @@ int cms_main(int argc, char **argv)
|
||||||
if (!opt_md(digestname, &sign_md))
|
if (!opt_md(digestname, &sign_md))
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
if (ciphername != NULL) {
|
if (!opt_cipher_any(ciphername, &cipher))
|
||||||
if (!opt_cipher_any(ciphername, &cipher))
|
goto end;
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
if (wrapname != NULL) {
|
if (wrapname != NULL) {
|
||||||
if (!opt_cipher_any(wrapname, &wrap_cipher))
|
if (!opt_cipher_any(wrapname, &wrap_cipher))
|
||||||
goto end;
|
goto end;
|
||||||
|
|
|
@ -209,14 +209,11 @@ int crl_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No remaining args. */
|
/* No remaining args. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
if (digestname != NULL) {
|
if (!opt_md(digestname, &digest))
|
||||||
if (!opt_md(digestname, &digest))
|
goto opthelp;
|
||||||
goto opthelp;
|
|
||||||
}
|
|
||||||
x = load_crl(infile, informat, 1, "CRL");
|
x = load_crl(infile, informat, 1, "CRL");
|
||||||
if (x == NULL)
|
if (x == NULL)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
|
@ -104,8 +104,7 @@ int crl2pkcs7_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No remaining args. */
|
/* No remaining args. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
if (!nocrl) {
|
if (!nocrl) {
|
||||||
|
|
|
@ -155,7 +155,7 @@ int dhparam_main(int argc, char **argv)
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
if (!opt_int(argv[0], &num) || num <= 0)
|
if (!opt_int(argv[0], &num) || num <= 0)
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
} else if (argc != 0) {
|
} else if (!opt_check_rest_arg(NULL)) {
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
}
|
}
|
||||||
if (!app_RAND_load())
|
if (!app_RAND_load())
|
||||||
|
|
|
@ -161,14 +161,11 @@ int dsa_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra args. */
|
/* No extra args. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
if (ciphername != NULL) {
|
if (!opt_cipher(ciphername, &enc))
|
||||||
if (!opt_cipher(ciphername, &enc))
|
goto end;
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
private = pubin || pubout ? 0 : 1;
|
private = pubin || pubout ? 0 : 1;
|
||||||
if (text && !pubin)
|
if (text && !pubin)
|
||||||
private = 1;
|
private = 1;
|
||||||
|
|
|
@ -133,7 +133,7 @@ int dsaparam_main(int argc, char **argv)
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
if (!opt_int(argv[0], &num) || num < 0)
|
if (!opt_int(argv[0], &num) || num < 0)
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
} else if (argc != 0) {
|
} else if (!opt_check_rest_arg(NULL)) {
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
}
|
}
|
||||||
if (!app_RAND_load())
|
if (!app_RAND_load())
|
||||||
|
|
|
@ -157,14 +157,11 @@ int ec_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra arguments. */
|
/* No extra arguments. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
if (ciphername != NULL) {
|
if (!opt_cipher(ciphername, &enc))
|
||||||
if (!opt_cipher(ciphername, &enc))
|
goto opthelp;
|
||||||
goto opthelp;
|
|
||||||
}
|
|
||||||
private = param_out || pubin || pubout ? 0 : 1;
|
private = param_out || pubin || pubout ? 0 : 1;
|
||||||
if (text && !pubin)
|
if (text && !pubin)
|
||||||
private = 1;
|
private = 1;
|
||||||
|
|
|
@ -186,8 +186,7 @@ int ecparam_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra args. */
|
/* No extra args. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
if (!app_RAND_load())
|
if (!app_RAND_load())
|
||||||
|
|
|
@ -289,17 +289,14 @@ int enc_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra arguments. */
|
/* No extra arguments. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
if (!app_RAND_load())
|
if (!app_RAND_load())
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
/* Get the cipher name, either from progname (if set) or flag. */
|
/* Get the cipher name, either from progname (if set) or flag. */
|
||||||
if (ciphername != NULL) {
|
if (!opt_cipher(ciphername, &cipher))
|
||||||
if (!opt_cipher(ciphername, &cipher))
|
goto opthelp;
|
||||||
goto opthelp;
|
|
||||||
}
|
|
||||||
if (digestname != NULL) {
|
if (digestname != NULL) {
|
||||||
if (!opt_md(digestname, &dgst))
|
if (!opt_md(digestname, &dgst))
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
|
@ -382,9 +382,12 @@ opthelp:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra arguments. */
|
/* No extra arguments. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0 || (verify && in_fname == NULL))
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
if (verify && in_fname == NULL) {
|
||||||
|
BIO_printf(bio_err, "Missing -in option for -verify\n");
|
||||||
|
goto opthelp;
|
||||||
|
}
|
||||||
|
|
||||||
if (parent_config != NULL) {
|
if (parent_config != NULL) {
|
||||||
/* Test that a parent config can load the module */
|
/* Test that a parent config can load the module */
|
||||||
|
|
|
@ -101,19 +101,16 @@ int gendsa_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* One argument, the params file. */
|
/* One argument, the params file. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg("params file"))
|
||||||
argv = opt_rest();
|
|
||||||
if (argc != 1)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
argv = opt_rest();
|
||||||
dsaparams = argv[0];
|
dsaparams = argv[0];
|
||||||
|
|
||||||
if (!app_RAND_load())
|
if (!app_RAND_load())
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
if (ciphername != NULL) {
|
if (!opt_cipher(ciphername, &enc))
|
||||||
if (!opt_cipher(ciphername, &enc))
|
goto end;
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
private = 1;
|
private = 1;
|
||||||
|
|
||||||
if (!app_passwd(NULL, passoutarg, NULL, &passout)) {
|
if (!app_passwd(NULL, passoutarg, NULL, &passout)) {
|
||||||
|
|
|
@ -139,8 +139,7 @@ int genpkey_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra arguments. */
|
/* No extra arguments. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
/* Fetch cipher, etc. */
|
/* Fetch cipher, etc. */
|
||||||
|
@ -163,9 +162,12 @@ int genpkey_main(int argc, char **argv)
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ciphername != NULL)
|
if (!opt_cipher(ciphername, &cipher))
|
||||||
if (!opt_cipher(ciphername, &cipher) || do_param == 1)
|
goto opthelp;
|
||||||
goto opthelp;
|
if (ciphername != NULL && do_param == 1) {
|
||||||
|
BIO_printf(bio_err, "Cannot use cipher with -genparam option\n");
|
||||||
|
goto opthelp;
|
||||||
|
}
|
||||||
|
|
||||||
private = do_param ? 0 : 1;
|
private = do_param ? 0 : 1;
|
||||||
|
|
||||||
|
|
|
@ -157,8 +157,7 @@ opthelp:
|
||||||
"Warning: It is not recommended to use more than %d bit for RSA keys.\n"
|
"Warning: It is not recommended to use more than %d bit for RSA keys.\n"
|
||||||
" Your key size is %d! Larger key size may behave not as expected.\n",
|
" Your key size is %d! Larger key size may behave not as expected.\n",
|
||||||
OPENSSL_RSA_MAX_MODULUS_BITS, num);
|
OPENSSL_RSA_MAX_MODULUS_BITS, num);
|
||||||
} else if (argc > 0) {
|
} else if (!opt_check_rest_arg(NULL)) {
|
||||||
BIO_printf(bio_err, "Extra arguments given.\n");
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,10 +165,8 @@ opthelp:
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
private = 1;
|
private = 1;
|
||||||
if (ciphername != NULL) {
|
if (!opt_cipher(ciphername, &enc))
|
||||||
if (!opt_cipher(ciphername, &enc))
|
goto end;
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
if (!app_passwd(NULL, passoutarg, NULL, &passout)) {
|
if (!app_passwd(NULL, passoutarg, NULL, &passout)) {
|
||||||
BIO_printf(bio_err, "Error getting password\n");
|
BIO_printf(bio_err, "Error getting password\n");
|
||||||
goto end;
|
goto end;
|
||||||
|
|
|
@ -368,6 +368,7 @@ char *opt_unknown(void);
|
||||||
int opt_cipher(const char *name, EVP_CIPHER **cipherp);
|
int opt_cipher(const char *name, EVP_CIPHER **cipherp);
|
||||||
int opt_cipher_any(const char *name, EVP_CIPHER **cipherp);
|
int opt_cipher_any(const char *name, EVP_CIPHER **cipherp);
|
||||||
int opt_cipher_silent(const char *name, EVP_CIPHER **cipherp);
|
int opt_cipher_silent(const char *name, EVP_CIPHER **cipherp);
|
||||||
|
int opt_check_md(const char *name);
|
||||||
int opt_md(const char *name, EVP_MD **mdp);
|
int opt_md(const char *name, EVP_MD **mdp);
|
||||||
int opt_md_silent(const char *name, EVP_MD **mdp);
|
int opt_md_silent(const char *name, EVP_MD **mdp);
|
||||||
|
|
||||||
|
@ -392,6 +393,7 @@ int opt_provider_option_given(void);
|
||||||
|
|
||||||
char **opt_rest(void);
|
char **opt_rest(void);
|
||||||
int opt_num_rest(void);
|
int opt_num_rest(void);
|
||||||
|
int opt_check_rest_arg(const char *expected);
|
||||||
|
|
||||||
/* Returns non-zero if legacy paths are still available */
|
/* Returns non-zero if legacy paths are still available */
|
||||||
int opt_legacy_okay(void);
|
int opt_legacy_okay(void);
|
||||||
|
|
|
@ -86,7 +86,7 @@ opthelp:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (opt_num_rest() != 0)
|
if (!opt_check_rest_arg(NULL))
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
if (dirty > 1) {
|
if (dirty > 1) {
|
||||||
BIO_printf(bio_err, "%s: Only one item allowed\n", prog);
|
BIO_printf(bio_err, "%s: Only one item allowed\n", prog);
|
||||||
|
|
|
@ -399,8 +399,10 @@ int opt_cipher_any(const char *name, EVP_CIPHER **cipherp)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (name == NULL)
|
||||||
|
return 1;
|
||||||
if ((ret = opt_cipher_silent(name, cipherp)) == 0)
|
if ((ret = opt_cipher_silent(name, cipherp)) == 0)
|
||||||
opt_printf_stderr("%s: Unknown cipher: %s\n", prog, name);
|
opt_printf_stderr("%s: Unknown option or cipher: %s\n", prog, name);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,6 +412,8 @@ int opt_cipher(const char *name, EVP_CIPHER **cipherp)
|
||||||
unsigned long int flags;
|
unsigned long int flags;
|
||||||
EVP_CIPHER *c = NULL;
|
EVP_CIPHER *c = NULL;
|
||||||
|
|
||||||
|
if (name == NULL)
|
||||||
|
return 1;
|
||||||
if (opt_cipher_any(name, &c)) {
|
if (opt_cipher_any(name, &c)) {
|
||||||
mode = EVP_CIPHER_get_mode(c);
|
mode = EVP_CIPHER_get_mode(c);
|
||||||
flags = EVP_CIPHER_get_flags(c);
|
flags = EVP_CIPHER_get_flags(c);
|
||||||
|
@ -454,12 +458,22 @@ int opt_md(const char *name, EVP_MD **mdp)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (name == NULL)
|
||||||
|
return 1;
|
||||||
if ((ret = opt_md_silent(name, mdp)) == 0)
|
if ((ret = opt_md_silent(name, mdp)) == 0)
|
||||||
opt_printf_stderr("%s: Unknown option or message digest: %s\n", prog,
|
opt_printf_stderr("%s: Unknown option or message digest: %s\n",
|
||||||
name != NULL ? name : "\"\"");
|
prog, name);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int opt_check_md(const char *name)
|
||||||
|
{
|
||||||
|
if (opt_md(name, NULL))
|
||||||
|
return 1;
|
||||||
|
ERR_clear_error();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Look through a list of name/value pairs. */
|
/* Look through a list of name/value pairs. */
|
||||||
int opt_pair(const char *name, const OPT_PAIR* pairs, int *result)
|
int opt_pair(const char *name, const OPT_PAIR* pairs, int *result)
|
||||||
{
|
{
|
||||||
|
@ -1013,6 +1027,26 @@ int opt_num_rest(void)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int opt_check_rest_arg(const char *expected)
|
||||||
|
{
|
||||||
|
char *opt = *opt_rest();
|
||||||
|
|
||||||
|
if (opt == NULL || *opt == '\0') {
|
||||||
|
if (expected == NULL)
|
||||||
|
return 1;
|
||||||
|
opt_printf_stderr("%s: Missing argument: %s\n", prog, expected);
|
||||||
|
return 0;
|
||||||
|
} else if (expected != NULL) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (opt_unknown() == NULL)
|
||||||
|
opt_printf_stderr("%s: Extra option: \"%s\"\n", prog, opt);
|
||||||
|
else
|
||||||
|
opt_printf_stderr("%s: Extra (unknown) options: \"%s\" \"%s\"\n",
|
||||||
|
prog, opt_unknown(), opt != NULL ? opt : "");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Return a string describing the parameter type. */
|
/* Return a string describing the parameter type. */
|
||||||
static const char *valtype2param(const OPTIONS *o)
|
static const char *valtype2param(const OPTIONS *o)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1647,7 +1647,7 @@ opthelp:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra arguments. */
|
/* No extra arguments. */
|
||||||
if (opt_num_rest() != 0)
|
if (!opt_check_rest_arg(NULL))
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
if (todo.commands)
|
if (todo.commands)
|
||||||
|
|
|
@ -137,10 +137,9 @@ opthelp:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* One argument, the MAC name. */
|
/* One argument, the MAC name. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg("MAC name"))
|
||||||
argv = opt_rest();
|
|
||||||
if (argc != 1)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
argv = opt_rest();
|
||||||
|
|
||||||
mac = EVP_MAC_fetch(app_get0_libctx(), argv[0], app_get0_propq());
|
mac = EVP_MAC_fetch(app_get0_libctx(), argv[0], app_get0_propq());
|
||||||
if (mac == NULL) {
|
if (mac == NULL) {
|
||||||
|
|
|
@ -73,8 +73,7 @@ int nseq_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra arguments. */
|
/* No extra arguments. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
in = bio_open_default(infile, 'r', FORMAT_PEM);
|
in = bio_open_default(infile, 'r', FORMAT_PEM);
|
||||||
|
|
|
@ -535,8 +535,7 @@ int ocsp_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra arguments. */
|
/* No extra arguments. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
if (trailing_md) {
|
if (trailing_md) {
|
||||||
|
|
|
@ -357,7 +357,7 @@ int help_main(int argc, char **argv)
|
||||||
new_argv[2] = NULL;
|
new_argv[2] = NULL;
|
||||||
return do_cmd(prog_init(), 2, new_argv);
|
return do_cmd(prog_init(), 2, new_argv);
|
||||||
}
|
}
|
||||||
if (opt_num_rest() != 0) {
|
if (!opt_check_rest_arg(NULL)) {
|
||||||
BIO_printf(bio_err, "Usage: %s\n", prog);
|
BIO_printf(bio_err, "Usage: %s\n", prog);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -356,17 +356,14 @@ int pkcs12_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra arguments. */
|
/* No extra arguments. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
if (!app_RAND_load())
|
if (!app_RAND_load())
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
if (ciphername != NULL) {
|
if (!opt_cipher_any(ciphername, &enc))
|
||||||
if (!opt_cipher_any(ciphername, &enc))
|
goto opthelp;
|
||||||
goto opthelp;
|
|
||||||
}
|
|
||||||
if (export_pkcs12) {
|
if (export_pkcs12) {
|
||||||
if ((options & INFO) != 0)
|
if ((options & INFO) != 0)
|
||||||
WARN_EXPORT("info");
|
WARN_EXPORT("info");
|
||||||
|
|
|
@ -111,8 +111,7 @@ int pkcs7_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra arguments. */
|
/* No extra arguments. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
in = bio_open_default(infile, 'r', informat);
|
in = bio_open_default(infile, 'r', informat);
|
||||||
|
|
|
@ -193,8 +193,7 @@ int pkcs8_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra arguments. */
|
/* No extra arguments. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
private = 1;
|
private = 1;
|
||||||
|
|
|
@ -171,8 +171,7 @@ int pkey_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra arguments. */
|
/* No extra arguments. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
if (text && text_pub)
|
if (text && text_pub)
|
||||||
|
@ -190,10 +189,8 @@ int pkey_main(int argc, char **argv)
|
||||||
|
|
||||||
private = (!noout && !pubout) || (text && !text_pub);
|
private = (!noout && !pubout) || (text && !text_pub);
|
||||||
|
|
||||||
if (ciphername != NULL) {
|
if (!opt_cipher(ciphername, &cipher))
|
||||||
if (!opt_cipher(ciphername, &cipher))
|
goto opthelp;
|
||||||
goto opthelp;
|
|
||||||
}
|
|
||||||
if (cipher == NULL) {
|
if (cipher == NULL) {
|
||||||
if (passoutarg != NULL)
|
if (passoutarg != NULL)
|
||||||
BIO_printf(bio_err,
|
BIO_printf(bio_err,
|
||||||
|
|
|
@ -91,8 +91,7 @@ int pkeyparam_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra arguments. */
|
/* No extra arguments. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
in = bio_open_default(infile, 'r', FORMAT_PEM);
|
in = bio_open_default(infile, 'r', FORMAT_PEM);
|
||||||
|
|
|
@ -253,8 +253,7 @@ int pkeyutl_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra arguments. */
|
/* No extra arguments. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
if (!app_RAND_load())
|
if (!app_RAND_load())
|
||||||
|
|
|
@ -83,12 +83,12 @@ opthelp:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Optional arguments are numbers to check. */
|
/* Optional arguments are numbers to check. */
|
||||||
|
if (generate && !opt_check_rest_arg(NULL))
|
||||||
|
goto opthelp;
|
||||||
argc = opt_num_rest();
|
argc = opt_num_rest();
|
||||||
argv = opt_rest();
|
argv = opt_rest();
|
||||||
if (generate) {
|
if (!generate && argc == 0) {
|
||||||
if (argc != 0)
|
BIO_printf(bio_err, "Missing number (s) to check\n");
|
||||||
goto opthelp;
|
|
||||||
} else if (argc == 0) {
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ int rand_main(int argc, char **argv)
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
if (!opt_int(argv[0], &num) || num <= 0)
|
if (!opt_int(argv[0], &num) || num <= 0)
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
} else if (argc != 0) {
|
} else if (!opt_check_rest_arg(NULL)) {
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -241,7 +241,6 @@ int req_main(int argc, char **argv)
|
||||||
X509 *new_x509 = NULL, *CAcert = NULL;
|
X509 *new_x509 = NULL, *CAcert = NULL;
|
||||||
X509_REQ *req = NULL;
|
X509_REQ *req = NULL;
|
||||||
EVP_CIPHER *cipher = NULL;
|
EVP_CIPHER *cipher = NULL;
|
||||||
EVP_MD *md = NULL;
|
|
||||||
int ext_copy = EXT_COPY_UNSET;
|
int ext_copy = EXT_COPY_UNSET;
|
||||||
BIO *addext_bio = NULL;
|
BIO *addext_bio = NULL;
|
||||||
char *extsect = NULL;
|
char *extsect = NULL;
|
||||||
|
@ -473,8 +472,7 @@ int req_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra arguments. */
|
/* No extra arguments. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
if (!app_RAND_load())
|
if (!app_RAND_load())
|
||||||
|
@ -533,11 +531,8 @@ int req_main(int argc, char **argv)
|
||||||
|
|
||||||
/* Check that any specified digest is fetchable */
|
/* Check that any specified digest is fetchable */
|
||||||
if (digest != NULL) {
|
if (digest != NULL) {
|
||||||
if (!opt_md(digest, &md)) {
|
if (!opt_check_md(digest))
|
||||||
ERR_clear_error();
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
}
|
|
||||||
EVP_MD_free(md);
|
|
||||||
} else {
|
} else {
|
||||||
/* No digest specified, default to configuration */
|
/* No digest specified, default to configuration */
|
||||||
p = NCONF_get_string(req_conf, section, "default_md");
|
p = NCONF_get_string(req_conf, section, "default_md");
|
||||||
|
|
|
@ -217,14 +217,11 @@ int rsa_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra arguments. */
|
/* No extra arguments. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
if (ciphername != NULL) {
|
if (!opt_cipher(ciphername, &enc))
|
||||||
if (!opt_cipher(ciphername, &enc))
|
goto opthelp;
|
||||||
goto opthelp;
|
|
||||||
}
|
|
||||||
private = (text && !pubin) || (!pubout && !noout) ? 1 : 0;
|
private = (text && !pubin) || (!pubout && !noout) ? 1 : 0;
|
||||||
|
|
||||||
if (!app_passwd(passinarg, passoutarg, &passin, &passout)) {
|
if (!app_passwd(passinarg, passoutarg, &passin, &passout)) {
|
||||||
|
|
|
@ -169,8 +169,7 @@ int rsautl_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra arguments. */
|
/* No extra arguments. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
if (!app_RAND_load())
|
if (!app_RAND_load())
|
||||||
|
|
|
@ -1473,8 +1473,7 @@ int s_client_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Optional argument is connect string if -connect not used. */
|
/* Optional argument is connect string if -connect not used. */
|
||||||
argc = opt_num_rest();
|
if (opt_num_rest() == 1) {
|
||||||
if (argc == 1) {
|
|
||||||
/* Don't allow -connect and a separate argument. */
|
/* Don't allow -connect and a separate argument. */
|
||||||
if (connectstr != NULL) {
|
if (connectstr != NULL) {
|
||||||
BIO_printf(bio_err,
|
BIO_printf(bio_err,
|
||||||
|
@ -1484,7 +1483,7 @@ int s_client_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
connect_type = use_inet;
|
connect_type = use_inet;
|
||||||
freeandcopy(&connectstr, *opt_rest());
|
freeandcopy(&connectstr, *opt_rest());
|
||||||
} else if (argc != 0) {
|
} else if (!opt_check_rest_arg(NULL)) {
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
}
|
}
|
||||||
if (!app_RAND_load())
|
if (!app_RAND_load())
|
||||||
|
|
|
@ -1648,8 +1648,7 @@ int s_server_main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra arguments. */
|
/* No extra arguments. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
if (!app_RAND_load())
|
if (!app_RAND_load())
|
||||||
|
|
|
@ -234,8 +234,7 @@ int s_time_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra arguments. */
|
/* No extra arguments. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
if (cipher == NULL)
|
if (cipher == NULL)
|
||||||
|
|
|
@ -98,8 +98,7 @@ int sess_id_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra arguments. */
|
/* No extra arguments. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
x = load_sess_id(infile, informat);
|
x = load_sess_id(infile, informat);
|
||||||
|
|
|
@ -366,10 +366,8 @@ int smime_main(int argc, char **argv)
|
||||||
if (!opt_md(digestname, &sign_md))
|
if (!opt_md(digestname, &sign_md))
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
}
|
}
|
||||||
if (ciphername != NULL) {
|
if (!opt_cipher_any(ciphername, &cipher))
|
||||||
if (!opt_cipher_any(ciphername, &cipher))
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
}
|
|
||||||
if (!(operation & SMIME_SIGNERS) && (skkeys != NULL || sksigners != NULL)) {
|
if (!(operation & SMIME_SIGNERS) && (skkeys != NULL || sksigners != NULL)) {
|
||||||
BIO_puts(bio_err, "Multiple signers or keys not allowed\n");
|
BIO_puts(bio_err, "Multiple signers or keys not allowed\n");
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
|
@ -133,8 +133,7 @@ int spkac_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra arguments. */
|
/* No extra arguments. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
if (!app_passwd(passinarg, NULL, &passin, NULL)) {
|
if (!app_passwd(passinarg, NULL, &passin, NULL)) {
|
||||||
|
|
|
@ -258,15 +258,12 @@ int storeutl_main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
/* One argument, the URI */
|
/* One argument, the URI */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg("URI"))
|
||||||
argv = opt_rest();
|
|
||||||
if (argc != 1)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
argv = opt_rest();
|
||||||
|
|
||||||
if (digestname != NULL) {
|
if (!opt_md(digestname, &digest))
|
||||||
if (!opt_md(digestname, &digest))
|
goto opthelp;
|
||||||
goto opthelp;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (criterion != 0) {
|
if (criterion != 0) {
|
||||||
switch (criterion) {
|
switch (criterion) {
|
||||||
|
|
17
apps/ts.c
17
apps/ts.c
|
@ -204,8 +204,10 @@ int ts_main(int argc, char **argv)
|
||||||
case OPT_QUERY:
|
case OPT_QUERY:
|
||||||
case OPT_REPLY:
|
case OPT_REPLY:
|
||||||
case OPT_VERIFY:
|
case OPT_VERIFY:
|
||||||
if (mode != OPT_ERR)
|
if (mode != OPT_ERR) {
|
||||||
|
BIO_printf(bio_err, "%s: Must give only one of -query, -reply, or -verify\n", prog);
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
}
|
||||||
mode = o;
|
mode = o;
|
||||||
break;
|
break;
|
||||||
case OPT_DATA:
|
case OPT_DATA:
|
||||||
|
@ -288,17 +290,18 @@ int ts_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra arguments. */
|
/* No extra arguments. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0 || mode == OPT_ERR)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
if (mode == OPT_ERR) {
|
||||||
|
BIO_printf(bio_err, "%s: Must give one of -query, -reply, or -verify\n", prog);
|
||||||
|
goto opthelp;
|
||||||
|
}
|
||||||
|
|
||||||
if (!app_RAND_load())
|
if (!app_RAND_load())
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
if (digestname != NULL) {
|
if (!opt_md(digestname, &md))
|
||||||
if (!opt_md(digestname, &md))
|
goto opthelp;
|
||||||
goto opthelp;
|
|
||||||
}
|
|
||||||
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");
|
||||||
|
|
|
@ -99,8 +99,7 @@ opthelp:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra arguments. */
|
/* No extra arguments. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
if (!dirty)
|
if (!dirty)
|
||||||
|
|
|
@ -594,13 +594,15 @@ int x509_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extra arguments. */
|
/* No extra arguments. */
|
||||||
argc = opt_num_rest();
|
if (!opt_check_rest_arg(NULL))
|
||||||
if (argc != 0)
|
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
if (!app_RAND_load())
|
if (!app_RAND_load())
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
|
if (!opt_check_md(digest))
|
||||||
|
goto opthelp;
|
||||||
|
|
||||||
if (preserve_dates && days != UNSET_DAYS) {
|
if (preserve_dates && days != UNSET_DAYS) {
|
||||||
BIO_printf(bio_err, "Cannot use -preserve_dates with -days option\n");
|
BIO_printf(bio_err, "Cannot use -preserve_dates with -days option\n");
|
||||||
goto err;
|
goto err;
|
||||||
|
|
Loading…
Reference in New Issue