| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2018-01-09 12:49:01 +08:00
										 |  |  |  * Copyright 2008-2018 The OpenSSL Project Authors. All Rights Reserved. | 
					
						
							| 
									
										
										
										
											2008-03-13 05:14:28 +08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2016-05-18 02:18:30 +08:00
										 |  |  |  * Licensed under the OpenSSL license (the "License").  You may not use | 
					
						
							|  |  |  |  * this file except in compliance with the License.  You can obtain a copy | 
					
						
							|  |  |  |  * in the file LICENSE in the source distribution or at | 
					
						
							|  |  |  |  * https://www.openssl.org/source/license.html
 | 
					
						
							| 
									
										
										
										
											2008-03-13 05:14:28 +08:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* CMS utility function */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <stdio.h>
 | 
					
						
							|  |  |  | #include <string.h>
 | 
					
						
							|  |  |  | #include "apps.h"
 | 
					
						
							| 
									
										
										
										
											2018-01-31 18:13:10 +08:00
										 |  |  | #include "progs.h"
 | 
					
						
							| 
									
										
										
										
											2008-03-13 05:14:28 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifndef OPENSSL_NO_CMS
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | # include <openssl/crypto.h>
 | 
					
						
							|  |  |  | # include <openssl/pem.h>
 | 
					
						
							|  |  |  | # include <openssl/err.h>
 | 
					
						
							|  |  |  | # include <openssl/x509_vfy.h>
 | 
					
						
							|  |  |  | # include <openssl/x509v3.h>
 | 
					
						
							|  |  |  | # include <openssl/cms.h>
 | 
					
						
							| 
									
										
										
										
											2008-03-13 05:14:28 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | static int save_certs(char *signerfile, STACK_OF(X509) *signers); | 
					
						
							| 
									
										
										
										
											2008-04-10 06:09:45 +08:00
										 |  |  | static int cms_cb(int ok, X509_STORE_CTX *ctx); | 
					
						
							| 
									
										
										
										
											2015-04-29 23:27:08 +08:00
										 |  |  | static void receipt_request_print(CMS_ContentInfo *cms); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | static CMS_ReceiptRequest *make_receipt_request(STACK_OF(OPENSSL_STRING) | 
					
						
							|  |  |  |                                                 *rr_to, int rr_allorfirst, STACK_OF(OPENSSL_STRING) | 
					
						
							|  |  |  |                                                 *rr_from); | 
					
						
							| 
									
										
										
										
											2013-06-20 01:24:00 +08:00
										 |  |  | static int cms_set_pkey_param(EVP_PKEY_CTX *pctx, | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                               STACK_OF(OPENSSL_STRING) *param); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # define SMIME_OP        0x10
 | 
					
						
							|  |  |  | # define SMIME_IP        0x20
 | 
					
						
							|  |  |  | # define SMIME_SIGNERS   0x40
 | 
					
						
							|  |  |  | # define SMIME_ENCRYPT           (1 | SMIME_OP)
 | 
					
						
							|  |  |  | # define SMIME_DECRYPT           (2 | SMIME_IP)
 | 
					
						
							|  |  |  | # define SMIME_SIGN              (3 | SMIME_OP | SMIME_SIGNERS)
 | 
					
						
							|  |  |  | # define SMIME_VERIFY            (4 | SMIME_IP)
 | 
					
						
							|  |  |  | # define SMIME_CMSOUT            (5 | SMIME_IP | SMIME_OP)
 | 
					
						
							|  |  |  | # define SMIME_RESIGN            (6 | SMIME_IP | SMIME_OP | SMIME_SIGNERS)
 | 
					
						
							|  |  |  | # define SMIME_DATAOUT           (7 | SMIME_IP)
 | 
					
						
							|  |  |  | # define SMIME_DATA_CREATE       (8 | SMIME_OP)
 | 
					
						
							|  |  |  | # define SMIME_DIGEST_VERIFY     (9 | SMIME_IP)
 | 
					
						
							|  |  |  | # define SMIME_DIGEST_CREATE     (10 | SMIME_OP)
 | 
					
						
							|  |  |  | # define SMIME_UNCOMPRESS        (11 | SMIME_IP)
 | 
					
						
							|  |  |  | # define SMIME_COMPRESS          (12 | SMIME_OP)
 | 
					
						
							|  |  |  | # define SMIME_ENCRYPTED_DECRYPT (13 | SMIME_IP)
 | 
					
						
							|  |  |  | # define SMIME_ENCRYPTED_ENCRYPT (14 | SMIME_OP)
 | 
					
						
							|  |  |  | # define SMIME_SIGN_RECEIPT      (15 | SMIME_IP | SMIME_OP)
 | 
					
						
							|  |  |  | # define SMIME_VERIFY_RECEIPT    (16 | SMIME_IP)
 | 
					
						
							| 
									
										
										
										
											2008-03-13 05:14:28 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-05 20:32:58 +08:00
										 |  |  | static int verify_err = 0; | 
					
						
							| 
									
										
										
										
											2008-07-13 22:25:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-20 01:24:00 +08:00
										 |  |  | typedef struct cms_key_param_st cms_key_param; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | struct cms_key_param_st { | 
					
						
							|  |  |  |     int idx; | 
					
						
							|  |  |  |     STACK_OF(OPENSSL_STRING) *param; | 
					
						
							|  |  |  |     cms_key_param *next; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2013-06-20 01:24:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  | typedef enum OPTION_choice { | 
					
						
							|  |  |  |     OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, | 
					
						
							|  |  |  |     OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_ENCRYPT, | 
					
						
							|  |  |  |     OPT_DECRYPT, OPT_SIGN, OPT_SIGN_RECEIPT, OPT_RESIGN, | 
					
						
							|  |  |  |     OPT_VERIFY, OPT_VERIFY_RETCODE, OPT_VERIFY_RECEIPT, | 
					
						
							|  |  |  |     OPT_CMSOUT, OPT_DATA_OUT, OPT_DATA_CREATE, OPT_DIGEST_VERIFY, | 
					
						
							|  |  |  |     OPT_DIGEST_CREATE, OPT_COMPRESS, OPT_UNCOMPRESS, | 
					
						
							|  |  |  |     OPT_ED_DECRYPT, OPT_ED_ENCRYPT, OPT_DEBUG_DECRYPT, OPT_TEXT, | 
					
						
							|  |  |  |     OPT_ASCIICRLF, OPT_NOINTERN, OPT_NOVERIFY, OPT_NOCERTS, | 
					
						
							|  |  |  |     OPT_NOATTR, OPT_NODETACH, OPT_NOSMIMECAP, OPT_BINARY, OPT_KEYID, | 
					
						
							|  |  |  |     OPT_NOSIGS, OPT_NO_CONTENT_VERIFY, OPT_NO_ATTR_VERIFY, OPT_INDEF, | 
					
						
							| 
									
										
										
										
											2016-09-18 03:29:48 +08:00
										 |  |  |     OPT_NOINDEF, OPT_CRLFEOL, OPT_NOOUT, OPT_RR_PRINT, | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     OPT_RR_ALL, OPT_RR_FIRST, OPT_RCTFORM, OPT_CERTFILE, OPT_CAFILE, | 
					
						
							| 
									
										
										
										
											2015-09-22 23:00:52 +08:00
										 |  |  |     OPT_CAPATH, OPT_NOCAPATH, OPT_NOCAFILE,OPT_CONTENT, OPT_PRINT, | 
					
						
							|  |  |  |     OPT_SECRETKEY, OPT_SECRETKEYID, OPT_PWRI_PASSWORD, OPT_ECONTENT_TYPE, | 
					
						
							| 
									
										
										
										
											2017-07-05 22:58:48 +08:00
										 |  |  |     OPT_PASSIN, OPT_TO, OPT_FROM, OPT_SUBJECT, OPT_SIGNER, OPT_RECIP, | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     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_3DES_WRAP, OPT_ENGINE, | 
					
						
							| 
									
										
										
										
											2017-07-05 22:58:48 +08:00
										 |  |  |     OPT_R_ENUM, | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     OPT_V_ENUM, | 
					
						
							|  |  |  |     OPT_CIPHER | 
					
						
							|  |  |  | } OPTION_CHOICE; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-13 21:07:50 +08:00
										 |  |  | const OPTIONS cms_options[] = { | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     {OPT_HELP_STR, 1, '-', "Usage: %s [options] cert.pem...\n"}, | 
					
						
							|  |  |  |     {OPT_HELP_STR, 1, '-', | 
					
						
							|  |  |  |         "  cert.pem... recipient certs for encryption\n"}, | 
					
						
							|  |  |  |     {OPT_HELP_STR, 1, '-', "Valid options are:\n"}, | 
					
						
							|  |  |  |     {"help", OPT_HELP, '-', "Display this summary"}, | 
					
						
							| 
									
										
										
										
											2016-05-13 00:13:50 +08:00
										 |  |  |     {"inform", OPT_INFORM, 'c', "Input format SMIME (default), PEM or DER"}, | 
					
						
							|  |  |  |     {"outform", OPT_OUTFORM, 'c', | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |      "Output format SMIME (default), PEM or DER"}, | 
					
						
							|  |  |  |     {"in", OPT_IN, '<', "Input file"}, | 
					
						
							|  |  |  |     {"out", OPT_OUT, '>', "Output file"}, | 
					
						
							|  |  |  |     {"encrypt", OPT_ENCRYPT, '-', "Encrypt message"}, | 
					
						
							|  |  |  |     {"decrypt", OPT_DECRYPT, '-', "Decrypt encrypted message"}, | 
					
						
							|  |  |  |     {"sign", OPT_SIGN, '-', "Sign message"}, | 
					
						
							| 
									
										
										
										
											2016-03-21 04:14:10 +08:00
										 |  |  |     {"sign_receipt", OPT_SIGN_RECEIPT, '-', "Generate a signed receipt for the message"}, | 
					
						
							| 
									
										
										
										
											2016-08-01 01:02:50 +08:00
										 |  |  |     {"resign", OPT_RESIGN, '-', "Resign a signed message"}, | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     {"verify", OPT_VERIFY, '-', "Verify signed message"}, | 
					
						
							|  |  |  |     {"verify_retcode", OPT_VERIFY_RETCODE, '-'}, | 
					
						
							|  |  |  |     {"verify_receipt", OPT_VERIFY_RECEIPT, '<'}, | 
					
						
							|  |  |  |     {"cmsout", OPT_CMSOUT, '-', "Output CMS structure"}, | 
					
						
							|  |  |  |     {"data_out", OPT_DATA_OUT, '-'}, | 
					
						
							|  |  |  |     {"data_create", OPT_DATA_CREATE, '-'}, | 
					
						
							|  |  |  |     {"digest_verify", OPT_DIGEST_VERIFY, '-'}, | 
					
						
							|  |  |  |     {"digest_create", OPT_DIGEST_CREATE, '-'}, | 
					
						
							|  |  |  |     {"compress", OPT_COMPRESS, '-'}, | 
					
						
							|  |  |  |     {"uncompress", OPT_UNCOMPRESS, '-'}, | 
					
						
							|  |  |  |     {"EncryptedData_decrypt", OPT_ED_DECRYPT, '-'}, | 
					
						
							|  |  |  |     {"EncryptedData_encrypt", OPT_ED_ENCRYPT, '-'}, | 
					
						
							|  |  |  |     {"debug_decrypt", OPT_DEBUG_DECRYPT, '-'}, | 
					
						
							|  |  |  |     {"text", OPT_TEXT, '-', "Include or delete text MIME headers"}, | 
					
						
							|  |  |  |     {"asciicrlf", OPT_ASCIICRLF, '-'}, | 
					
						
							|  |  |  |     {"nointern", OPT_NOINTERN, '-', | 
					
						
							|  |  |  |      "Don't search certificates in message for signer"}, | 
					
						
							|  |  |  |     {"noverify", OPT_NOVERIFY, '-', "Don't verify signers certificate"}, | 
					
						
							|  |  |  |     {"nocerts", OPT_NOCERTS, '-', | 
					
						
							|  |  |  |      "Don't include signers certificate when signing"}, | 
					
						
							|  |  |  |     {"noattr", OPT_NOATTR, '-', "Don't include any signed attributes"}, | 
					
						
							|  |  |  |     {"nodetach", OPT_NODETACH, '-', "Use opaque signing"}, | 
					
						
							| 
									
										
										
										
											2016-08-01 01:02:50 +08:00
										 |  |  |     {"nosmimecap", OPT_NOSMIMECAP, '-', "Omit the SMIMECapabilities attribute"}, | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     {"binary", OPT_BINARY, '-', "Don't translate message to text"}, | 
					
						
							|  |  |  |     {"keyid", OPT_KEYID, '-', "Use subject key identifier"}, | 
					
						
							|  |  |  |     {"nosigs", OPT_NOSIGS, '-', "Don't verify message signature"}, | 
					
						
							|  |  |  |     {"no_content_verify", OPT_NO_CONTENT_VERIFY, '-'}, | 
					
						
							|  |  |  |     {"no_attr_verify", OPT_NO_ATTR_VERIFY, '-'}, | 
					
						
							| 
									
										
										
										
											2016-08-01 01:02:50 +08:00
										 |  |  |     {"stream", OPT_INDEF, '-', "Enable CMS streaming"}, | 
					
						
							|  |  |  |     {"indef", OPT_INDEF, '-', "Same as -stream"}, | 
					
						
							|  |  |  |     {"noindef", OPT_NOINDEF, '-', "Disable CMS streaming"}, | 
					
						
							|  |  |  |     {"crlfeol", OPT_CRLFEOL, '-', "Use CRLF as EOL termination instead of CR only" }, | 
					
						
							| 
									
										
										
										
											2016-03-21 04:14:10 +08:00
										 |  |  |     {"noout", OPT_NOOUT, '-', "For the -cmsout operation do not output the parsed CMS structure"}, | 
					
						
							| 
									
										
										
										
											2016-08-01 01:02:50 +08:00
										 |  |  |     {"receipt_request_print", OPT_RR_PRINT, '-', "Print CMS Receipt Request" }, | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     {"receipt_request_all", OPT_RR_ALL, '-'}, | 
					
						
							|  |  |  |     {"receipt_request_first", OPT_RR_FIRST, '-'}, | 
					
						
							| 
									
										
										
										
											2016-08-01 01:02:50 +08:00
										 |  |  |     {"rctform", OPT_RCTFORM, 'F', "Receipt file format"}, | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     {"certfile", OPT_CERTFILE, '<', "Other certificates file"}, | 
					
						
							|  |  |  |     {"CAfile", OPT_CAFILE, '<', "Trusted certificates file"}, | 
					
						
							|  |  |  |     {"CApath", OPT_CAPATH, '/', "trusted certificates directory"}, | 
					
						
							| 
									
										
										
										
											2015-09-22 23:00:52 +08:00
										 |  |  |     {"no-CAfile", OPT_NOCAFILE, '-', | 
					
						
							|  |  |  |      "Do not load the default certificates file"}, | 
					
						
							|  |  |  |     {"no-CApath", OPT_NOCAPATH, '-', | 
					
						
							|  |  |  |      "Do not load certificates from the default certificates directory"}, | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     {"content", OPT_CONTENT, '<', | 
					
						
							|  |  |  |      "Supply or override content for detached signature"}, | 
					
						
							| 
									
										
										
										
											2016-10-11 00:01:24 +08:00
										 |  |  |     {"print", OPT_PRINT, '-', | 
					
						
							| 
									
										
										
										
											2016-08-01 01:02:50 +08:00
										 |  |  |      "For the -cmsout operation print out all fields of the CMS structure"}, | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     {"secretkey", OPT_SECRETKEY, 's'}, | 
					
						
							|  |  |  |     {"secretkeyid", OPT_SECRETKEYID, 's'}, | 
					
						
							|  |  |  |     {"pwri_password", OPT_PWRI_PASSWORD, 's'}, | 
					
						
							|  |  |  |     {"econtent_type", OPT_ECONTENT_TYPE, 's'}, | 
					
						
							|  |  |  |     {"passin", OPT_PASSIN, 's', "Input file pass phrase source"}, | 
					
						
							|  |  |  |     {"to", OPT_TO, 's', "To address"}, | 
					
						
							|  |  |  |     {"from", OPT_FROM, 's', "From address"}, | 
					
						
							|  |  |  |     {"subject", OPT_SUBJECT, 's', "Subject"}, | 
					
						
							|  |  |  |     {"signer", OPT_SIGNER, 's', "Signer certificate file"}, | 
					
						
							|  |  |  |     {"recip", OPT_RECIP, '<', "Recipient cert file for decryption"}, | 
					
						
							|  |  |  |     {"certsout", OPT_CERTSOUT, '>', "Certificate output file"}, | 
					
						
							| 
									
										
										
										
											2016-03-21 04:14:10 +08:00
										 |  |  |     {"md", OPT_MD, 's', "Digest algorithm to use when signing or resigning"}, | 
					
						
							| 
									
										
										
										
											2016-02-11 23:51:31 +08:00
										 |  |  |     {"inkey", OPT_INKEY, 's', | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |      "Input private key (if not signer or recipient)"}, | 
					
						
							|  |  |  |     {"keyform", OPT_KEYFORM, 'f', "Input private key format (PEM or ENGINE)"}, | 
					
						
							|  |  |  |     {"keyopt", OPT_KEYOPT, 's', "Set public key parameters as n:v pairs"}, | 
					
						
							|  |  |  |     {"receipt_request_from", OPT_RR_FROM, 's'}, | 
					
						
							|  |  |  |     {"receipt_request_to", OPT_RR_TO, 's'}, | 
					
						
							| 
									
										
										
										
											2015-05-16 01:50:38 +08:00
										 |  |  |     {"", OPT_CIPHER, '-', "Any supported cipher"}, | 
					
						
							| 
									
										
										
										
											2017-07-05 22:58:48 +08:00
										 |  |  |     OPT_R_OPTIONS, | 
					
						
							| 
									
										
										
										
											2015-05-16 01:50:38 +08:00
										 |  |  |     OPT_V_OPTIONS, | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     {"aes128-wrap", OPT_AES128_WRAP, '-', "Use AES128 to wrap key"}, | 
					
						
							|  |  |  |     {"aes192-wrap", OPT_AES192_WRAP, '-', "Use AES192 to wrap key"}, | 
					
						
							|  |  |  |     {"aes256-wrap", OPT_AES256_WRAP, '-', "Use AES256 to wrap key"}, | 
					
						
							|  |  |  | # ifndef OPENSSL_NO_DES
 | 
					
						
							|  |  |  |     {"des3-wrap", OPT_3DES_WRAP, '-', "Use 3DES-EDE to wrap key"}, | 
					
						
							|  |  |  | # endif
 | 
					
						
							|  |  |  | # ifndef OPENSSL_NO_ENGINE
 | 
					
						
							|  |  |  |     {"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"}, | 
					
						
							|  |  |  | # endif
 | 
					
						
							| 
									
										
										
										
											2015-05-16 01:50:38 +08:00
										 |  |  |     {NULL} | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2008-03-13 05:14:28 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  | int cms_main(int argc, char **argv) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | { | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     ASN1_OBJECT *econtent_type = NULL; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     BIO *in = NULL, *out = NULL, *indata = NULL, *rctin = NULL; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     CMS_ContentInfo *cms = NULL, *rcms = NULL; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     CMS_ReceiptRequest *rr = NULL; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     ENGINE *e = NULL; | 
					
						
							|  |  |  |     EVP_PKEY *key = NULL; | 
					
						
							|  |  |  |     const EVP_CIPHER *cipher = NULL, *wrap_cipher = NULL; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     const EVP_MD *sign_md = NULL; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     STACK_OF(OPENSSL_STRING) *rr_to = NULL, *rr_from = NULL; | 
					
						
							|  |  |  |     STACK_OF(OPENSSL_STRING) *sksigners = NULL, *skkeys = NULL; | 
					
						
							|  |  |  |     STACK_OF(X509) *encerts = NULL, *other = NULL; | 
					
						
							|  |  |  |     X509 *cert = NULL, *recip = NULL, *signer = NULL; | 
					
						
							|  |  |  |     X509_STORE *store = NULL; | 
					
						
							|  |  |  |     X509_VERIFY_PARAM *vpm = NULL; | 
					
						
							|  |  |  |     char *certfile = NULL, *keyfile = NULL, *contfile = NULL; | 
					
						
							| 
									
										
										
										
											2016-08-05 05:52:22 +08:00
										 |  |  |     const char *CAfile = NULL, *CApath = NULL; | 
					
						
							|  |  |  |     char *certsoutfile = NULL; | 
					
						
							| 
									
										
										
										
											2015-09-22 23:00:52 +08:00
										 |  |  |     int noCAfile = 0, noCApath = 0; | 
					
						
							| 
									
										
										
										
											2017-07-05 22:58:48 +08:00
										 |  |  |     char *infile = NULL, *outfile = NULL, *rctfile = NULL; | 
					
						
							|  |  |  |     char *passinarg = NULL, *passin = NULL, *signerfile = NULL, *recipfile = NULL; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     char *to = NULL, *from = NULL, *subject = NULL, *prog; | 
					
						
							|  |  |  |     cms_key_param *key_first = NULL, *key_param = NULL; | 
					
						
							| 
									
										
										
										
											2017-07-05 22:58:48 +08:00
										 |  |  |     int flags = CMS_DETACHED, noout = 0, print = 0, keyidx = -1, vpmtouched = 0; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     int informat = FORMAT_SMIME, outformat = FORMAT_SMIME; | 
					
						
							| 
									
										
										
										
											2017-07-05 22:58:48 +08:00
										 |  |  |     int operation = 0, ret = 1, rr_print = 0, rr_allorfirst = -1; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     int verify_retcode = 0, rctformat = FORMAT_SMIME, keyform = FORMAT_PEM; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     size_t secret_keylen = 0, secret_keyidlen = 0; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     unsigned char *pwri_pass = NULL, *pwri_tmp = NULL; | 
					
						
							|  |  |  |     unsigned char *secret_key = NULL, *secret_keyid = NULL; | 
					
						
							|  |  |  |     long ltmp; | 
					
						
							| 
									
										
										
										
											2016-05-20 00:22:57 +08:00
										 |  |  |     const char *mime_eol = "\n"; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     OPTION_CHOICE o; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     if ((vpm = X509_VERIFY_PARAM_new()) == NULL) | 
					
						
							|  |  |  |         return 1; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     prog = opt_init(argc, argv, cms_options); | 
					
						
							|  |  |  |     while ((o = opt_next()) != OPT_EOF) { | 
					
						
							|  |  |  |         switch (o) { | 
					
						
							|  |  |  |         case OPT_EOF: | 
					
						
							|  |  |  |         case OPT_ERR: | 
					
						
							|  |  |  |  opthelp: | 
					
						
							|  |  |  |             BIO_printf(bio_err, "%s: Use -help for summary.\n", prog); | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |         case OPT_HELP: | 
					
						
							|  |  |  |             opt_help(cms_options); | 
					
						
							|  |  |  |             ret = 0; | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |         case OPT_INFORM: | 
					
						
							| 
									
										
										
										
											2016-05-13 00:13:50 +08:00
										 |  |  |             if (!opt_format(opt_arg(), OPT_FMT_PDS, &informat)) | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |                 goto opthelp; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_OUTFORM: | 
					
						
							| 
									
										
										
										
											2016-05-13 00:13:50 +08:00
										 |  |  |             if (!opt_format(opt_arg(), OPT_FMT_PDS, &outformat)) | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |                 goto opthelp; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_OUT: | 
					
						
							|  |  |  |             outfile = opt_arg(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_ENCRYPT: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             operation = SMIME_ENCRYPT; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_DECRYPT: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             operation = SMIME_DECRYPT; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_SIGN: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             operation = SMIME_SIGN; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_SIGN_RECEIPT: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             operation = SMIME_SIGN_RECEIPT; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_RESIGN: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             operation = SMIME_RESIGN; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_VERIFY: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             operation = SMIME_VERIFY; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_VERIFY_RETCODE: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             verify_retcode = 1; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_VERIFY_RECEIPT: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             operation = SMIME_VERIFY_RECEIPT; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             rctfile = opt_arg(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_CMSOUT: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             operation = SMIME_CMSOUT; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_DATA_OUT: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             operation = SMIME_DATAOUT; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_DATA_CREATE: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             operation = SMIME_DATA_CREATE; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_DIGEST_VERIFY: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             operation = SMIME_DIGEST_VERIFY; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_DIGEST_CREATE: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             operation = SMIME_DIGEST_CREATE; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_COMPRESS: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             operation = SMIME_COMPRESS; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_UNCOMPRESS: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             operation = SMIME_UNCOMPRESS; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_ED_DECRYPT: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             operation = SMIME_ENCRYPTED_DECRYPT; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_ED_ENCRYPT: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             operation = SMIME_ENCRYPTED_ENCRYPT; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_DEBUG_DECRYPT: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             flags |= CMS_DEBUG_DECRYPT; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_TEXT: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             flags |= CMS_TEXT; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_ASCIICRLF: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             flags |= CMS_ASCIICRLF; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_NOINTERN: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             flags |= CMS_NOINTERN; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_NOVERIFY: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             flags |= CMS_NO_SIGNER_CERT_VERIFY; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_NOCERTS: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             flags |= CMS_NOCERTS; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_NOATTR: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             flags |= CMS_NOATTR; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_NODETACH: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             flags &= ~CMS_DETACHED; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_NOSMIMECAP: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             flags |= CMS_NOSMIMECAP; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_BINARY: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             flags |= CMS_BINARY; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_KEYID: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             flags |= CMS_USE_KEYID; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_NOSIGS: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             flags |= CMS_NOSIGS; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_NO_CONTENT_VERIFY: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             flags |= CMS_NO_CONTENT_VERIFY; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_NO_ATTR_VERIFY: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             flags |= CMS_NO_ATTR_VERIFY; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_INDEF: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             flags |= CMS_STREAM; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_NOINDEF: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             flags &= ~CMS_STREAM; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_CRLFEOL: | 
					
						
							| 
									
										
										
										
											2016-05-20 00:22:57 +08:00
										 |  |  |             mime_eol = "\r\n"; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             flags |= CMS_CRLFEOL; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_NOOUT: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             noout = 1; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_RR_PRINT: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             rr_print = 1; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_RR_ALL: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             rr_allorfirst = 0; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_RR_FIRST: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             rr_allorfirst = 1; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_RCTFORM: | 
					
						
							|  |  |  |             if (rctformat == FORMAT_SMIME) | 
					
						
							|  |  |  |                 rcms = SMIME_read_CMS(rctin, NULL); | 
					
						
							|  |  |  |             else if (rctformat == FORMAT_PEM) | 
					
						
							|  |  |  |                 rcms = PEM_read_bio_CMS(rctin, NULL, NULL, NULL); | 
					
						
							|  |  |  |             else if (rctformat == FORMAT_ASN1) | 
					
						
							|  |  |  |                 if (!opt_format(opt_arg(), | 
					
						
							|  |  |  |                                 OPT_FMT_PEMDER | OPT_FMT_SMIME, &rctformat)) | 
					
						
							|  |  |  |                     goto opthelp; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_CERTFILE: | 
					
						
							|  |  |  |             certfile = opt_arg(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_CAFILE: | 
					
						
							|  |  |  |             CAfile = opt_arg(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_CAPATH: | 
					
						
							|  |  |  |             CApath = opt_arg(); | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2015-09-22 23:00:52 +08:00
										 |  |  |         case OPT_NOCAFILE: | 
					
						
							|  |  |  |             noCAfile = 1; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_NOCAPATH: | 
					
						
							|  |  |  |             noCApath = 1; | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |         case OPT_IN: | 
					
						
							|  |  |  |             infile = opt_arg(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_CONTENT: | 
					
						
							|  |  |  |             contfile = opt_arg(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_RR_FROM: | 
					
						
							|  |  |  |             if (rr_from == NULL | 
					
						
							|  |  |  |                 && (rr_from = sk_OPENSSL_STRING_new_null()) == NULL) | 
					
						
							|  |  |  |                 goto end; | 
					
						
							|  |  |  |             sk_OPENSSL_STRING_push(rr_from, opt_arg()); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_RR_TO: | 
					
						
							|  |  |  |             if (rr_to == NULL | 
					
						
							|  |  |  |                 && (rr_to = sk_OPENSSL_STRING_new_null()) == NULL) | 
					
						
							|  |  |  |                 goto end; | 
					
						
							|  |  |  |             sk_OPENSSL_STRING_push(rr_to, opt_arg()); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_PRINT: | 
					
						
							|  |  |  |             noout = print = 1; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_SECRETKEY: | 
					
						
							| 
									
										
										
										
											2016-08-24 18:22:47 +08:00
										 |  |  |             if (secret_key != NULL) { | 
					
						
							| 
									
										
										
										
											2016-08-24 20:36:07 +08:00
										 |  |  |                 BIO_printf(bio_err, "Invalid key (supplied twice) %s\n", | 
					
						
							|  |  |  |                            opt_arg()); | 
					
						
							| 
									
										
										
										
											2016-08-24 18:22:47 +08:00
										 |  |  |                 goto opthelp; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2016-04-14 03:58:28 +08:00
										 |  |  |             secret_key = OPENSSL_hexstr2buf(opt_arg(), <mp); | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             if (secret_key == NULL) { | 
					
						
							|  |  |  |                 BIO_printf(bio_err, "Invalid key %s\n", opt_arg()); | 
					
						
							|  |  |  |                 goto end; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             } | 
					
						
							|  |  |  |             secret_keylen = (size_t)ltmp; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_SECRETKEYID: | 
					
						
							| 
									
										
										
										
											2016-08-24 18:22:47 +08:00
										 |  |  |             if (secret_keyid != NULL) { | 
					
						
							| 
									
										
										
										
											2016-08-24 20:36:07 +08:00
										 |  |  |                 BIO_printf(bio_err, "Invalid id (supplied twice) %s\n", | 
					
						
							|  |  |  |                            opt_arg()); | 
					
						
							| 
									
										
										
										
											2016-08-24 18:22:47 +08:00
										 |  |  |                 goto opthelp; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2016-04-14 03:58:28 +08:00
										 |  |  |             secret_keyid = OPENSSL_hexstr2buf(opt_arg(), <mp); | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             if (secret_keyid == NULL) { | 
					
						
							|  |  |  |                 BIO_printf(bio_err, "Invalid id %s\n", opt_arg()); | 
					
						
							|  |  |  |                 goto opthelp; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             } | 
					
						
							|  |  |  |             secret_keyidlen = (size_t)ltmp; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_PWRI_PASSWORD: | 
					
						
							|  |  |  |             pwri_pass = (unsigned char *)opt_arg(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_ECONTENT_TYPE: | 
					
						
							| 
									
										
										
										
											2016-08-24 18:22:47 +08:00
										 |  |  |             if (econtent_type != NULL) { | 
					
						
							| 
									
										
										
										
											2016-08-24 20:36:07 +08:00
										 |  |  |                 BIO_printf(bio_err, "Invalid OID (supplied twice) %s\n", | 
					
						
							|  |  |  |                            opt_arg()); | 
					
						
							| 
									
										
										
										
											2016-08-24 18:22:47 +08:00
										 |  |  |                 goto opthelp; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             econtent_type = OBJ_txt2obj(opt_arg(), 0); | 
					
						
							|  |  |  |             if (econtent_type == NULL) { | 
					
						
							|  |  |  |                 BIO_printf(bio_err, "Invalid OID %s\n", opt_arg()); | 
					
						
							|  |  |  |                 goto opthelp; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             } | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_ENGINE: | 
					
						
							| 
									
										
										
										
											2015-04-26 03:41:29 +08:00
										 |  |  |             e = setup_engine(opt_arg(), 0); | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_PASSIN: | 
					
						
							|  |  |  |             passinarg = opt_arg(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_TO: | 
					
						
							|  |  |  |             to = opt_arg(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_FROM: | 
					
						
							|  |  |  |             from = opt_arg(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_SUBJECT: | 
					
						
							|  |  |  |             subject = opt_arg(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_CERTSOUT: | 
					
						
							|  |  |  |             certsoutfile = opt_arg(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_MD: | 
					
						
							|  |  |  |             if (!opt_md(opt_arg(), &sign_md)) | 
					
						
							|  |  |  |                 goto end; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_SIGNER: | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             /* If previous -signer argument add signer to list */ | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             if (signerfile != NULL) { | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |                 if (sksigners == NULL | 
					
						
							|  |  |  |                     && (sksigners = sk_OPENSSL_STRING_new_null()) == NULL) | 
					
						
							|  |  |  |                     goto end; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 sk_OPENSSL_STRING_push(sksigners, signerfile); | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |                 if (keyfile == NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                     keyfile = signerfile; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |                 if (skkeys == NULL | 
					
						
							|  |  |  |                     && (skkeys = sk_OPENSSL_STRING_new_null()) == NULL) | 
					
						
							|  |  |  |                     goto end; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 sk_OPENSSL_STRING_push(skkeys, keyfile); | 
					
						
							|  |  |  |                 keyfile = NULL; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             signerfile = opt_arg(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_INKEY: | 
					
						
							| 
									
										
										
										
											2016-07-06 03:22:18 +08:00
										 |  |  |             /* If previous -inkey argument add signer to list */ | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             if (keyfile != NULL) { | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |                 if (signerfile == NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                     BIO_puts(bio_err, "Illegal -inkey without -signer\n"); | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |                     goto end; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 } | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |                 if (sksigners == NULL | 
					
						
							|  |  |  |                     && (sksigners = sk_OPENSSL_STRING_new_null()) == NULL) | 
					
						
							|  |  |  |                     goto end; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 sk_OPENSSL_STRING_push(sksigners, signerfile); | 
					
						
							|  |  |  |                 signerfile = NULL; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |                 if (skkeys == NULL | 
					
						
							|  |  |  |                     && (skkeys = sk_OPENSSL_STRING_new_null()) == NULL) | 
					
						
							|  |  |  |                     goto end; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 sk_OPENSSL_STRING_push(skkeys, keyfile); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             keyfile = opt_arg(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_KEYFORM: | 
					
						
							|  |  |  |             if (!opt_format(opt_arg(), OPT_FMT_ANY, &keyform)) | 
					
						
							|  |  |  |                 goto opthelp; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_RECIP: | 
					
						
							|  |  |  |             if (operation == SMIME_ENCRYPT) { | 
					
						
							|  |  |  |                 if (encerts == NULL && (encerts = sk_X509_new_null()) == NULL) | 
					
						
							|  |  |  |                     goto end; | 
					
						
							| 
									
										
										
										
											2016-02-14 11:33:56 +08:00
										 |  |  |                 cert = load_cert(opt_arg(), FORMAT_PEM, | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |                                  "recipient certificate file"); | 
					
						
							|  |  |  |                 if (cert == NULL) | 
					
						
							|  |  |  |                     goto end; | 
					
						
							|  |  |  |                 sk_X509_push(encerts, cert); | 
					
						
							|  |  |  |                 cert = NULL; | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             } else { | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |                 recipfile = opt_arg(); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             } | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_CIPHER: | 
					
						
							|  |  |  |             if (!opt_cipher(opt_unknown(), &cipher)) | 
					
						
							|  |  |  |                 goto end; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_KEYOPT: | 
					
						
							|  |  |  |             keyidx = -1; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             if (operation == SMIME_ENCRYPT) { | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |                 if (encerts != NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                     keyidx += sk_X509_num(encerts); | 
					
						
							|  |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |                 if (keyfile != NULL || signerfile != NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                     keyidx++; | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |                 if (skkeys != NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                     keyidx += sk_OPENSSL_STRING_num(skkeys); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             if (keyidx < 0) { | 
					
						
							|  |  |  |                 BIO_printf(bio_err, "No key specified\n"); | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |                 goto opthelp; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             } | 
					
						
							|  |  |  |             if (key_param == NULL || key_param->idx != keyidx) { | 
					
						
							|  |  |  |                 cms_key_param *nparam; | 
					
						
							| 
									
										
										
										
											2015-05-02 11:10:31 +08:00
										 |  |  |                 nparam = app_malloc(sizeof(*nparam), "key param buffer"); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 nparam->idx = keyidx; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |                 if ((nparam->param = sk_OPENSSL_STRING_new_null()) == NULL) | 
					
						
							|  |  |  |                     goto end; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 nparam->next = NULL; | 
					
						
							|  |  |  |                 if (key_first == NULL) | 
					
						
							|  |  |  |                     key_first = nparam; | 
					
						
							|  |  |  |                 else | 
					
						
							|  |  |  |                     key_param->next = nparam; | 
					
						
							|  |  |  |                 key_param = nparam; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             sk_OPENSSL_STRING_push(key_param->param, opt_arg()); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_V_CASES: | 
					
						
							|  |  |  |             if (!opt_verify(o, vpm)) | 
					
						
							|  |  |  |                 goto end; | 
					
						
							|  |  |  |             vpmtouched++; | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2017-07-05 22:58:48 +08:00
										 |  |  |         case OPT_R_CASES: | 
					
						
							|  |  |  |             if (!opt_rand(o)) | 
					
						
							|  |  |  |                 goto end; | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |         case OPT_3DES_WRAP: | 
					
						
							| 
									
										
										
										
											2015-05-16 01:50:38 +08:00
										 |  |  | # ifndef OPENSSL_NO_DES
 | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             wrap_cipher = EVP_des_ede3_wrap(); | 
					
						
							|  |  |  | # endif
 | 
					
						
							| 
									
										
										
										
											2015-05-16 01:50:38 +08:00
										 |  |  |             break; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |         case OPT_AES128_WRAP: | 
					
						
							|  |  |  |             wrap_cipher = EVP_aes_128_wrap(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_AES192_WRAP: | 
					
						
							|  |  |  |             wrap_cipher = EVP_aes_192_wrap(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_AES256_WRAP: | 
					
						
							|  |  |  |             wrap_cipher = EVP_aes_256_wrap(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     argc = opt_num_rest(); | 
					
						
							|  |  |  |     argv = opt_rest(); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |     if ((rr_allorfirst != -1 || rr_from != NULL) && rr_to == NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         BIO_puts(bio_err, "No Signed Receipts Recipients\n"); | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |         goto opthelp; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |     if (!(operation & SMIME_SIGNERS) && (rr_to != NULL || rr_from != NULL)) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         BIO_puts(bio_err, "Signed receipts only allowed with -sign\n"); | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |         goto opthelp; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |     if (!(operation & SMIME_SIGNERS) && (skkeys != NULL || sksigners != NULL)) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         BIO_puts(bio_err, "Multiple signers or keys not allowed\n"); | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |         goto opthelp; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (operation & SMIME_SIGNERS) { | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (keyfile != NULL && signerfile == NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             BIO_puts(bio_err, "Illegal -inkey without -signer\n"); | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             goto opthelp; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         } | 
					
						
							|  |  |  |         /* Check to see if any final signer needs to be appended */ | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (signerfile != NULL) { | 
					
						
							|  |  |  |             if (sksigners == NULL | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |                 && (sksigners = sk_OPENSSL_STRING_new_null()) == NULL) | 
					
						
							|  |  |  |                 goto end; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             sk_OPENSSL_STRING_push(sksigners, signerfile); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             if (skkeys == NULL && (skkeys = sk_OPENSSL_STRING_new_null()) == NULL) | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |                 goto end; | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             if (keyfile == NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 keyfile = signerfile; | 
					
						
							|  |  |  |             sk_OPENSSL_STRING_push(skkeys, keyfile); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (sksigners == NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             BIO_printf(bio_err, "No signer certificate specified\n"); | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             goto opthelp; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         } | 
					
						
							|  |  |  |         signerfile = NULL; | 
					
						
							|  |  |  |         keyfile = NULL; | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |     } else if (operation == SMIME_DECRYPT) { | 
					
						
							|  |  |  |         if (recipfile == NULL && keyfile == NULL | 
					
						
							|  |  |  |             && secret_key == NULL && pwri_pass == NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             BIO_printf(bio_err, | 
					
						
							|  |  |  |                        "No recipient certificate or key specified\n"); | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             goto opthelp; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         } | 
					
						
							|  |  |  |     } else if (operation == SMIME_ENCRYPT) { | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (*argv == NULL && secret_key == NULL | 
					
						
							|  |  |  |             && pwri_pass == NULL && encerts == NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             BIO_printf(bio_err, "No recipient(s) certificate(s) specified\n"); | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             goto opthelp; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |     } else if (!operation) { | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |         goto opthelp; | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (!app_passwd(passinarg, NULL, &passin, NULL)) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         BIO_printf(bio_err, "Error getting password\n"); | 
					
						
							|  |  |  |         goto end; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ret = 2; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (!(operation & SMIME_SIGNERS)) | 
					
						
							|  |  |  |         flags &= ~CMS_DETACHED; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |     if (!(operation & SMIME_OP)) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         if (flags & CMS_BINARY) | 
					
						
							| 
									
										
										
										
											2015-09-04 18:49:06 +08:00
										 |  |  |             outformat = FORMAT_BINARY; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |     if (!(operation & SMIME_IP)) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         if (flags & CMS_BINARY) | 
					
						
							| 
									
										
										
										
											2015-09-04 18:49:06 +08:00
										 |  |  |             informat = FORMAT_BINARY; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (operation == SMIME_ENCRYPT) { | 
					
						
							|  |  |  |         if (!cipher) { | 
					
						
							|  |  |  | # ifndef OPENSSL_NO_DES
 | 
					
						
							|  |  |  |             cipher = EVP_des_ede3_cbc(); | 
					
						
							|  |  |  | # else
 | 
					
						
							|  |  |  |             BIO_printf(bio_err, "No cipher selected\n"); | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  | # endif
 | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (secret_key && !secret_keyid) { | 
					
						
							|  |  |  |             BIO_printf(bio_err, "No secret key id\n"); | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (*argv && encerts == NULL) | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             if ((encerts = sk_X509_new_null()) == NULL) | 
					
						
							|  |  |  |                 goto end; | 
					
						
							|  |  |  |         while (*argv) { | 
					
						
							| 
									
										
										
										
											2016-02-14 11:33:56 +08:00
										 |  |  |             if ((cert = load_cert(*argv, FORMAT_PEM, | 
					
						
							| 
									
										
										
										
											2015-05-07 01:43:59 +08:00
										 |  |  |                                   "recipient certificate file")) == NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 goto end; | 
					
						
							|  |  |  |             sk_X509_push(encerts, cert); | 
					
						
							|  |  |  |             cert = NULL; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             argv++; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |     if (certfile != NULL) { | 
					
						
							| 
									
										
										
										
											2016-02-14 11:33:56 +08:00
										 |  |  |         if (!load_certs(certfile, &other, FORMAT_PEM, NULL, | 
					
						
							| 
									
										
										
										
											2016-01-16 13:08:38 +08:00
										 |  |  |                         "certificate file")) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             ERR_print_errors(bio_err); | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |     if (recipfile != NULL && (operation == SMIME_DECRYPT)) { | 
					
						
							| 
									
										
										
										
											2016-02-14 11:33:56 +08:00
										 |  |  |         if ((recip = load_cert(recipfile, FORMAT_PEM, | 
					
						
							| 
									
										
										
										
											2015-05-07 01:43:59 +08:00
										 |  |  |                                "recipient certificate file")) == NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             ERR_print_errors(bio_err); | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (operation == SMIME_SIGN_RECEIPT) { | 
					
						
							| 
									
										
										
										
											2016-02-14 11:33:56 +08:00
										 |  |  |         if ((signer = load_cert(signerfile, FORMAT_PEM, | 
					
						
							| 
									
										
										
										
											2015-05-07 01:43:59 +08:00
										 |  |  |                                 "receipt signer certificate file")) == NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             ERR_print_errors(bio_err); | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (operation == SMIME_DECRYPT) { | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (keyfile == NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             keyfile = recipfile; | 
					
						
							|  |  |  |     } else if ((operation == SMIME_SIGN) || (operation == SMIME_SIGN_RECEIPT)) { | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (keyfile == NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             keyfile = signerfile; | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         keyfile = NULL; | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |     if (keyfile != NULL) { | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |         key = load_key(keyfile, keyform, 0, passin, e, "signing key file"); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (key == NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             goto end; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-04 18:49:06 +08:00
										 |  |  |     in = bio_open_default(infile, 'r', informat); | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     if (in == NULL) | 
					
						
							|  |  |  |         goto end; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (operation & SMIME_IP) { | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (informat == FORMAT_SMIME) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             cms = SMIME_read_CMS(in, &indata); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         } else if (informat == FORMAT_PEM) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             cms = PEM_read_bio_CMS(in, NULL, NULL, NULL); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         } else if (informat == FORMAT_ASN1) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             cms = d2i_CMS_bio(in, NULL); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             BIO_printf(bio_err, "Bad input format for CMS file\n"); | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (cms == NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             BIO_printf(bio_err, "Error reading S/MIME message\n"); | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (contfile != NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             BIO_free(indata); | 
					
						
							| 
									
										
										
										
											2015-05-07 01:43:59 +08:00
										 |  |  |             if ((indata = BIO_new_file(contfile, "rb")) == NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 BIO_printf(bio_err, "Can't read content file %s\n", contfile); | 
					
						
							|  |  |  |                 goto end; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (certsoutfile != NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             STACK_OF(X509) *allcerts; | 
					
						
							|  |  |  |             allcerts = CMS_get1_certs(cms); | 
					
						
							|  |  |  |             if (!save_certs(certsoutfile, allcerts)) { | 
					
						
							|  |  |  |                 BIO_printf(bio_err, | 
					
						
							|  |  |  |                            "Error writing certs to %s\n", certsoutfile); | 
					
						
							|  |  |  |                 ret = 5; | 
					
						
							|  |  |  |                 goto end; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             sk_X509_pop_free(allcerts, X509_free); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |     if (rctfile != NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         char *rctmode = (rctformat == FORMAT_ASN1) ? "rb" : "r"; | 
					
						
							| 
									
										
										
										
											2015-05-07 01:43:59 +08:00
										 |  |  |         if ((rctin = BIO_new_file(rctfile, rctmode)) == NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             BIO_printf(bio_err, "Can't open receipt file %s\n", rctfile); | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (rctformat == FORMAT_SMIME) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             rcms = SMIME_read_CMS(rctin, NULL); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         } else if (rctformat == FORMAT_PEM) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             rcms = PEM_read_bio_CMS(rctin, NULL, NULL, NULL); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         } else if (rctformat == FORMAT_ASN1) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             rcms = d2i_CMS_bio(rctin, NULL); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             BIO_printf(bio_err, "Bad input format for receipt\n"); | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (rcms == NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             BIO_printf(bio_err, "Error reading receipt\n"); | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-04 18:49:06 +08:00
										 |  |  |     out = bio_open_default(outfile, 'w', outformat); | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     if (out == NULL) | 
					
						
							|  |  |  |         goto end; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if ((operation == SMIME_VERIFY) || (operation == SMIME_VERIFY_RECEIPT)) { | 
					
						
							| 
									
										
										
										
											2015-09-22 23:00:52 +08:00
										 |  |  |         if ((store = setup_verify(CAfile, CApath, noCAfile, noCApath)) == NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             goto end; | 
					
						
							|  |  |  |         X509_STORE_set_verify_cb(store, cms_cb); | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |         if (vpmtouched) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             X509_STORE_set1_param(store, vpm); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ret = 3; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (operation == SMIME_DATA_CREATE) { | 
					
						
							|  |  |  |         cms = CMS_data_create(in, flags); | 
					
						
							|  |  |  |     } else if (operation == SMIME_DIGEST_CREATE) { | 
					
						
							|  |  |  |         cms = CMS_digest_create(in, sign_md, flags); | 
					
						
							|  |  |  |     } else if (operation == SMIME_COMPRESS) { | 
					
						
							|  |  |  |         cms = CMS_compress(in, -1, flags); | 
					
						
							|  |  |  |     } else if (operation == SMIME_ENCRYPT) { | 
					
						
							|  |  |  |         int i; | 
					
						
							|  |  |  |         flags |= CMS_PARTIAL; | 
					
						
							|  |  |  |         cms = CMS_encrypt(NULL, in, cipher, flags); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (cms == NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             goto end; | 
					
						
							|  |  |  |         for (i = 0; i < sk_X509_num(encerts); i++) { | 
					
						
							|  |  |  |             CMS_RecipientInfo *ri; | 
					
						
							|  |  |  |             cms_key_param *kparam; | 
					
						
							|  |  |  |             int tflags = flags; | 
					
						
							|  |  |  |             X509 *x = sk_X509_value(encerts, i); | 
					
						
							|  |  |  |             for (kparam = key_first; kparam; kparam = kparam->next) { | 
					
						
							|  |  |  |                 if (kparam->idx == i) { | 
					
						
							|  |  |  |                     tflags |= CMS_KEY_PARAM; | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             ri = CMS_add1_recipient_cert(cms, x, tflags); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             if (ri == NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 goto end; | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             if (kparam != NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 EVP_PKEY_CTX *pctx; | 
					
						
							|  |  |  |                 pctx = CMS_RecipientInfo_get0_pkey_ctx(ri); | 
					
						
							|  |  |  |                 if (!cms_set_pkey_param(pctx, kparam->param)) | 
					
						
							|  |  |  |                     goto end; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             if (CMS_RecipientInfo_type(ri) == CMS_RECIPINFO_AGREE | 
					
						
							|  |  |  |                 && wrap_cipher) { | 
					
						
							|  |  |  |                 EVP_CIPHER_CTX *wctx; | 
					
						
							|  |  |  |                 wctx = CMS_RecipientInfo_kari_get0_ctx(ri); | 
					
						
							|  |  |  |                 EVP_EncryptInit_ex(wctx, wrap_cipher, NULL, NULL, NULL); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (secret_key != NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             if (!CMS_add0_recipient_key(cms, NID_undef, | 
					
						
							|  |  |  |                                         secret_key, secret_keylen, | 
					
						
							|  |  |  |                                         secret_keyid, secret_keyidlen, | 
					
						
							|  |  |  |                                         NULL, NULL, NULL)) | 
					
						
							|  |  |  |                 goto end; | 
					
						
							|  |  |  |             /* NULL these because call absorbs them */ | 
					
						
							|  |  |  |             secret_key = NULL; | 
					
						
							|  |  |  |             secret_keyid = NULL; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (pwri_pass != NULL) { | 
					
						
							| 
									
										
										
											
												Rename some BUF_xxx to OPENSSL_xxx
Rename BUF_{strdup,strlcat,strlcpy,memdup,strndup,strnlen}
to OPENSSL_{strdup,strlcat,strlcpy,memdup,strndup,strnlen}
Add #define's for the old names.
Add CRYPTO_{memdup,strndup}, called by OPENSSL_{memdup,strndup} macros.
Reviewed-by: Tim Hudson <tjh@openssl.org>
											
										 
											2015-12-17 05:12:24 +08:00
										 |  |  |             pwri_tmp = (unsigned char *)OPENSSL_strdup((char *)pwri_pass); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             if (pwri_tmp == NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 goto end; | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             if (CMS_add0_recipient_password(cms, | 
					
						
							|  |  |  |                                             -1, NID_undef, NID_undef, | 
					
						
							|  |  |  |                                             pwri_tmp, -1, NULL) == NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 goto end; | 
					
						
							|  |  |  |             pwri_tmp = NULL; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (!(flags & CMS_STREAM)) { | 
					
						
							|  |  |  |             if (!CMS_final(cms, in, NULL, flags)) | 
					
						
							|  |  |  |                 goto end; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } else if (operation == SMIME_ENCRYPTED_ENCRYPT) { | 
					
						
							|  |  |  |         cms = CMS_EncryptedData_encrypt(in, cipher, | 
					
						
							|  |  |  |                                         secret_key, secret_keylen, flags); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     } else if (operation == SMIME_SIGN_RECEIPT) { | 
					
						
							|  |  |  |         CMS_ContentInfo *srcms = NULL; | 
					
						
							|  |  |  |         STACK_OF(CMS_SignerInfo) *sis; | 
					
						
							|  |  |  |         CMS_SignerInfo *si; | 
					
						
							|  |  |  |         sis = CMS_get0_SignerInfos(cms); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (sis == NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             goto end; | 
					
						
							|  |  |  |         si = sk_CMS_SignerInfo_value(sis, 0); | 
					
						
							|  |  |  |         srcms = CMS_sign_receipt(si, signer, key, other, flags); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (srcms == NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             goto end; | 
					
						
							|  |  |  |         CMS_ContentInfo_free(cms); | 
					
						
							|  |  |  |         cms = srcms; | 
					
						
							|  |  |  |     } else if (operation & SMIME_SIGNERS) { | 
					
						
							|  |  |  |         int i; | 
					
						
							|  |  |  |         /*
 | 
					
						
							|  |  |  |          * If detached data content we enable streaming if S/MIME output | 
					
						
							|  |  |  |          * format. | 
					
						
							|  |  |  |          */ | 
					
						
							|  |  |  |         if (operation == SMIME_SIGN) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (flags & CMS_DETACHED) { | 
					
						
							|  |  |  |                 if (outformat == FORMAT_SMIME) | 
					
						
							|  |  |  |                     flags |= CMS_STREAM; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             flags |= CMS_PARTIAL; | 
					
						
							|  |  |  |             cms = CMS_sign(NULL, NULL, other, in, flags); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             if (cms == NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 goto end; | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             if (econtent_type != NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 CMS_set1_eContentType(cms, econtent_type); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             if (rr_to != NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 rr = make_receipt_request(rr_to, rr_allorfirst, rr_from); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |                 if (rr == NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                     BIO_puts(bio_err, | 
					
						
							|  |  |  |                              "Signed Receipt Request Creation Error\n"); | 
					
						
							|  |  |  |                     goto end; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             flags |= CMS_REUSE_DIGEST; | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         for (i = 0; i < sk_OPENSSL_STRING_num(sksigners); i++) { | 
					
						
							|  |  |  |             CMS_SignerInfo *si; | 
					
						
							|  |  |  |             cms_key_param *kparam; | 
					
						
							|  |  |  |             int tflags = flags; | 
					
						
							|  |  |  |             signerfile = sk_OPENSSL_STRING_value(sksigners, i); | 
					
						
							|  |  |  |             keyfile = sk_OPENSSL_STRING_value(skkeys, i); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-14 11:33:56 +08:00
										 |  |  |             signer = load_cert(signerfile, FORMAT_PEM, "signer certificate"); | 
					
						
							| 
									
										
										
										
											2017-12-29 05:12:59 +08:00
										 |  |  |             if (signer == NULL) { | 
					
						
							|  |  |  |                 ret = 2; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 goto end; | 
					
						
							| 
									
										
										
										
											2017-12-29 05:12:59 +08:00
										 |  |  |             } | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             key = load_key(keyfile, keyform, 0, passin, e, "signing key file"); | 
					
						
							| 
									
										
										
										
											2017-12-29 05:12:59 +08:00
										 |  |  |             if (key == NULL) { | 
					
						
							|  |  |  |                 ret = 2; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 goto end; | 
					
						
							| 
									
										
										
										
											2017-12-29 05:12:59 +08:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             for (kparam = key_first; kparam; kparam = kparam->next) { | 
					
						
							|  |  |  |                 if (kparam->idx == i) { | 
					
						
							|  |  |  |                     tflags |= CMS_KEY_PARAM; | 
					
						
							|  |  |  |                     break; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             si = CMS_add1_signer(cms, signer, key, sign_md, tflags); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             if (si == NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 goto end; | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             if (kparam != NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 EVP_PKEY_CTX *pctx; | 
					
						
							|  |  |  |                 pctx = CMS_SignerInfo_get0_pkey_ctx(si); | 
					
						
							|  |  |  |                 if (!cms_set_pkey_param(pctx, kparam->param)) | 
					
						
							|  |  |  |                     goto end; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             if (rr != NULL && !CMS_add1_ReceiptRequest(si, rr)) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                 goto end; | 
					
						
							|  |  |  |             X509_free(signer); | 
					
						
							|  |  |  |             signer = NULL; | 
					
						
							|  |  |  |             EVP_PKEY_free(key); | 
					
						
							|  |  |  |             key = NULL; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         /* If not streaming or resigning finalize structure */ | 
					
						
							|  |  |  |         if ((operation == SMIME_SIGN) && !(flags & CMS_STREAM)) { | 
					
						
							|  |  |  |             if (!CMS_final(cms, in, NULL, flags)) | 
					
						
							|  |  |  |                 goto end; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |     if (cms == NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         BIO_printf(bio_err, "Error creating CMS structure\n"); | 
					
						
							|  |  |  |         goto end; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ret = 4; | 
					
						
							|  |  |  |     if (operation == SMIME_DECRYPT) { | 
					
						
							|  |  |  |         if (flags & CMS_DEBUG_DECRYPT) | 
					
						
							|  |  |  |             CMS_decrypt(cms, NULL, NULL, NULL, NULL, flags); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (secret_key != NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             if (!CMS_decrypt_set1_key(cms, | 
					
						
							|  |  |  |                                       secret_key, secret_keylen, | 
					
						
							|  |  |  |                                       secret_keyid, secret_keyidlen)) { | 
					
						
							|  |  |  |                 BIO_puts(bio_err, "Error decrypting CMS using secret key\n"); | 
					
						
							|  |  |  |                 goto end; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (key != NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             if (!CMS_decrypt_set1_pkey(cms, key, recip)) { | 
					
						
							|  |  |  |                 BIO_puts(bio_err, "Error decrypting CMS using private key\n"); | 
					
						
							|  |  |  |                 goto end; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (pwri_pass != NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             if (!CMS_decrypt_set1_password(cms, pwri_pass, -1)) { | 
					
						
							|  |  |  |                 BIO_puts(bio_err, "Error decrypting CMS using password\n"); | 
					
						
							|  |  |  |                 goto end; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (!CMS_decrypt(cms, NULL, NULL, indata, out, flags)) { | 
					
						
							|  |  |  |             BIO_printf(bio_err, "Error decrypting CMS structure\n"); | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } else if (operation == SMIME_DATAOUT) { | 
					
						
							|  |  |  |         if (!CMS_data(cms, out, flags)) | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |     } else if (operation == SMIME_UNCOMPRESS) { | 
					
						
							|  |  |  |         if (!CMS_uncompress(cms, indata, out, flags)) | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |     } else if (operation == SMIME_DIGEST_VERIFY) { | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (CMS_digest_verify(cms, indata, out, flags) > 0) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             BIO_printf(bio_err, "Verification successful\n"); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             BIO_printf(bio_err, "Verification failure\n"); | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } else if (operation == SMIME_ENCRYPTED_DECRYPT) { | 
					
						
							|  |  |  |         if (!CMS_EncryptedData_decrypt(cms, secret_key, secret_keylen, | 
					
						
							|  |  |  |                                        indata, out, flags)) | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |     } else if (operation == SMIME_VERIFY) { | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (CMS_verify(cms, other, store, indata, out, flags) > 0) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             BIO_printf(bio_err, "Verification successful\n"); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             BIO_printf(bio_err, "Verification failure\n"); | 
					
						
							|  |  |  |             if (verify_retcode) | 
					
						
							|  |  |  |                 ret = verify_err + 32; | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (signerfile != NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             STACK_OF(X509) *signers; | 
					
						
							|  |  |  |             signers = CMS_get0_signers(cms); | 
					
						
							|  |  |  |             if (!save_certs(signerfile, signers)) { | 
					
						
							|  |  |  |                 BIO_printf(bio_err, | 
					
						
							|  |  |  |                            "Error writing signers to %s\n", signerfile); | 
					
						
							|  |  |  |                 ret = 5; | 
					
						
							|  |  |  |                 goto end; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             sk_X509_free(signers); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (rr_print) | 
					
						
							| 
									
										
										
										
											2015-04-29 23:27:08 +08:00
										 |  |  |             receipt_request_print(cms); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     } else if (operation == SMIME_VERIFY_RECEIPT) { | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (CMS_verify_receipt(rcms, cms, other, store, flags) > 0) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             BIO_printf(bio_err, "Verification successful\n"); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             BIO_printf(bio_err, "Verification failure\n"); | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         if (noout) { | 
					
						
							|  |  |  |             if (print) | 
					
						
							|  |  |  |                 CMS_ContentInfo_print_ctx(out, cms, 0, NULL); | 
					
						
							|  |  |  |         } else if (outformat == FORMAT_SMIME) { | 
					
						
							|  |  |  |             if (to) | 
					
						
							| 
									
										
										
										
											2016-05-20 00:22:57 +08:00
										 |  |  |                 BIO_printf(out, "To: %s%s", to, mime_eol); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             if (from) | 
					
						
							| 
									
										
										
										
											2016-05-20 00:22:57 +08:00
										 |  |  |                 BIO_printf(out, "From: %s%s", from, mime_eol); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             if (subject) | 
					
						
							| 
									
										
										
										
											2016-05-20 00:22:57 +08:00
										 |  |  |                 BIO_printf(out, "Subject: %s%s", subject, mime_eol); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             if (operation == SMIME_RESIGN) | 
					
						
							|  |  |  |                 ret = SMIME_write_CMS(out, cms, indata, flags); | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |                 ret = SMIME_write_CMS(out, cms, in, flags); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         } else if (outformat == FORMAT_PEM) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             ret = PEM_write_bio_CMS_stream(out, cms, in, flags); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         } else if (outformat == FORMAT_ASN1) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             ret = i2d_CMS_bio_stream(out, cms, in, flags); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             BIO_printf(bio_err, "Bad output format for CMS file\n"); | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (ret <= 0) { | 
					
						
							|  |  |  |             ret = 6; | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     ret = 0; | 
					
						
							|  |  |  |  end: | 
					
						
							|  |  |  |     if (ret) | 
					
						
							|  |  |  |         ERR_print_errors(bio_err); | 
					
						
							|  |  |  |     sk_X509_pop_free(encerts, X509_free); | 
					
						
							|  |  |  |     sk_X509_pop_free(other, X509_free); | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     X509_VERIFY_PARAM_free(vpm); | 
					
						
							| 
									
										
										
										
											2015-05-02 02:37:16 +08:00
										 |  |  |     sk_OPENSSL_STRING_free(sksigners); | 
					
						
							|  |  |  |     sk_OPENSSL_STRING_free(skkeys); | 
					
						
							| 
									
										
										
										
											2015-05-01 22:02:07 +08:00
										 |  |  |     OPENSSL_free(secret_key); | 
					
						
							|  |  |  |     OPENSSL_free(secret_keyid); | 
					
						
							|  |  |  |     OPENSSL_free(pwri_tmp); | 
					
						
							| 
									
										
										
										
											2015-03-24 19:52:24 +08:00
										 |  |  |     ASN1_OBJECT_free(econtent_type); | 
					
						
							| 
									
										
										
										
											2015-05-02 02:37:16 +08:00
										 |  |  |     CMS_ReceiptRequest_free(rr); | 
					
						
							|  |  |  |     sk_OPENSSL_STRING_free(rr_to); | 
					
						
							|  |  |  |     sk_OPENSSL_STRING_free(rr_from); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     for (key_param = key_first; key_param;) { | 
					
						
							|  |  |  |         cms_key_param *tparam; | 
					
						
							|  |  |  |         sk_OPENSSL_STRING_free(key_param->param); | 
					
						
							|  |  |  |         tparam = key_param->next; | 
					
						
							|  |  |  |         OPENSSL_free(key_param); | 
					
						
							|  |  |  |         key_param = tparam; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     X509_STORE_free(store); | 
					
						
							|  |  |  |     X509_free(cert); | 
					
						
							|  |  |  |     X509_free(recip); | 
					
						
							|  |  |  |     X509_free(signer); | 
					
						
							|  |  |  |     EVP_PKEY_free(key); | 
					
						
							|  |  |  |     CMS_ContentInfo_free(cms); | 
					
						
							|  |  |  |     CMS_ContentInfo_free(rcms); | 
					
						
							| 
									
										
										
										
											2016-09-29 05:39:18 +08:00
										 |  |  |     release_engine(e); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     BIO_free(rctin); | 
					
						
							|  |  |  |     BIO_free(in); | 
					
						
							|  |  |  |     BIO_free(indata); | 
					
						
							|  |  |  |     BIO_free_all(out); | 
					
						
							| 
									
										
										
										
											2015-05-01 22:02:07 +08:00
										 |  |  |     OPENSSL_free(passin); | 
					
						
							| 
									
										
										
										
											2017-10-17 22:04:09 +08:00
										 |  |  |     return ret; | 
					
						
							| 
									
										
										
										
											2008-03-13 05:14:28 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int save_certs(char *signerfile, STACK_OF(X509) *signers) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | { | 
					
						
							|  |  |  |     int i; | 
					
						
							|  |  |  |     BIO *tmp; | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |     if (signerfile == NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         return 1; | 
					
						
							|  |  |  |     tmp = BIO_new_file(signerfile, "w"); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |     if (tmp == NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         return 0; | 
					
						
							|  |  |  |     for (i = 0; i < sk_X509_num(signers); i++) | 
					
						
							|  |  |  |         PEM_write_bio_X509(tmp, sk_X509_value(signers, i)); | 
					
						
							|  |  |  |     BIO_free(tmp); | 
					
						
							|  |  |  |     return 1; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2008-03-13 05:14:28 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Minimal callback just to output policy info (if any) */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-10 06:09:45 +08:00
										 |  |  | static int cms_cb(int ok, X509_STORE_CTX *ctx) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | { | 
					
						
							|  |  |  |     int error; | 
					
						
							| 
									
										
										
										
											2008-03-13 05:14:28 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     error = X509_STORE_CTX_get_error(ctx); | 
					
						
							| 
									
										
										
										
											2008-03-13 05:14:28 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     verify_err = error; | 
					
						
							| 
									
										
										
										
											2008-07-13 22:25:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     if ((error != X509_V_ERR_NO_EXPLICIT_POLICY) | 
					
						
							|  |  |  |         && ((error != X509_V_OK) || (ok != 2))) | 
					
						
							|  |  |  |         return ok; | 
					
						
							| 
									
										
										
										
											2008-03-13 05:14:28 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-29 23:27:08 +08:00
										 |  |  |     policies_print(ctx); | 
					
						
							| 
									
										
										
										
											2008-03-13 05:14:28 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     return ok; | 
					
						
							| 
									
										
										
										
											2008-03-13 05:14:28 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2008-03-13 05:14:28 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-29 23:27:08 +08:00
										 |  |  | static void gnames_stack_print(STACK_OF(GENERAL_NAMES) *gns) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | { | 
					
						
							|  |  |  |     STACK_OF(GENERAL_NAME) *gens; | 
					
						
							|  |  |  |     GENERAL_NAME *gen; | 
					
						
							|  |  |  |     int i, j; | 
					
						
							| 
									
										
										
										
											2015-04-29 23:27:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     for (i = 0; i < sk_GENERAL_NAMES_num(gns); i++) { | 
					
						
							|  |  |  |         gens = sk_GENERAL_NAMES_value(gns, i); | 
					
						
							|  |  |  |         for (j = 0; j < sk_GENERAL_NAME_num(gens); j++) { | 
					
						
							|  |  |  |             gen = sk_GENERAL_NAME_value(gens, j); | 
					
						
							| 
									
										
										
										
											2015-04-29 23:27:08 +08:00
										 |  |  |             BIO_puts(bio_err, "    "); | 
					
						
							|  |  |  |             GENERAL_NAME_print(bio_err, gen); | 
					
						
							|  |  |  |             BIO_puts(bio_err, "\n"); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2008-03-26 21:10:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-29 23:27:08 +08:00
										 |  |  | static void receipt_request_print(CMS_ContentInfo *cms) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | { | 
					
						
							|  |  |  |     STACK_OF(CMS_SignerInfo) *sis; | 
					
						
							|  |  |  |     CMS_SignerInfo *si; | 
					
						
							|  |  |  |     CMS_ReceiptRequest *rr; | 
					
						
							|  |  |  |     int allorfirst; | 
					
						
							|  |  |  |     STACK_OF(GENERAL_NAMES) *rto, *rlist; | 
					
						
							|  |  |  |     ASN1_STRING *scid; | 
					
						
							|  |  |  |     int i, rv; | 
					
						
							|  |  |  |     sis = CMS_get0_SignerInfos(cms); | 
					
						
							|  |  |  |     for (i = 0; i < sk_CMS_SignerInfo_num(sis); i++) { | 
					
						
							|  |  |  |         si = sk_CMS_SignerInfo_value(sis, i); | 
					
						
							|  |  |  |         rv = CMS_get1_ReceiptRequest(si, &rr); | 
					
						
							|  |  |  |         BIO_printf(bio_err, "Signer %d:\n", i + 1); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (rv == 0) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             BIO_puts(bio_err, "  No Receipt Request\n"); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         } else if (rv < 0) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             BIO_puts(bio_err, "  Receipt Request Parse Error\n"); | 
					
						
							|  |  |  |             ERR_print_errors(bio_err); | 
					
						
							|  |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2016-08-16 21:06:48 +08:00
										 |  |  |             const char *id; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             int idlen; | 
					
						
							|  |  |  |             CMS_ReceiptRequest_get0_values(rr, &scid, &allorfirst, | 
					
						
							|  |  |  |                                            &rlist, &rto); | 
					
						
							| 
									
										
										
										
											2015-04-29 23:27:08 +08:00
										 |  |  |             BIO_puts(bio_err, "  Signed Content ID:\n"); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             idlen = ASN1_STRING_length(scid); | 
					
						
							| 
									
										
										
										
											2016-08-16 21:06:48 +08:00
										 |  |  |             id = (const char *)ASN1_STRING_get0_data(scid); | 
					
						
							| 
									
										
										
										
											2015-04-29 23:27:08 +08:00
										 |  |  |             BIO_dump_indent(bio_err, id, idlen, 4); | 
					
						
							|  |  |  |             BIO_puts(bio_err, "  Receipts From"); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             if (rlist != NULL) { | 
					
						
							| 
									
										
										
										
											2015-04-29 23:27:08 +08:00
										 |  |  |                 BIO_puts(bio_err, " List:\n"); | 
					
						
							|  |  |  |                 gnames_stack_print(rlist); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             } else if (allorfirst == 1) { | 
					
						
							| 
									
										
										
										
											2015-04-29 23:27:08 +08:00
										 |  |  |                 BIO_puts(bio_err, ": First Tier\n"); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             } else if (allorfirst == 0) { | 
					
						
							| 
									
										
										
										
											2015-04-29 23:27:08 +08:00
										 |  |  |                 BIO_puts(bio_err, ": All\n"); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2015-04-29 23:27:08 +08:00
										 |  |  |                 BIO_printf(bio_err, " Unknown (%d)\n", allorfirst); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2015-04-29 23:27:08 +08:00
										 |  |  |             BIO_puts(bio_err, "  Receipts To:\n"); | 
					
						
							|  |  |  |             gnames_stack_print(rto); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-05-02 02:37:16 +08:00
										 |  |  |         CMS_ReceiptRequest_free(rr); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2008-03-26 21:10:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-28 05:10:00 +08:00
										 |  |  | static STACK_OF(GENERAL_NAMES) *make_names_stack(STACK_OF(OPENSSL_STRING) *ns) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | { | 
					
						
							|  |  |  |     int i; | 
					
						
							|  |  |  |     STACK_OF(GENERAL_NAMES) *ret; | 
					
						
							|  |  |  |     GENERAL_NAMES *gens = NULL; | 
					
						
							|  |  |  |     GENERAL_NAME *gen = NULL; | 
					
						
							|  |  |  |     ret = sk_GENERAL_NAMES_new_null(); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |     if (ret == NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         goto err; | 
					
						
							|  |  |  |     for (i = 0; i < sk_OPENSSL_STRING_num(ns); i++) { | 
					
						
							|  |  |  |         char *str = sk_OPENSSL_STRING_value(ns, i); | 
					
						
							|  |  |  |         gen = a2i_GENERAL_NAME(NULL, NULL, NULL, GEN_EMAIL, str, 0); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (gen == NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             goto err; | 
					
						
							|  |  |  |         gens = GENERAL_NAMES_new(); | 
					
						
							| 
									
										
										
										
											2015-10-30 19:18:04 +08:00
										 |  |  |         if (gens == NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             goto err; | 
					
						
							|  |  |  |         if (!sk_GENERAL_NAME_push(gens, gen)) | 
					
						
							|  |  |  |             goto err; | 
					
						
							|  |  |  |         gen = NULL; | 
					
						
							|  |  |  |         if (!sk_GENERAL_NAMES_push(ret, gens)) | 
					
						
							|  |  |  |             goto err; | 
					
						
							|  |  |  |         gens = NULL; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return ret; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  err: | 
					
						
							| 
									
										
										
										
											2015-05-02 02:37:16 +08:00
										 |  |  |     sk_GENERAL_NAMES_pop_free(ret, GENERAL_NAMES_free); | 
					
						
							|  |  |  |     GENERAL_NAMES_free(gens); | 
					
						
							|  |  |  |     GENERAL_NAME_free(gen); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static CMS_ReceiptRequest *make_receipt_request(STACK_OF(OPENSSL_STRING) | 
					
						
							|  |  |  |                                                 *rr_to, int rr_allorfirst, STACK_OF(OPENSSL_STRING) | 
					
						
							|  |  |  |                                                 *rr_from) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-04-27 21:46:09 +08:00
										 |  |  |     STACK_OF(GENERAL_NAMES) *rct_to = NULL, *rct_from = NULL; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     CMS_ReceiptRequest *rr; | 
					
						
							|  |  |  |     rct_to = make_names_stack(rr_to); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |     if (rct_to == NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         goto err; | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |     if (rr_from != NULL) { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         rct_from = make_names_stack(rr_from); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |         if (rct_from == NULL) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |             goto err; | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         rct_from = NULL; | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     rr = CMS_ReceiptRequest_create0(NULL, -1, rr_allorfirst, rct_from, | 
					
						
							|  |  |  |                                     rct_to); | 
					
						
							|  |  |  |     return rr; | 
					
						
							|  |  |  |  err: | 
					
						
							| 
									
										
										
										
											2016-04-27 21:46:09 +08:00
										 |  |  |     sk_GENERAL_NAMES_pop_free(rct_to, GENERAL_NAMES_free); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2008-03-27 01:40:22 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-20 01:24:00 +08:00
										 |  |  | static int cms_set_pkey_param(EVP_PKEY_CTX *pctx, | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |                               STACK_OF(OPENSSL_STRING) *param) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     char *keyopt; | 
					
						
							|  |  |  |     int i; | 
					
						
							|  |  |  |     if (sk_OPENSSL_STRING_num(param) <= 0) | 
					
						
							|  |  |  |         return 1; | 
					
						
							|  |  |  |     for (i = 0; i < sk_OPENSSL_STRING_num(param); i++) { | 
					
						
							|  |  |  |         keyopt = sk_OPENSSL_STRING_value(param, i); | 
					
						
							|  |  |  |         if (pkey_ctrl_string(pctx, keyopt) <= 0) { | 
					
						
							|  |  |  |             BIO_printf(bio_err, "parameter error \"%s\"\n", keyopt); | 
					
						
							|  |  |  |             ERR_print_errors(bio_err); | 
					
						
							|  |  |  |             return 0; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return 1; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2013-06-20 01:24:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-13 05:14:28 +08:00
										 |  |  | #endif
 |