From f47e5647750d4443cbdd7fc2311f838f0f103112 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Thu, 12 May 2016 17:13:50 +0100 Subject: [PATCH] Fix signer option and support format SMIME. Fix -signer option in smime utility to output signer certificates when verifying. Add support for format SMIME for -inform and -outform with cms and smime utilities. PR#4215 Reviewed-by: Viktor Dukhovni --- apps/apps.h | 1 + apps/cms.c | 8 ++++---- apps/opt.c | 4 +++- apps/smime.c | 10 +++++----- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/apps/apps.h b/apps/apps.h index fc96d81e1c..4b11dbca83 100644 --- a/apps/apps.h +++ b/apps/apps.h @@ -410,6 +410,7 @@ typedef struct string_int_pair_st { # define OPT_FMT_HTTP (1L << 9) # define OPT_FMT_PVK (1L << 10) # define OPT_FMT_PDE (OPT_FMT_PEMDER | OPT_FMT_ENGINE) +# define OPT_FMT_PDS (OPT_FMT_PEMDER | OPT_FMT_SMIME) # define OPT_FMT_ANY ( \ OPT_FMT_PEMDER | OPT_FMT_PKCS12 | OPT_FMT_SMIME | \ OPT_FMT_ENGINE | OPT_FMT_MSBLOB | OPT_FMT_NETSCAPE | \ diff --git a/apps/cms.c b/apps/cms.c index 7bc40d5d2f..84cea9d1b3 100644 --- a/apps/cms.c +++ b/apps/cms.c @@ -134,8 +134,8 @@ OPTIONS cms_options[] = { " cert.pem... recipient certs for encryption\n"}, {OPT_HELP_STR, 1, '-', "Valid options are:\n"}, {"help", OPT_HELP, '-', "Display this summary"}, - {"inform", OPT_INFORM, 'F', "Input format SMIME (default), PEM or DER"}, - {"outform", OPT_OUTFORM, 'F', + {"inform", OPT_INFORM, 'c', "Input format SMIME (default), PEM or DER"}, + {"outform", OPT_OUTFORM, 'c', "Output format SMIME (default), PEM or DER"}, {"in", OPT_IN, '<', "Input file"}, {"out", OPT_OUT, '>', "Output file"}, @@ -278,11 +278,11 @@ int cms_main(int argc, char **argv) ret = 0; goto end; case OPT_INFORM: - if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &informat)) + if (!opt_format(opt_arg(), OPT_FMT_PDS, &informat)) goto opthelp; break; case OPT_OUTFORM: - if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &outformat)) + if (!opt_format(opt_arg(), OPT_FMT_PDS, &outformat)) goto opthelp; break; case OPT_OUT: diff --git a/apps/opt.c b/apps/opt.c index 82ac5a804e..84e8661a93 100644 --- a/apps/opt.c +++ b/apps/opt.c @@ -180,7 +180,7 @@ char *opt_init(int ac, char **av, const OPTIONS *o) switch (i) { case 0: case '-': case '/': case '<': case '>': case 'E': case 'F': case 'M': case 'U': case 'f': case 'l': case 'n': case 'p': case 's': - case 'u': + case 'u': case 'c': break; default: assert(0); @@ -756,10 +756,12 @@ int opt_next(void) return -1; } break; + case 'c': case 'E': case 'F': case 'f': if (opt_format(arg, + o->valtype == 'c' ? OPT_FMT_PDS : o->valtype == 'E' ? OPT_FMT_PDE : o->valtype == 'F' ? OPT_FMT_PEMDER : OPT_FMT_ANY, &ival)) diff --git a/apps/smime.c b/apps/smime.c index 3257a23396..cd68e55196 100644 --- a/apps/smime.c +++ b/apps/smime.c @@ -115,15 +115,15 @@ OPTIONS smime_options[] = { {"noattr", OPT_NOATTR, '-', "Don't include any signed attributes"}, {"binary", OPT_BINARY, '-', "Don't translate message to text"}, {"certfile", OPT_CERTFILE, '<', "Other certificates file"}, - {"signer", OPT_SIGNER, '<', "Signer certificate file"}, + {"signer", OPT_SIGNER, 's', "Signer certificate file"}, {"recip", OPT_RECIP, '<', "Recipient certificate file for decryption"}, {"in", OPT_IN, '<', "Input file"}, - {"inform", OPT_INFORM, 'F', "Input format SMIME (default), PEM or DER"}, + {"inform", OPT_INFORM, 'c', "Input format SMIME (default), PEM or DER"}, {"inkey", OPT_INKEY, '<', "Input private key (if not signer or recipient)"}, {"keyform", OPT_KEYFORM, 'f', "Input private key format (PEM or ENGINE)"}, {"out", OPT_OUT, '>', "Output file"}, - {"outform", OPT_OUTFORM, 'F', + {"outform", OPT_OUTFORM, 'c', "Output format SMIME (default), PEM or DER"}, {"content", OPT_CONTENT, '<', "Supply or override content for detached signature"}, @@ -200,14 +200,14 @@ int smime_main(int argc, char **argv) ret = 0; goto end; case OPT_INFORM: - if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &informat)) + if (!opt_format(opt_arg(), OPT_FMT_PDS, &informat)) goto opthelp; break; case OPT_IN: infile = opt_arg(); break; case OPT_OUTFORM: - if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &outformat)) + if (!opt_format(opt_arg(), OPT_FMT_PDS, &outformat)) goto opthelp; break; case OPT_OUT: -- 2.25.1