Latest update.
This commit is contained in:
+12
-7
@@ -27,27 +27,32 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS asn1parse_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"oid", OPT_OID, '<', "file of extra oid definitions"},
|
||||
|
||||
OPT_SECTION("I/O"),
|
||||
{"inform", OPT_INFORM, 'F', "input format - one of DER PEM"},
|
||||
{"in", OPT_IN, '<', "input file"},
|
||||
{"out", OPT_OUT, '>', "output file (output format is always DER)"},
|
||||
{"i", OPT_INDENT, 0, "indents the output"},
|
||||
{"noout", OPT_NOOUT, 0, "do not produce any output"},
|
||||
{"offset", OPT_OFFSET, 'p', "offset into file"},
|
||||
{"length", OPT_LENGTH, 'p', "length of section in file"},
|
||||
{"oid", OPT_OID, '<', "file of extra oid definitions"},
|
||||
{"dump", OPT_DUMP, 0, "unknown data in hex form"},
|
||||
{"dlimit", OPT_DLIMIT, 'p',
|
||||
"dump the first arg bytes of unknown data in hex form"},
|
||||
{"strparse", OPT_STRPARSE, 'p',
|
||||
"offset; a series of these can be used to 'dig'"},
|
||||
{OPT_MORE_STR, 0, 0, "into multiple ASN1 blob wrappings"},
|
||||
{"genstr", OPT_GENSTR, 's', "string to generate ASN1 structure from"},
|
||||
{OPT_MORE_STR, 0, 0, "into multiple ASN1 blob wrappings"},
|
||||
{"genconf", OPT_GENCONF, 's', "file to generate ASN1 structure from"},
|
||||
{OPT_MORE_STR, 0, 0, "(-inform will be ignored)"},
|
||||
{"strictpem", OPT_STRICTPEM, 0,
|
||||
"do not attempt base64 decode outside PEM markers"},
|
||||
{"item", OPT_ITEM, 's', "item to parse and print"},
|
||||
{OPT_MORE_STR, 0, 0, "(-inform will be ignored)"},
|
||||
|
||||
OPT_SECTION("Formatting"),
|
||||
{"i", OPT_INDENT, 0, "indents the output"},
|
||||
{"dump", OPT_DUMP, 0, "unknown data in hex form"},
|
||||
{"dlimit", OPT_DLIMIT, 'p',
|
||||
"dump the first arg bytes of unknown data in hex form"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
@@ -154,10 +154,32 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS ca_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] [certreq...]\n"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"verbose", OPT_VERBOSE, '-', "Verbose output during processing"},
|
||||
{"outdir", OPT_OUTDIR, '/', "Where to put output cert"},
|
||||
{"in", OPT_IN, '<', "The input PEM encoded cert request(s)"},
|
||||
{"infiles", OPT_INFILES, '-', "The last argument, requests to process"},
|
||||
{"out", OPT_OUT, '>', "Where to put the output file(s)"},
|
||||
{"notext", OPT_NOTEXT, '-', "Do not print the generated certificate"},
|
||||
{"batch", OPT_BATCH, '-', "Don't ask questions"},
|
||||
{"msie_hack", OPT_MSIE_HACK, '-',
|
||||
"msie modifications to handle all Universal Strings"},
|
||||
{"ss_cert", OPT_SS_CERT, '<', "File contains a self signed cert to sign"},
|
||||
{"spkac", OPT_SPKAC, '<',
|
||||
"File contains DN and signed public key and challenge"},
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
|
||||
OPT_SECTION("Configuration"),
|
||||
{"config", OPT_CONFIG, 's', "A config file"},
|
||||
{"name", OPT_NAME, 's', "The particular CA definition to use"},
|
||||
{"policy", OPT_POLICY, 's', "The CA 'policy' to support"},
|
||||
|
||||
OPT_SECTION("Certificate"),
|
||||
{"subj", OPT_SUBJ, 's', "Use arg instead of request's subject"},
|
||||
{"utf8", OPT_UTF8, '-', "Input characters are UTF8 (default ASCII)"},
|
||||
{"create_serial", OPT_CREATE_SERIAL, '-',
|
||||
@@ -170,8 +192,21 @@ const OPTIONS ca_options[] = {
|
||||
{"enddate", OPT_ENDDATE, 's',
|
||||
"YYMMDDHHMMSSZ cert notAfter (overrides -days)"},
|
||||
{"days", OPT_DAYS, 'p', "Number of days to certify the cert for"},
|
||||
{"extensions", OPT_EXTENSIONS, 's',
|
||||
"Extension section (override value in config file)"},
|
||||
{"extfile", OPT_EXTFILE, '<',
|
||||
"Configuration file with X509v3 extensions to add"},
|
||||
#ifndef OPENSSL_NO_SM2
|
||||
{"sm2-id", OPT_SM2ID, 's',
|
||||
"Specify an ID string to verify an SM2 certificate request"},
|
||||
{"sm2-hex-id", OPT_SM2HEXID, 's',
|
||||
"Specify a hex ID string to verify an SM2 certificate request"},
|
||||
#endif
|
||||
{"preserveDN", OPT_PRESERVEDN, '-', "Don't re-order the DN"},
|
||||
{"noemailDN", OPT_NOEMAILDN, '-', "Don't add the EMAIL field to the DN"},
|
||||
|
||||
OPT_SECTION("Signing"),
|
||||
{"md", OPT_MD, 's', "md to use; one of md2, md5, sha or sha1"},
|
||||
{"policy", OPT_POLICY, 's', "The CA 'policy' to support"},
|
||||
{"keyfile", OPT_KEYFILE, 's', "Private key"},
|
||||
{"keyform", OPT_KEYFORM, 'f', "Private key file format (PEM or ENGINE)"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
@@ -179,31 +214,12 @@ const OPTIONS ca_options[] = {
|
||||
{"cert", OPT_CERT, '<', "The CA cert"},
|
||||
{"selfsign", OPT_SELFSIGN, '-',
|
||||
"Sign a cert with the key associated with it"},
|
||||
{"in", OPT_IN, '<', "The input PEM encoded cert request(s)"},
|
||||
{"out", OPT_OUT, '>', "Where to put the output file(s)"},
|
||||
{"outdir", OPT_OUTDIR, '/', "Where to put output cert"},
|
||||
{"sigopt", OPT_SIGOPT, 's', "Signature parameter in n:v form"},
|
||||
{"notext", OPT_NOTEXT, '-', "Do not print the generated certificate"},
|
||||
{"batch", OPT_BATCH, '-', "Don't ask questions"},
|
||||
{"preserveDN", OPT_PRESERVEDN, '-', "Don't re-order the DN"},
|
||||
{"noemailDN", OPT_NOEMAILDN, '-', "Don't add the EMAIL field to the DN"},
|
||||
|
||||
OPT_SECTION("Revocation"),
|
||||
{"gencrl", OPT_GENCRL, '-', "Generate a new CRL"},
|
||||
{"msie_hack", OPT_MSIE_HACK, '-',
|
||||
"msie modifications to handle all those universal strings"},
|
||||
{"crldays", OPT_CRLDAYS, 'p', "Days until the next CRL is due"},
|
||||
{"crlhours", OPT_CRLHOURS, 'p', "Hours until the next CRL is due"},
|
||||
{"crlsec", OPT_CRLSEC, 'p', "Seconds until the next CRL is due"},
|
||||
{"infiles", OPT_INFILES, '-', "The last argument, requests to process"},
|
||||
{"ss_cert", OPT_SS_CERT, '<', "File contains a self signed cert to sign"},
|
||||
{"spkac", OPT_SPKAC, '<',
|
||||
"File contains DN and signed public key and challenge"},
|
||||
{"revoke", OPT_REVOKE, '<', "Revoke a cert (given in file)"},
|
||||
{"valid", OPT_VALID, 's',
|
||||
"Add a Valid(not-revoked) DB entry about a cert (given in file)"},
|
||||
{"extensions", OPT_EXTENSIONS, 's',
|
||||
"Extension section (override value in config file)"},
|
||||
{"extfile", OPT_EXTFILE, '<',
|
||||
"Configuration file with X509v3 extensions to add"},
|
||||
{"status", OPT_STATUS, 's', "Shows cert status given the serial number"},
|
||||
{"updatedb", OPT_UPDATEDB, '-', "Updates db for expired cert"},
|
||||
{"crlexts", OPT_CRLEXTS, 's',
|
||||
@@ -215,16 +231,15 @@ const OPTIONS ca_options[] = {
|
||||
"sets compromise time to val and the revocation reason to keyCompromise"},
|
||||
{"crl_CA_compromise", OPT_CRL_CA_COMPROMISE, 's',
|
||||
"sets compromise time to val and the revocation reason to CACompromise"},
|
||||
{"crldays", OPT_CRLDAYS, 'p', "Days until the next CRL is due"},
|
||||
{"crlhours", OPT_CRLHOURS, 'p', "Hours until the next CRL is due"},
|
||||
{"crlsec", OPT_CRLSEC, 'p', "Seconds until the next CRL is due"},
|
||||
{"revoke", OPT_REVOKE, '<', "Revoke a cert (given in file)"},
|
||||
|
||||
OPT_R_OPTIONS,
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SM2
|
||||
{"sm2-id", OPT_SM2ID, 's',
|
||||
"Specify an ID string to verify an SM2 certificate request"},
|
||||
{"sm2-hex-id", OPT_SM2HEXID, 's',
|
||||
"Specify a hex ID string to verify an SM2 certificate request"},
|
||||
#endif
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"certreq", 0, 0, "Certificate requests to be signed (optional)"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+19
-9
@@ -31,35 +31,45 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS ciphers_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] [cipher]\n"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"v", OPT_V, '-', "Verbose listing of the SSL/TLS ciphers"},
|
||||
{"V", OPT_UPPER_V, '-', "Even more verbose"},
|
||||
{"stdname", OPT_STDNAME, '-', "Show standard cipher names"},
|
||||
{"convert", OPT_CONVERT, 's', "Convert standard name into OpenSSL name"},
|
||||
|
||||
OPT_SECTION("Cipher specification"),
|
||||
{"s", OPT_S, '-', "Only supported ciphers"},
|
||||
#ifndef OPENSSL_NO_SSL3
|
||||
{"ssl3", OPT_SSL3, '-', "SSL3 mode"},
|
||||
{"ssl3", OPT_SSL3, '-', "Ciphers compatible with SSL3"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_TLS1
|
||||
{"tls1", OPT_TLS1, '-', "TLS1 mode"},
|
||||
{"tls1", OPT_TLS1, '-', "Ciphers compatible with TLS1"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_TLS1_1
|
||||
{"tls1_1", OPT_TLS1_1, '-', "TLS1.1 mode"},
|
||||
{"tls1_1", OPT_TLS1_1, '-', "Ciphers compatible with TLS1.1"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_TLS1_2
|
||||
{"tls1_2", OPT_TLS1_2, '-', "TLS1.2 mode"},
|
||||
{"tls1_2", OPT_TLS1_2, '-', "Ciphers compatible with TLS1.2"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_TLS1_3
|
||||
{"tls1_3", OPT_TLS1_3, '-', "TLS1.3 mode"},
|
||||
{"tls1_3", OPT_TLS1_3, '-', "Ciphers compatible with TLS1.3"},
|
||||
#endif
|
||||
{"stdname", OPT_STDNAME, '-', "Show standard cipher names"},
|
||||
#ifndef OPENSSL_NO_PSK
|
||||
{"psk", OPT_PSK, '-', "include ciphersuites requiring PSK"},
|
||||
{"psk", OPT_PSK, '-', "Include ciphersuites requiring PSK"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SRP
|
||||
{"srp", OPT_SRP, '-', "include ciphersuites requiring SRP"},
|
||||
{"srp", OPT_SRP, '-', "Include ciphersuites requiring SRP"},
|
||||
#endif
|
||||
{"convert", OPT_CONVERT, 's', "Convert standard name into OpenSSL name"},
|
||||
{"ciphersuites", OPT_CIPHERSUITES, 's',
|
||||
"Configure the TLSv1.3 ciphersuites to use"},
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"cipher", 0, 0, "Cipher string to decode (optional)"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+80
-52
@@ -75,7 +75,8 @@ typedef enum OPTION_choice {
|
||||
OPT_NOSIGS, OPT_NO_CONTENT_VERIFY, OPT_NO_ATTR_VERIFY, OPT_INDEF,
|
||||
OPT_NOINDEF, OPT_CRLFEOL, OPT_NOOUT, OPT_RR_PRINT,
|
||||
OPT_RR_ALL, OPT_RR_FIRST, OPT_RCTFORM, OPT_CERTFILE, OPT_CAFILE,
|
||||
OPT_CAPATH, OPT_NOCAPATH, OPT_NOCAFILE,OPT_CONTENT, OPT_PRINT,
|
||||
OPT_CAPATH, OPT_CASTORE, OPT_NOCAPATH, OPT_NOCAFILE, OPT_NOCASTORE,
|
||||
OPT_CONTENT, OPT_PRINT,
|
||||
OPT_SECRETKEY, OPT_SECRETKEYID, OPT_PWRI_PASSWORD, OPT_ECONTENT_TYPE,
|
||||
OPT_PASSIN, OPT_TO, OPT_FROM, OPT_SUBJECT, OPT_SIGNER, OPT_RECIP,
|
||||
OPT_CERTSOUT, OPT_MD, OPT_INKEY, OPT_KEYFORM, OPT_KEYOPT, OPT_RR_FROM,
|
||||
@@ -87,16 +88,36 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS cms_options[] = {
|
||||
{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"},
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] [cert...]\n"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"inform", OPT_INFORM, 'c', "Input format SMIME (default), PEM or DER"},
|
||||
{"outform", OPT_OUTFORM, 'c',
|
||||
"Output format SMIME (default), PEM or DER"},
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"debug_decrypt", OPT_DEBUG_DECRYPT, '-',
|
||||
"Disable MMA protection and return an error if no recipient found"
|
||||
" (see documentation)"},
|
||||
{"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" },
|
||||
{"CAfile", OPT_CAFILE, '<', "Trusted certificates file"},
|
||||
{"CApath", OPT_CAPATH, '/', "trusted certificates directory"},
|
||||
{"CAstore", OPT_CASTORE, ':', "trusted certificates store URI"},
|
||||
{"no-CAfile", OPT_NOCAFILE, '-',
|
||||
"Do not load the default certificates file"},
|
||||
{"no-CApath", OPT_NOCAPATH, '-',
|
||||
"Do not load certificates from the default certificates directory"},
|
||||
{"no-CAstore", OPT_NOCASTORE, '-',
|
||||
"Do not load certificates from the default certificates store"},
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
|
||||
# endif
|
||||
|
||||
OPT_SECTION("Action"),
|
||||
{"encrypt", OPT_ENCRYPT, '-', "Encrypt message"},
|
||||
{"decrypt", OPT_DECRYPT, '-', "Decrypt encrypted message"},
|
||||
{"sign", OPT_SIGN, '-', "Sign message"},
|
||||
@@ -108,45 +129,42 @@ const OPTIONS cms_options[] = {
|
||||
"Exit non-zero on verification failure"},
|
||||
{"verify_receipt", OPT_VERIFY_RECEIPT, '<',
|
||||
"Verify receipts; exit if receipt signatures do not verify"},
|
||||
{"cmsout", OPT_CMSOUT, '-', "Output CMS structure"},
|
||||
{"data_out", OPT_DATA_OUT, '-', "Copy CMS \"Data\" object to output"},
|
||||
{"data_create", OPT_DATA_CREATE, '-', "Create a CMS \"Data\" object"},
|
||||
{"digest_verify", OPT_DIGEST_VERIFY, '-',
|
||||
"Verify a CMS \"DigestedData\" object and output it"},
|
||||
{"digest_create", OPT_DIGEST_CREATE, '-',
|
||||
"Create a CMS \"DigestedData\" object"},
|
||||
{"compress", OPT_COMPRESS, '-', "Create a CMS \"CompressedData\" object"},
|
||||
{"uncompress", OPT_UNCOMPRESS, '-', "Uncompress a CMS \"CompressedData\" object"},
|
||||
{"uncompress", OPT_UNCOMPRESS, '-',
|
||||
"Uncompress a CMS \"CompressedData\" object"},
|
||||
{"EncryptedData_decrypt", OPT_ED_DECRYPT, '-',
|
||||
"Decrypt CMS \"EncryptedData\" object using symmetric key"},
|
||||
{"EncryptedData_encrypt", OPT_ED_ENCRYPT, '-',
|
||||
"Create CMS \"EncryptedData\" object using symmetric key"},
|
||||
{"debug_decrypt", OPT_DEBUG_DECRYPT, '-',
|
||||
"Disable MMA protection and return an error if no recipient found"
|
||||
" (see documentation)"},
|
||||
{"text", OPT_TEXT, '-', "Include or delete text MIME headers"},
|
||||
{"asciicrlf", OPT_ASCIICRLF, '-',
|
||||
"Perform CRLF canonicalisation when signing"},
|
||||
{"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"},
|
||||
{"nosmimecap", OPT_NOSMIMECAP, '-', "Omit the SMIMECapabilities attribute"},
|
||||
{"binary", OPT_BINARY, '-', "Don't translate message to text"},
|
||||
{"keyid", OPT_KEYID, '-', "Use subject key identifier"},
|
||||
{"nosigs", OPT_NOSIGS, '-', "Don't verify message signature"},
|
||||
{"data_out", OPT_DATA_OUT, '-', "Copy CMS \"Data\" object to output"},
|
||||
{"data_create", OPT_DATA_CREATE, '-', "Create a CMS \"Data\" object"},
|
||||
{"cmsout", OPT_CMSOUT, '-', "Output CMS structure"},
|
||||
{"no_content_verify", OPT_NO_CONTENT_VERIFY, '-',
|
||||
"Do not verify signed content signatures"},
|
||||
{"no_attr_verify", OPT_NO_ATTR_VERIFY, '-',
|
||||
"Do not verify signed attribute signatures"},
|
||||
{"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" },
|
||||
{"noout", OPT_NOOUT, '-', "For the -cmsout operation do not output the parsed CMS structure"},
|
||||
{"nointern", OPT_NOINTERN, '-',
|
||||
"Don't search certificates in message for signer"},
|
||||
{"noverify", OPT_NOVERIFY, '-', "Don't verify signers certificate"},
|
||||
|
||||
OPT_SECTION("Formatting"),
|
||||
{"text", OPT_TEXT, '-', "Include or delete text MIME headers"},
|
||||
{"asciicrlf", OPT_ASCIICRLF, '-',
|
||||
"Perform CRLF canonicalisation when signing"},
|
||||
{"nodetach", OPT_NODETACH, '-', "Use opaque signing"},
|
||||
{"nosmimecap", OPT_NOSMIMECAP, '-', "Omit the SMIMECapabilities attribute"},
|
||||
{"noattr", OPT_NOATTR, '-', "Don't include any signed attributes"},
|
||||
{"binary", OPT_BINARY, '-', "Don't translate message to text"},
|
||||
{"keyid", OPT_KEYID, '-', "Use subject key identifier"},
|
||||
{"nosigs", OPT_NOSIGS, '-', "Don't verify message signature"},
|
||||
{"nocerts", OPT_NOCERTS, '-',
|
||||
"Don't include signers certificate when signing"},
|
||||
{"noout", OPT_NOOUT, '-',
|
||||
"For the -cmsout operation do not output the parsed CMS structure"},
|
||||
{"receipt_request_print", OPT_RR_PRINT, '-', "Print CMS Receipt Request" },
|
||||
{"receipt_request_all", OPT_RR_ALL, '-',
|
||||
"When signing, create a receipt request for all recipients"},
|
||||
@@ -154,51 +172,54 @@ const OPTIONS cms_options[] = {
|
||||
"When signing, create a receipt request for first recipient"},
|
||||
{"rctform", OPT_RCTFORM, 'F', "Receipt file format"},
|
||||
{"certfile", OPT_CERTFILE, '<', "Other certificates file"},
|
||||
{"CAfile", OPT_CAFILE, '<', "Trusted certificates file"},
|
||||
{"CApath", OPT_CAPATH, '/', "trusted certificates directory"},
|
||||
{"no-CAfile", OPT_NOCAFILE, '-',
|
||||
"Do not load the default certificates file"},
|
||||
{"no-CApath", OPT_NOCAPATH, '-',
|
||||
"Do not load certificates from the default certificates directory"},
|
||||
{"content", OPT_CONTENT, '<',
|
||||
"Supply or override content for detached signature"},
|
||||
{"print", OPT_PRINT, '-',
|
||||
"For the -cmsout operation print out all fields of the CMS structure"},
|
||||
{"certsout", OPT_CERTSOUT, '>', "Certificate output file"},
|
||||
|
||||
OPT_SECTION("Keying"),
|
||||
{"secretkey", OPT_SECRETKEY, 's',
|
||||
"Use specified hex-encoded key to decrypt/encrypt recipients or content"},
|
||||
{"secretkeyid", OPT_SECRETKEYID, 's',
|
||||
"Identity of the -secretkey for CMS \"KEKRecipientInfo\" object"},
|
||||
{"pwri_password", OPT_PWRI_PASSWORD, 's',
|
||||
"Specific password for recipient"},
|
||||
{"econtent_type", OPT_ECONTENT_TYPE, 's', "OID for external content"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"inkey", OPT_INKEY, 's',
|
||||
"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"},
|
||||
|
||||
OPT_SECTION("Mail header"),
|
||||
{"econtent_type", OPT_ECONTENT_TYPE, 's', "OID for external content"},
|
||||
{"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"},
|
||||
{"md", OPT_MD, 's', "Digest algorithm to use when signing or resigning"},
|
||||
{"inkey", OPT_INKEY, 's',
|
||||
"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',
|
||||
"Create signed receipt request with specified email address"},
|
||||
{"receipt_request_to", OPT_RR_TO, 's',
|
||||
"Create signed receipt targeted to specified address"},
|
||||
|
||||
OPT_SECTION("Encryption"),
|
||||
{"md", OPT_MD, 's', "Digest algorithm to use when signing or resigning"},
|
||||
{"", OPT_CIPHER, '-', "Any supported cipher"},
|
||||
OPT_R_OPTIONS,
|
||||
OPT_V_OPTIONS,
|
||||
|
||||
OPT_SECTION("Key-wrapping"),
|
||||
{"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
|
||||
|
||||
OPT_R_OPTIONS,
|
||||
OPT_V_OPTIONS,
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"cert", 0, 0, "Recipient certs (optional; used only when encrypting)"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
@@ -219,9 +240,9 @@ int cms_main(int argc, char **argv)
|
||||
X509_STORE *store = NULL;
|
||||
X509_VERIFY_PARAM *vpm = NULL;
|
||||
char *certfile = NULL, *keyfile = NULL, *contfile = NULL;
|
||||
const char *CAfile = NULL, *CApath = NULL;
|
||||
const char *CAfile = NULL, *CApath = NULL, *CAstore = NULL;
|
||||
char *certsoutfile = NULL;
|
||||
int noCAfile = 0, noCApath = 0;
|
||||
int noCAfile = 0, noCApath = 0, noCAstore = 0;
|
||||
char *infile = NULL, *outfile = NULL, *rctfile = NULL;
|
||||
char *passinarg = NULL, *passin = NULL, *signerfile = NULL, *recipfile = NULL;
|
||||
char *to = NULL, *from = NULL, *subject = NULL, *prog;
|
||||
@@ -401,12 +422,18 @@ int cms_main(int argc, char **argv)
|
||||
case OPT_CAPATH:
|
||||
CApath = opt_arg();
|
||||
break;
|
||||
case OPT_CASTORE:
|
||||
CAstore = opt_arg();
|
||||
break;
|
||||
case OPT_NOCAFILE:
|
||||
noCAfile = 1;
|
||||
break;
|
||||
case OPT_NOCAPATH:
|
||||
noCApath = 1;
|
||||
break;
|
||||
case OPT_NOCASTORE:
|
||||
noCAstore = 1;
|
||||
break;
|
||||
case OPT_IN:
|
||||
infile = opt_arg();
|
||||
break;
|
||||
@@ -825,7 +852,8 @@ int cms_main(int argc, char **argv)
|
||||
goto end;
|
||||
|
||||
if ((operation == SMIME_VERIFY) || (operation == SMIME_VERIFY_RECEIPT)) {
|
||||
if ((store = setup_verify(CAfile, CApath, noCAfile, noCApath)) == NULL)
|
||||
if ((store = setup_verify(CAfile, noCAfile, CApath, noCApath,
|
||||
CAstore, noCAstore)) == NULL)
|
||||
goto end;
|
||||
X509_STORE_set_verify_cb(store, cms_cb);
|
||||
if (vpmtouched)
|
||||
|
||||
+38
-18
@@ -22,19 +22,34 @@ typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_INFORM, OPT_IN, OPT_OUTFORM, OPT_OUT, OPT_KEYFORM, OPT_KEY,
|
||||
OPT_ISSUER, OPT_LASTUPDATE, OPT_NEXTUPDATE, OPT_FINGERPRINT,
|
||||
OPT_CRLNUMBER, OPT_BADSIG, OPT_GENDELTA, OPT_CAPATH, OPT_CAFILE,
|
||||
OPT_NOCAPATH, OPT_NOCAFILE, OPT_VERIFY, OPT_TEXT, OPT_HASH, OPT_HASH_OLD,
|
||||
OPT_NOOUT, OPT_NAMEOPT, OPT_MD
|
||||
OPT_CRLNUMBER, OPT_BADSIG, OPT_GENDELTA, OPT_CAPATH, OPT_CAFILE, OPT_CASTORE,
|
||||
OPT_NOCAPATH, OPT_NOCAFILE, OPT_NOCASTORE, OPT_VERIFY, OPT_TEXT, OPT_HASH,
|
||||
OPT_HASH_OLD, OPT_NOOUT, OPT_NAMEOPT, OPT_MD
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS crl_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"inform", OPT_INFORM, 'F', "Input format; default PEM"},
|
||||
{"verify", OPT_VERIFY, '-', "Verify CRL signature"},
|
||||
|
||||
OPT_SECTION("Input"),
|
||||
{"in", OPT_IN, '<', "Input file - default stdin"},
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format - default PEM"},
|
||||
{"out", OPT_OUT, '>', "output file - default stdout"},
|
||||
{"keyform", OPT_KEYFORM, 'F', "Private key file format (PEM or ENGINE)"},
|
||||
{"inform", OPT_INFORM, 'F', "Input format; default PEM"},
|
||||
{"key", OPT_KEY, '<', "CRL signing Private key to use"},
|
||||
{"keyform", OPT_KEYFORM, 'F', "Private key file format (PEM or ENGINE)"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"out", OPT_OUT, '>', "output file - default stdout"},
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format - default PEM"},
|
||||
{"text", OPT_TEXT, '-', "Print out a text format version"},
|
||||
{"hash", OPT_HASH, '-', "Print hash value"},
|
||||
#ifndef OPENSSL_NO_MD5
|
||||
{"hash_old", OPT_HASH_OLD, '-', "Print old-style (MD5) hash value"},
|
||||
#endif
|
||||
{"nameopt", OPT_NAMEOPT, 's', "Various certificate name options"},
|
||||
{"", OPT_MD, '-', "Any supported digest"},
|
||||
|
||||
OPT_SECTION("CRL"),
|
||||
{"issuer", OPT_ISSUER, '-', "Print issuer DN"},
|
||||
{"lastupdate", OPT_LASTUPDATE, '-', "Set lastUpdate field"},
|
||||
{"nextupdate", OPT_NEXTUPDATE, '-', "Set nextUpdate field"},
|
||||
@@ -43,20 +58,17 @@ const OPTIONS crl_options[] = {
|
||||
{"crlnumber", OPT_CRLNUMBER, '-', "Print CRL number"},
|
||||
{"badsig", OPT_BADSIG, '-', "Corrupt last byte of loaded CRL signature (for test)" },
|
||||
{"gendelta", OPT_GENDELTA, '<', "Other CRL to compare/diff to the Input one"},
|
||||
|
||||
OPT_SECTION("Certificate"),
|
||||
{"CApath", OPT_CAPATH, '/', "Verify CRL using certificates in dir"},
|
||||
{"CAfile", OPT_CAFILE, '<', "Verify CRL using certificates in file name"},
|
||||
{"CAstore", OPT_CASTORE, ':', "Verify CRL using certificates in store URI"},
|
||||
{"no-CAfile", OPT_NOCAFILE, '-',
|
||||
"Do not load the default certificates file"},
|
||||
{"no-CApath", OPT_NOCAPATH, '-',
|
||||
"Do not load certificates from the default certificates directory"},
|
||||
{"verify", OPT_VERIFY, '-', "Verify CRL signature"},
|
||||
{"text", OPT_TEXT, '-', "Print out a text format version"},
|
||||
{"hash", OPT_HASH, '-', "Print hash value"},
|
||||
{"nameopt", OPT_NAMEOPT, 's', "Various certificate name options"},
|
||||
{"", OPT_MD, '-', "Any supported digest"},
|
||||
#ifndef OPENSSL_NO_MD5
|
||||
{"hash_old", OPT_HASH_OLD, '-', "Print old-style (MD5) hash value"},
|
||||
#endif
|
||||
{"no-CAstore", OPT_NOCASTORE, '-',
|
||||
"Do not load certificates from the default certificates store"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
@@ -71,12 +83,12 @@ int crl_main(int argc, char **argv)
|
||||
EVP_PKEY *pkey;
|
||||
const EVP_MD *digest = EVP_sha1();
|
||||
char *infile = NULL, *outfile = NULL, *crldiff = NULL, *keyfile = NULL;
|
||||
const char *CAfile = NULL, *CApath = NULL, *prog;
|
||||
const char *CAfile = NULL, *CApath = NULL, *CAstore = NULL, *prog;
|
||||
OPTION_CHOICE o;
|
||||
int hash = 0, issuer = 0, lastupdate = 0, nextupdate = 0, noout = 0;
|
||||
int informat = FORMAT_PEM, outformat = FORMAT_PEM, keyformat = FORMAT_PEM;
|
||||
int ret = 1, num = 0, badsig = 0, fingerprint = 0, crlnumber = 0;
|
||||
int text = 0, do_ver = 0, noCAfile = 0, noCApath = 0;
|
||||
int text = 0, do_ver = 0, noCAfile = 0, noCApath = 0, noCAstore = 0;
|
||||
int i;
|
||||
#ifndef OPENSSL_NO_MD5
|
||||
int hash_old = 0;
|
||||
@@ -126,12 +138,19 @@ int crl_main(int argc, char **argv)
|
||||
CAfile = opt_arg();
|
||||
do_ver = 1;
|
||||
break;
|
||||
case OPT_CASTORE:
|
||||
CAstore = opt_arg();
|
||||
do_ver = 1;
|
||||
break;
|
||||
case OPT_NOCAPATH:
|
||||
noCApath = 1;
|
||||
break;
|
||||
case OPT_NOCAFILE:
|
||||
noCAfile = 1;
|
||||
break;
|
||||
case OPT_NOCASTORE:
|
||||
noCAstore = 1;
|
||||
break;
|
||||
case OPT_HASH_OLD:
|
||||
#ifndef OPENSSL_NO_MD5
|
||||
hash_old = ++num;
|
||||
@@ -185,7 +204,8 @@ int crl_main(int argc, char **argv)
|
||||
goto end;
|
||||
|
||||
if (do_ver) {
|
||||
if ((store = setup_verify(CAfile, CApath, noCAfile, noCApath)) == NULL)
|
||||
if ((store = setup_verify(CAfile, noCAfile, CApath, noCApath,
|
||||
CAstore, noCAstore)) == NULL)
|
||||
goto end;
|
||||
lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file());
|
||||
if (lookup == NULL)
|
||||
|
||||
+8
-3
@@ -27,14 +27,19 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS crl2pkcs7_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"inform", OPT_INFORM, 'F', "Input format - DER or PEM"},
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format - DER or PEM"},
|
||||
|
||||
OPT_SECTION("Input"),
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"inform", OPT_INFORM, 'F', "Input format - DER or PEM"},
|
||||
{"nocrl", OPT_NOCRL, '-', "No crl to load, just certs from '-certfile'"},
|
||||
{"certfile", OPT_CERTFILE, '<',
|
||||
"File of chain of certs to a trusted CA; can be repeated"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format - DER or PEM"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+101
-37
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/hmac.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#undef BUFSIZE
|
||||
#define BUFSIZE 1024*8
|
||||
@@ -27,9 +28,15 @@ int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
|
||||
EVP_PKEY *key, unsigned char *sigin, int siglen,
|
||||
const char *sig_name, const char *md_name,
|
||||
const char *file);
|
||||
static void show_digests(const OBJ_NAME *name, void *bio_);
|
||||
|
||||
struct doall_dgst_digests {
|
||||
BIO *bio;
|
||||
int n;
|
||||
};
|
||||
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_LIST,
|
||||
OPT_C, OPT_R, OPT_OUT, OPT_SIGN, OPT_PASSIN, OPT_VERIFY,
|
||||
OPT_PRVERIFY, OPT_SIGNATURE, OPT_KEYFORM, OPT_ENGINE, OPT_ENGINE_IMPL,
|
||||
OPT_HEX, OPT_BINARY, OPT_DEBUG, OPT_FIPS_FINGERPRINT,
|
||||
@@ -40,37 +47,44 @@ typedef enum OPTION_choice {
|
||||
|
||||
const OPTIONS dgst_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] [file...]\n"},
|
||||
{OPT_HELP_STR, 1, '-',
|
||||
" file... files to digest (default is stdin)\n"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"c", OPT_C, '-', "Print the digest with separating colons"},
|
||||
{"r", OPT_R, '-', "Print the digest in coreutils format"},
|
||||
{"out", OPT_OUT, '>', "Output to filename rather than stdout"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"sign", OPT_SIGN, 's', "Sign digest using private key"},
|
||||
{"verify", OPT_VERIFY, 's',
|
||||
"Verify a signature using public key"},
|
||||
{"prverify", OPT_PRVERIFY, 's',
|
||||
"Verify a signature using private key"},
|
||||
{"signature", OPT_SIGNATURE, '<', "File with signature to verify"},
|
||||
{"keyform", OPT_KEYFORM, 'f', "Key file format (PEM or ENGINE)"},
|
||||
{"hex", OPT_HEX, '-', "Print as hex dump"},
|
||||
{"binary", OPT_BINARY, '-', "Print in binary form"},
|
||||
{"d", OPT_DEBUG, '-', "Print debug info"},
|
||||
{"debug", OPT_DEBUG, '-', "Print debug info"},
|
||||
{"fips-fingerprint", OPT_FIPS_FINGERPRINT, '-',
|
||||
"Compute HMAC with the key used in OpenSSL-FIPS fingerprint"},
|
||||
{"hmac", OPT_HMAC, 's', "Create hashed MAC with key"},
|
||||
{"mac", OPT_MAC, 's', "Create MAC (not necessarily HMAC)"},
|
||||
{"sigopt", OPT_SIGOPT, 's', "Signature parameter in n:v form"},
|
||||
{"macopt", OPT_MACOPT, 's', "MAC algorithm parameters in n:v form or key"},
|
||||
{"", OPT_DIGEST, '-', "Any supported digest"},
|
||||
OPT_R_OPTIONS,
|
||||
{"list", OPT_LIST, '-', "List digests"},
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
|
||||
{"engine_impl", OPT_ENGINE_IMPL, '-',
|
||||
"Also use engine given by -engine for digest operations"},
|
||||
#endif
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"c", OPT_C, '-', "Print the digest with separating colons"},
|
||||
{"r", OPT_R, '-', "Print the digest in coreutils format"},
|
||||
{"out", OPT_OUT, '>', "Output to filename rather than stdout"},
|
||||
{"keyform", OPT_KEYFORM, 'f', "Key file format (PEM or ENGINE)"},
|
||||
{"hex", OPT_HEX, '-', "Print as hex dump"},
|
||||
{"binary", OPT_BINARY, '-', "Print in binary form"},
|
||||
{"d", OPT_DEBUG, '-', "Print debug info"},
|
||||
{"debug", OPT_DEBUG, '-', "Print debug info"},
|
||||
|
||||
OPT_SECTION("Signing"),
|
||||
{"sign", OPT_SIGN, 's', "Sign digest using private key"},
|
||||
{"verify", OPT_VERIFY, 's', "Verify a signature using public key"},
|
||||
{"prverify", OPT_PRVERIFY, 's', "Verify a signature using private key"},
|
||||
{"sigopt", OPT_SIGOPT, 's', "Signature parameter in n:v form"},
|
||||
{"signature", OPT_SIGNATURE, '<', "File with signature to verify"},
|
||||
{"hmac", OPT_HMAC, 's', "Create hashed MAC with key"},
|
||||
{"mac", OPT_MAC, 's', "Create MAC (not necessarily HMAC)"},
|
||||
{"macopt", OPT_MACOPT, 's', "MAC algorithm parameters in n:v form or key"},
|
||||
{"", OPT_DIGEST, '-', "Any supported digest"},
|
||||
{"fips-fingerprint", OPT_FIPS_FINGERPRINT, '-',
|
||||
"Compute HMAC with the key used in OpenSSL-FIPS fingerprint"},
|
||||
|
||||
OPT_R_OPTIONS,
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"file", 0, 0, "Files to digest (optional; default is stdin)"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
@@ -92,6 +106,7 @@ int dgst_main(int argc, char **argv)
|
||||
int i, ret = 1, out_bin = -1, want_pub = 0, do_verify = 0;
|
||||
unsigned char *buf = NULL, *sigbuf = NULL;
|
||||
int engine_impl = 0;
|
||||
struct doall_dgst_digests dec;
|
||||
|
||||
prog = opt_progname(argv[0]);
|
||||
buf = app_malloc(BUFSIZE, "I/O buffer");
|
||||
@@ -109,6 +124,15 @@ int dgst_main(int argc, char **argv)
|
||||
opt_help(dgst_options);
|
||||
ret = 0;
|
||||
goto end;
|
||||
case OPT_LIST:
|
||||
BIO_printf(bio_out, "Supported digests:\n");
|
||||
dec.bio = bio_out;
|
||||
dec.n = 0;
|
||||
OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_MD_METH,
|
||||
show_digests, &dec);
|
||||
BIO_printf(bio_out, "\n");
|
||||
ret = 0;
|
||||
goto end;
|
||||
case OPT_C:
|
||||
separator = 1;
|
||||
break;
|
||||
@@ -414,6 +438,32 @@ int dgst_main(int argc, char **argv)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void show_digests(const OBJ_NAME *name, void *arg)
|
||||
{
|
||||
struct doall_dgst_digests *dec = (struct doall_dgst_digests *)arg;
|
||||
const EVP_MD *md = NULL;
|
||||
|
||||
/* Filter out signed digests (a.k.a signature algorithms) */
|
||||
if (strstr(name->name, "rsa") != NULL || strstr(name->name, "RSA") != NULL)
|
||||
return;
|
||||
|
||||
if (!islower((unsigned char)*name->name))
|
||||
return;
|
||||
|
||||
/* Filter out message digests that we cannot use */
|
||||
md = EVP_get_digestbyname(name->name);
|
||||
if (md == NULL)
|
||||
return;
|
||||
|
||||
BIO_printf(dec->bio, "-%-25s", name->name);
|
||||
if (++dec->n == 3) {
|
||||
BIO_printf(dec->bio, "\n");
|
||||
dec->n = 0;
|
||||
} else {
|
||||
BIO_printf(dec->bio, " ");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The newline_escape_filename function performs newline escaping for any
|
||||
* filename that contains a newline. This function also takes a pointer
|
||||
@@ -458,15 +508,16 @@ int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
|
||||
const char *sig_name, const char *md_name,
|
||||
const char *file)
|
||||
{
|
||||
size_t len;
|
||||
int i, backslash = 0;
|
||||
size_t len = BUFSIZE;
|
||||
int i, backslash = 0, ret = 1;
|
||||
unsigned char *sigbuf = NULL;
|
||||
|
||||
while (BIO_pending(bp) || !BIO_eof(bp)) {
|
||||
i = BIO_read(bp, (char *)buf, BUFSIZE);
|
||||
if (i < 0) {
|
||||
BIO_printf(bio_err, "Read Error in %s\n", file);
|
||||
ERR_print_errors(bio_err);
|
||||
return 1;
|
||||
goto end;
|
||||
}
|
||||
if (i == 0)
|
||||
break;
|
||||
@@ -479,28 +530,35 @@ int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
|
||||
BIO_printf(out, "Verified OK\n");
|
||||
} else if (i == 0) {
|
||||
BIO_printf(out, "Verification Failure\n");
|
||||
return 1;
|
||||
goto end;
|
||||
} else {
|
||||
BIO_printf(bio_err, "Error Verifying Data\n");
|
||||
ERR_print_errors(bio_err);
|
||||
return 1;
|
||||
goto end;
|
||||
}
|
||||
return 0;
|
||||
ret = 0;
|
||||
goto end;
|
||||
}
|
||||
if (key != NULL) {
|
||||
EVP_MD_CTX *ctx;
|
||||
int pkey_len;
|
||||
BIO_get_md_ctx(bp, &ctx);
|
||||
len = BUFSIZE;
|
||||
pkey_len = EVP_PKEY_size(key);
|
||||
if (pkey_len > BUFSIZE) {
|
||||
len = pkey_len;
|
||||
sigbuf = app_malloc(len, "Signature buffer");
|
||||
buf = sigbuf;
|
||||
}
|
||||
if (!EVP_DigestSignFinal(ctx, buf, &len)) {
|
||||
BIO_printf(bio_err, "Error Signing Data\n");
|
||||
ERR_print_errors(bio_err);
|
||||
return 1;
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
len = BIO_gets(bp, (char *)buf, BUFSIZE);
|
||||
if ((int)len < 0) {
|
||||
ERR_print_errors(bio_err);
|
||||
return 1;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -535,5 +593,11 @@ int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
|
||||
}
|
||||
BIO_printf(out, "\n");
|
||||
}
|
||||
return 0;
|
||||
|
||||
ret = 0;
|
||||
end:
|
||||
if (sigbuf != NULL)
|
||||
OPENSSL_clear_free(sigbuf, len);
|
||||
|
||||
return ret;
|
||||
}
|
||||
+22
-13
@@ -42,21 +42,11 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS dhparam_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [flags] [numbits]\n"},
|
||||
{OPT_HELP_STR, 1, '-', "Valid options are:\n"},
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] [numbits]\n"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
{"inform", OPT_INFORM, 'F', "Input format, DER or PEM"},
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format, DER or PEM"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"check", OPT_CHECK, '-', "Check the DH parameters"},
|
||||
{"text", OPT_TEXT, '-', "Print a text form of the DH parameters"},
|
||||
{"noout", OPT_NOOUT, '-', "Don't output any DH parameters"},
|
||||
OPT_R_OPTIONS,
|
||||
{"C", OPT_C, '-', "Print C code"},
|
||||
{"2", OPT_2, '-', "Generate parameters using 2 as the generator value"},
|
||||
{"3", OPT_3, '-', "Generate parameters using 3 as the generator value"},
|
||||
{"5", OPT_5, '-', "Generate parameters using 5 as the generator value"},
|
||||
# ifndef OPENSSL_NO_DSA
|
||||
{"dsaparam", OPT_DSAPARAM, '-',
|
||||
"Read or generate DSA parameters, convert to DH"},
|
||||
@@ -64,6 +54,25 @@ const OPTIONS dhparam_options[] = {
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
|
||||
# endif
|
||||
|
||||
OPT_SECTION("Input"),
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
{"inform", OPT_INFORM, 'F', "Input format, DER or PEM"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format, DER or PEM"},
|
||||
{"text", OPT_TEXT, '-', "Print a text form of the DH parameters"},
|
||||
{"noout", OPT_NOOUT, '-', "Don't output any DH parameters"},
|
||||
{"C", OPT_C, '-', "Print C code"},
|
||||
{"2", OPT_2, '-', "Generate parameters using 2 as the generator value"},
|
||||
{"3", OPT_3, '-', "Generate parameters using 3 as the generator value"},
|
||||
{"5", OPT_5, '-', "Generate parameters using 5 as the generator value"},
|
||||
|
||||
OPT_R_OPTIONS,
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"numbits", 0, 0, "Number of bits if generating parameters (optional)"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+17
-11
@@ -36,18 +36,8 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS dsa_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"inform", OPT_INFORM, 'f', "Input format, DER PEM PVK"},
|
||||
{"outform", OPT_OUTFORM, 'f', "Output format, DER PEM PVK"},
|
||||
{"in", OPT_IN, 's', "Input key"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"noout", OPT_NOOUT, '-', "Don't print key out"},
|
||||
{"text", OPT_TEXT, '-', "Print the key in text"},
|
||||
{"modulus", OPT_MODULUS, '-', "Print the DSA public value"},
|
||||
{"pubin", OPT_PUBIN, '-', "Expect a public key in input file"},
|
||||
{"pubout", OPT_PUBOUT, '-', "Output public key, not private"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
|
||||
{"", OPT_CIPHER, '-', "Any supported cipher"},
|
||||
# ifndef OPENSSL_NO_RC4
|
||||
{"pvk-strong", OPT_PVK_STRONG, '-', "Enable 'Strong' PVK encoding level (default)"},
|
||||
@@ -57,6 +47,22 @@ const OPTIONS dsa_options[] = {
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
|
||||
# endif
|
||||
|
||||
OPT_SECTION("Input"),
|
||||
{"in", OPT_IN, 's', "Input key"},
|
||||
{"inform", OPT_INFORM, 'f', "Input format, DER PEM PVK"},
|
||||
{"pubin", OPT_PUBIN, '-', "Expect a public key in input file"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"outform", OPT_OUTFORM, 'f', "Output format, DER PEM PVK"},
|
||||
{"noout", OPT_NOOUT, '-', "Don't print key out"},
|
||||
{"text", OPT_TEXT, '-', "Print the key in text"},
|
||||
{"modulus", OPT_MODULUS, '-', "Print the DSA public value"},
|
||||
{"pubout", OPT_PUBOUT, '-', "Output public key, not private"},
|
||||
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
|
||||
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+20
-9
@@ -37,20 +37,31 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS dsaparam_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] [numbits]\n"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"inform", OPT_INFORM, 'F', "Input format - DER or PEM"},
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format - DER or PEM"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"text", OPT_TEXT, '-', "Print as text"},
|
||||
{"C", OPT_C, '-', "Output C code"},
|
||||
{"noout", OPT_NOOUT, '-', "No output"},
|
||||
{"genkey", OPT_GENKEY, '-', "Generate a DSA key"},
|
||||
OPT_R_OPTIONS,
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
|
||||
# endif
|
||||
|
||||
OPT_SECTION("Input"),
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
{"inform", OPT_INFORM, 'F', "Input format - DER or PEM"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format - DER or PEM"},
|
||||
{"text", OPT_TEXT, '-', "Print as text"},
|
||||
{"C", OPT_C, '-', "Output C code"},
|
||||
{"noout", OPT_NOOUT, '-', "No output"},
|
||||
{"verbose", OPT_VERBOSE, '-', "Verbose output"},
|
||||
{"genkey", OPT_GENKEY, '-', "Generate a DSA key"},
|
||||
|
||||
OPT_R_OPTIONS,
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"numbits", 0, 0, "Number of bits if generating parameters (optional)"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
@@ -44,27 +44,32 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS ec_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
# endif
|
||||
|
||||
OPT_SECTION("Input"),
|
||||
{"in", OPT_IN, 's', "Input file"},
|
||||
{"inform", OPT_INFORM, 'f', "Input format - DER or PEM"},
|
||||
{"pubin", OPT_PUBIN, '-', "Expect a public key in input file"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"check", OPT_CHECK, '-', "check key consistency"},
|
||||
{"", OPT_CIPHER, '-', "Any supported cipher"},
|
||||
{"param_enc", OPT_PARAM_ENC, 's',
|
||||
"Specifies the way the ec parameters are encoded"},
|
||||
{"conv_form", OPT_CONV_FORM, 's', "Specifies the point conversion form "},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format - DER or PEM"},
|
||||
{"noout", OPT_NOOUT, '-', "Don't print key out"},
|
||||
{"text", OPT_TEXT, '-', "Print the key"},
|
||||
{"param_out", OPT_PARAM_OUT, '-', "Print the elliptic curve parameters"},
|
||||
{"pubin", OPT_PUBIN, '-', "Expect a public key in input file"},
|
||||
{"pubout", OPT_PUBOUT, '-', "Output public key, not private"},
|
||||
{"no_public", OPT_NO_PUBLIC, '-', "exclude public key from private key"},
|
||||
{"check", OPT_CHECK, '-', "check key consistency"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
|
||||
{"param_enc", OPT_PARAM_ENC, 's',
|
||||
"Specifies the way the ec parameters are encoded"},
|
||||
{"conv_form", OPT_CONV_FORM, 's', "Specifies the point conversion form "},
|
||||
{"", OPT_CIPHER, '-', "Any supported cipher"},
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
# endif
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+26
-19
@@ -35,31 +35,38 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS ecparam_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"inform", OPT_INFORM, 'F', "Input format - default PEM (DER or PEM)"},
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format - default PEM"},
|
||||
{"in", OPT_IN, '<', "Input file - default stdin"},
|
||||
{"out", OPT_OUT, '>', "Output file - default stdout"},
|
||||
{"text", OPT_TEXT, '-', "Print the ec parameters in text form"},
|
||||
{"C", OPT_C, '-', "Print a 'C' function creating the parameters"},
|
||||
{"check", OPT_CHECK, '-', "Validate the ec parameters"},
|
||||
{"check_named", OPT_CHECK_NAMED, '-',
|
||||
"Check that named EC curve parameters have not been modified"},
|
||||
{"list_curves", OPT_LIST_CURVES, '-',
|
||||
"Prints a list of all curve 'short names'"},
|
||||
{"no_seed", OPT_NO_SEED, '-',
|
||||
"If 'explicit' parameters are chosen do not use the seed"},
|
||||
{"noout", OPT_NOOUT, '-', "Do not print the ec parameter"},
|
||||
{"name", OPT_NAME, 's',
|
||||
"Use the ec parameters with specified 'short name'"},
|
||||
{"conv_form", OPT_CONV_FORM, 's', "Specifies the point conversion form "},
|
||||
{"param_enc", OPT_PARAM_ENC, 's',
|
||||
"Specifies the way the ec parameters are encoded"},
|
||||
{"genkey", OPT_GENKEY, '-', "Generate ec key"},
|
||||
OPT_R_OPTIONS,
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
# endif
|
||||
|
||||
{"genkey", OPT_GENKEY, '-', "Generate ec key"},
|
||||
{"in", OPT_IN, '<', "Input file - default stdin"},
|
||||
{"inform", OPT_INFORM, 'F', "Input format - default PEM (DER or PEM)"},
|
||||
{"out", OPT_OUT, '>', "Output file - default stdout"},
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format - default PEM"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"text", OPT_TEXT, '-', "Print the ec parameters in text form"},
|
||||
{"C", OPT_C, '-', "Print a 'C' function creating the parameters"},
|
||||
{"noout", OPT_NOOUT, '-', "Do not print the ec parameter"},
|
||||
{"param_enc", OPT_PARAM_ENC, 's',
|
||||
"Specifies the way the ec parameters are encoded"},
|
||||
|
||||
OPT_SECTION("Parameter"),
|
||||
{"check", OPT_CHECK, '-', "Validate the ec parameters"},
|
||||
{"check_named", OPT_CHECK_NAMED, '-',
|
||||
"Check that named EC curve parameters have not been modified"},
|
||||
{"no_seed", OPT_NO_SEED, '-',
|
||||
"If 'explicit' parameters are chosen do not use the seed"},
|
||||
{"name", OPT_NAME, 's',
|
||||
"Use the ec parameters with specified 'short name'"},
|
||||
{"conv_form", OPT_CONV_FORM, 's', "Specifies the point conversion form "},
|
||||
|
||||
OPT_R_OPTIONS,
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+28
-16
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -49,27 +49,41 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS enc_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"ciphers", OPT_LIST, '-', "List ciphers"},
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"pass", OPT_PASS, 's', "Passphrase source"},
|
||||
{"list", OPT_LIST, '-', "List ciphers"},
|
||||
#ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||
{"ciphers", OPT_LIST, '-', "Alias for -list"},
|
||||
#endif
|
||||
{"e", OPT_E, '-', "Encrypt"},
|
||||
{"d", OPT_D, '-', "Decrypt"},
|
||||
{"p", OPT_P, '-', "Print the iv/key"},
|
||||
{"P", OPT_UPPER_P, '-', "Print the iv/key and exit"},
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
|
||||
OPT_SECTION("Input"),
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
{"k", OPT_K, 's', "Passphrase"},
|
||||
{"kfile", OPT_KFILE, '<', "Read passphrase from file"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"pass", OPT_PASS, 's', "Passphrase source"},
|
||||
{"v", OPT_V, '-', "Verbose output"},
|
||||
{"nopad", OPT_NOPAD, '-', "Disable standard block padding"},
|
||||
{"salt", OPT_SALT, '-', "Use salt in the KDF (default)"},
|
||||
{"nosalt", OPT_NOSALT, '-', "Do not use salt in the KDF"},
|
||||
{"debug", OPT_DEBUG, '-', "Print debug info"},
|
||||
{"a", OPT_A, '-', "Base64 encode/decode, depending on encryption flag"},
|
||||
{"base64", OPT_A, '-', "Same as option -a"},
|
||||
{"A", OPT_UPPER_A, '-',
|
||||
"Used with -[base64|a] to specify base64 buffer as a single line"},
|
||||
|
||||
OPT_SECTION("Encryption"),
|
||||
{"nopad", OPT_NOPAD, '-', "Disable standard block padding"},
|
||||
{"salt", OPT_SALT, '-', "Use salt in the KDF (default)"},
|
||||
{"nosalt", OPT_NOSALT, '-', "Do not use salt in the KDF"},
|
||||
{"debug", OPT_DEBUG, '-', "Print debug info"},
|
||||
|
||||
{"bufsize", OPT_BUFSIZE, 's', "Buffer size"},
|
||||
{"k", OPT_K, 's', "Passphrase"},
|
||||
{"kfile", OPT_KFILE, '<', "Read passphrase from file"},
|
||||
{"K", OPT_UPPER_K, 's', "Raw key, in hex"},
|
||||
{"S", OPT_UPPER_S, 's', "Salt, in hex"},
|
||||
{"iv", OPT_IV, 's', "IV in hex"},
|
||||
@@ -77,14 +91,12 @@ const OPTIONS enc_options[] = {
|
||||
{"iter", OPT_ITER, 'p', "Specify the iteration count and force use of PBKDF2"},
|
||||
{"pbkdf2", OPT_PBKDF2, '-', "Use password-based key derivation function 2"},
|
||||
{"none", OPT_NONE, '-', "Don't encrypt"},
|
||||
{"", OPT_CIPHER, '-', "Any supported cipher"},
|
||||
OPT_R_OPTIONS,
|
||||
#ifdef ZLIB
|
||||
{"z", OPT_Z, '-', "Use zlib as the 'encryption'"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
{"", OPT_CIPHER, '-', "Any supported cipher"},
|
||||
|
||||
OPT_R_OPTIONS,
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+10
-5
@@ -30,20 +30,25 @@ typedef enum OPTION_choice {
|
||||
|
||||
const OPTIONS engine_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] engine...\n"},
|
||||
{OPT_HELP_STR, 1, '-',
|
||||
" engine... Engines to load\n"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"t", OPT_T, '-', "Check that specified engine is available"},
|
||||
{"pre", OPT_PRE, 's', "Run command against the ENGINE before loading it"},
|
||||
{"post", OPT_POST, 's', "Run command against the ENGINE after loading it"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"v", OPT_V, '-', "List 'control commands' For each specified engine"},
|
||||
{"vv", OPT_VV, '-', "Also display each command's description"},
|
||||
{"vvv", OPT_VVV, '-', "Also add the input flags for each command"},
|
||||
{"vvvv", OPT_VVVV, '-', "Also show internal input flags"},
|
||||
{"c", OPT_C, '-', "List the capabilities of specified engine"},
|
||||
{"t", OPT_T, '-', "Check that specified engine is available"},
|
||||
{"tt", OPT_TT, '-', "Display error trace for unavailable engines"},
|
||||
{"pre", OPT_PRE, 's', "Run command against the ENGINE before loading it"},
|
||||
{"post", OPT_POST, 's', "Run command against the ENGINE after loading it"},
|
||||
{OPT_MORE_STR, OPT_EOF, 1,
|
||||
"Commands are like \"SO_PATH:/lib/libdriver.so\""},
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"engine", 0, 0, "ID of engine(s) to load"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+5
-1
@@ -22,8 +22,12 @@ typedef enum OPTION_choice {
|
||||
|
||||
const OPTIONS errstr_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] errnum...\n"},
|
||||
{OPT_HELP_STR, 1, '-', " errnum Error number\n"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"errnum", 0, 0, "Error number(s) to decode"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+86
-9
@@ -13,6 +13,8 @@
|
||||
#include <openssl/provider.h>
|
||||
#include <openssl/params.h>
|
||||
#include <openssl/fips_names.h>
|
||||
#include <openssl/core_names.h>
|
||||
#include <openssl/self_test.h>
|
||||
#include "apps.h"
|
||||
#include "progs.h"
|
||||
|
||||
@@ -25,28 +27,39 @@
|
||||
#define VERSION_VAL "1"
|
||||
#define INSTALL_STATUS_VAL "INSTALL_SELF_TEST_KATS_RUN"
|
||||
|
||||
static OSSL_CALLBACK self_test_events;
|
||||
static char *self_test_corrupt_desc = NULL;
|
||||
static char *self_test_corrupt_type = NULL;
|
||||
static int self_test_log = 1;
|
||||
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_IN, OPT_OUT, OPT_MODULE,
|
||||
OPT_PROV_NAME, OPT_SECTION_NAME, OPT_MAC_NAME, OPT_MACOPT, OPT_VERIFY
|
||||
OPT_PROV_NAME, OPT_SECTION_NAME, OPT_MAC_NAME, OPT_MACOPT, OPT_VERIFY,
|
||||
OPT_NO_LOG, OPT_CORRUPT_DESC, OPT_CORRUPT_TYPE
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS fipsinstall_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{OPT_MORE_STR, 0, 0, "e.g: openssl fipsinstall -provider_name fips"
|
||||
"-section_name fipsinstall -out fips.conf -module ./fips.so"
|
||||
"-mac_name HMAC -macopt digest:SHA256 -macopt hexkey:00"},
|
||||
{"verify", OPT_VERIFY, '-', "Verification mode, i.e verify a config file "
|
||||
"instead of generating one"},
|
||||
{"in", OPT_IN, '<', "Input config file, used when verifying"},
|
||||
{"out", OPT_OUT, '>', "Output config file, used when generating"},
|
||||
{"verify", OPT_VERIFY, '-',
|
||||
"Verify a config file instead of generating one"},
|
||||
{"module", OPT_MODULE, '<', "File name of the provider module"},
|
||||
{"provider_name", OPT_PROV_NAME, 's', "FIPS provider name"},
|
||||
{"section_name", OPT_SECTION_NAME, 's',
|
||||
"FIPS Provider config section name (optional)"},
|
||||
|
||||
OPT_SECTION("Input"),
|
||||
{"in", OPT_IN, '<', "Input config file, used when verifying"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"out", OPT_OUT, '>', "Output config file, used when generating"},
|
||||
{"mac_name", OPT_MAC_NAME, 's', "MAC name"},
|
||||
{"macopt", OPT_MACOPT, 's', "MAC algorithm parameters in n:v form. "
|
||||
"See 'PARAMETER NAMES' in the EVP_MAC_ docs"},
|
||||
{"noout", OPT_NO_LOG, '-', "Disable logging of self test events"},
|
||||
{"corrupt_desc", OPT_CORRUPT_DESC, 's', "Corrupt a self test by description"},
|
||||
{"corrupt_type", OPT_CORRUPT_TYPE, 's', "Corrupt a self test by type"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
@@ -168,7 +181,7 @@ static CONF *generate_config_and_load(const char *prov_name,
|
||||
if (conf == NULL)
|
||||
goto end;
|
||||
|
||||
if (!CONF_modules_load(conf, NULL, 0))
|
||||
if (CONF_modules_load(conf, NULL, 0) <= 0)
|
||||
goto end;
|
||||
BIO_free(mem_bio);
|
||||
return conf;
|
||||
@@ -285,6 +298,15 @@ opthelp:
|
||||
case OPT_OUT:
|
||||
out_fname = opt_arg();
|
||||
break;
|
||||
case OPT_NO_LOG:
|
||||
self_test_log = 0;
|
||||
break;
|
||||
case OPT_CORRUPT_DESC:
|
||||
self_test_corrupt_desc = opt_arg();
|
||||
break;
|
||||
case OPT_CORRUPT_TYPE:
|
||||
self_test_corrupt_type = opt_arg();
|
||||
break;
|
||||
case OPT_PROV_NAME:
|
||||
prov_name = opt_arg();
|
||||
break;
|
||||
@@ -316,6 +338,11 @@ opthelp:
|
||||
|| argc != 0)
|
||||
goto opthelp;
|
||||
|
||||
if (self_test_log
|
||||
|| self_test_corrupt_desc != NULL
|
||||
|| self_test_corrupt_type != NULL)
|
||||
OSSL_SELF_TEST_set_callback(NULL, self_test_events, NULL);
|
||||
|
||||
module_bio = bio_open_default(module_fname, 'r', FORMAT_BINARY);
|
||||
if (module_bio == NULL) {
|
||||
BIO_printf(bio_err, "Failed to open module file\n");
|
||||
@@ -418,3 +445,53 @@ end:
|
||||
free_config_and_unload(conf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int self_test_events(const OSSL_PARAM params[], void *arg)
|
||||
{
|
||||
const OSSL_PARAM *p = NULL;
|
||||
const char *phase = NULL, *type = NULL, *desc = NULL;
|
||||
int ret = 0;
|
||||
|
||||
p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_PHASE);
|
||||
if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
|
||||
goto err;
|
||||
phase = (const char *)p->data;
|
||||
|
||||
p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_DESC);
|
||||
if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
|
||||
goto err;
|
||||
desc = (const char *)p->data;
|
||||
|
||||
p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_TYPE);
|
||||
if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
|
||||
goto err;
|
||||
type = (const char *)p->data;
|
||||
|
||||
if (self_test_log) {
|
||||
if (strcmp(phase, OSSL_SELF_TEST_PHASE_START) == 0)
|
||||
BIO_printf(bio_out, "%s : (%s) : ", desc, type);
|
||||
else if (strcmp(phase, OSSL_SELF_TEST_PHASE_PASS) == 0
|
||||
|| strcmp(phase, OSSL_SELF_TEST_PHASE_FAIL) == 0)
|
||||
BIO_printf(bio_out, "%s\n", phase);
|
||||
}
|
||||
/*
|
||||
* The self test code will internally corrupt the KAT test result if an
|
||||
* error is returned during the corrupt phase.
|
||||
*/
|
||||
if (strcmp(phase, OSSL_SELF_TEST_PHASE_CORRUPT) == 0
|
||||
&& (self_test_corrupt_desc != NULL
|
||||
|| self_test_corrupt_type != NULL)) {
|
||||
if (self_test_corrupt_desc != NULL
|
||||
&& strcmp(self_test_corrupt_desc, desc) != 0)
|
||||
goto end;
|
||||
if (self_test_corrupt_type != NULL
|
||||
&& strcmp(self_test_corrupt_type, type) != 0)
|
||||
goto end;
|
||||
BIO_printf(bio_out, "%s ", phase);
|
||||
goto err;
|
||||
}
|
||||
end:
|
||||
ret = 1;
|
||||
err:
|
||||
return ret;
|
||||
}
|
||||
+11
-5
@@ -32,17 +32,23 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS gendsa_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [args] dsaparam-file\n"},
|
||||
{OPT_HELP_STR, 1, '-', "Valid options are:\n"},
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] dsaparam-file\n"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
# endif
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"out", OPT_OUT, '>', "Output the key to the specified file"},
|
||||
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
|
||||
OPT_R_OPTIONS,
|
||||
{"", OPT_CIPHER, '-', "Encrypt the output with any supported cipher"},
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
# endif
|
||||
{"verbose", OPT_VERBOSE, '-', "Verbose output"},
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"dsaparam-file", 0, 0, "File containing DSA parameters"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+10
-6
@@ -28,20 +28,24 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS genpkey_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"outform", OPT_OUTFORM, 'F', "output format (DER or PEM)"},
|
||||
{"pass", OPT_PASS, 's', "Output file pass phrase source"},
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
{"paramfile", OPT_PARAMFILE, '<', "Parameters file"},
|
||||
{"algorithm", OPT_ALGORITHM, 's', "The public key algorithm"},
|
||||
{"pkeyopt", OPT_PKEYOPT, 's',
|
||||
"Set the public key algorithm option as opt:value"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"outform", OPT_OUTFORM, 'F', "output format (DER or PEM)"},
|
||||
{"pass", OPT_PASS, 's', "Output file pass phrase source"},
|
||||
{"genparam", OPT_GENPARAM, '-', "Generate parameters, not key"},
|
||||
{"text", OPT_TEXT, '-', "Print the in text"},
|
||||
{"", OPT_CIPHER, '-', "Cipher to use to encrypt the key"},
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
|
||||
/* This is deliberately last. */
|
||||
{OPT_HELP_STR, 1, 1,
|
||||
"Order of options may be important! See the documentation.\n"},
|
||||
|
||||
+18
-7
@@ -42,19 +42,30 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS genrsa_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] numbits\n"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"3", OPT_3, '-', "Use 3 for the E value"},
|
||||
{"F4", OPT_F4, '-', "Use F4 (0x10001) for the E value"},
|
||||
{"f4", OPT_F4, '-', "Use F4 (0x10001) for the E value"},
|
||||
{"out", OPT_OUT, '>', "Output the key to specified file"},
|
||||
OPT_R_OPTIONS,
|
||||
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
|
||||
{"", OPT_CIPHER, '-', "Encrypt the output with any supported cipher"},
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
# endif
|
||||
|
||||
OPT_SECTION("Input"),
|
||||
{"3", OPT_3, '-', "Use 3 for the E value"},
|
||||
{"F4", OPT_F4, '-', "Use F4 (0x10001) for the E value"},
|
||||
{"f4", OPT_F4, '-', "Use F4 (0x10001) for the E value"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"out", OPT_OUT, '>', "Output the key to specified file"},
|
||||
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
|
||||
{"primes", OPT_PRIMES, 'p', "Specify number of primes"},
|
||||
{"verbose", OPT_VERBOSE, '-', "Verbose output"},
|
||||
{"", OPT_CIPHER, '-', "Encrypt the output with any supported cipher"},
|
||||
|
||||
OPT_R_OPTIONS,
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"numbits", 0, 0, "Size of key in bits"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+7
-19
@@ -58,20 +58,6 @@ extern const unsigned char tls13_aes128gcmsha256_id[];
|
||||
extern const unsigned char tls13_aes256gcmsha384_id[];
|
||||
extern BIO_ADDR *ourpeer;
|
||||
|
||||
BIO_METHOD *apps_bf_prefix(void);
|
||||
/*
|
||||
* The control used to set the prefix with BIO_ctrl()
|
||||
* We make it high enough so the chance of ever clashing with the BIO library
|
||||
* remains unlikely for the foreseeable future and beyond.
|
||||
*/
|
||||
#define PREFIX_CTRL_SET_PREFIX (1 << 15)
|
||||
/*
|
||||
* apps_bf_prefix() returns a dynamically created BIO_METHOD, which we
|
||||
* need to destroy at some point. When created internally, it's stored
|
||||
* in an internal pointer which can be freed with the following function
|
||||
*/
|
||||
void destroy_prefix_method(void);
|
||||
|
||||
BIO *dup_bio_in(int format);
|
||||
BIO *dup_bio_out(int format);
|
||||
BIO *dup_bio_err(int format);
|
||||
@@ -126,11 +112,13 @@ int load_certs(const char *file, STACK_OF(X509) **certs, int format,
|
||||
const char *pass, const char *cert_descrip);
|
||||
int load_crls(const char *file, STACK_OF(X509_CRL) **crls, int format,
|
||||
const char *pass, const char *cert_descrip);
|
||||
X509_STORE *setup_verify(const char *CAfile, const char *CApath,
|
||||
int noCAfile, int noCApath);
|
||||
__owur int ctx_set_verify_locations(SSL_CTX *ctx, const char *CAfile,
|
||||
const char *CApath, int noCAfile,
|
||||
int noCApath);
|
||||
X509_STORE *setup_verify(const char *CAfile, int noCAfile,
|
||||
const char *CApath, int noCApath,
|
||||
const char *CAstore, int noCAstore);
|
||||
__owur int ctx_set_verify_locations(SSL_CTX *ctx,
|
||||
const char *CAfile, int noCAfile,
|
||||
const char *CApath, int noCApath,
|
||||
const char *CAstore, int noCAstore);
|
||||
|
||||
#ifndef OPENSSL_NO_CT
|
||||
|
||||
|
||||
+9
-2
@@ -32,6 +32,7 @@
|
||||
OPT_V__LAST
|
||||
|
||||
# define OPT_V_OPTIONS \
|
||||
OPT_SECTION("Validation"), \
|
||||
{ "policy", OPT_V_POLICY, 's', "adds policy to the acceptable policy set"}, \
|
||||
{ "purpose", OPT_V_PURPOSE, 's', \
|
||||
"certificate chain purpose"}, \
|
||||
@@ -124,6 +125,7 @@
|
||||
OPT_X__LAST
|
||||
|
||||
# define OPT_X_OPTIONS \
|
||||
OPT_SECTION("Extended certificate"), \
|
||||
{ "xkey", OPT_X_KEY, '<', "key for Extended certificates"}, \
|
||||
{ "xcert", OPT_X_CERT, '<', "cert for Extended certificates"}, \
|
||||
{ "xchain", OPT_X_CHAIN, '<', "chain for Extended certificates"}, \
|
||||
@@ -161,6 +163,7 @@
|
||||
OPT_S_NO_RENEGOTIATION, OPT_S_NO_MIDDLEBOX, OPT_S__LAST
|
||||
|
||||
# define OPT_S_OPTIONS \
|
||||
OPT_SECTION("TLS/SSL"), \
|
||||
{"no_ssl3", OPT_S_NOSSL3, '-',"Just disable SSLv3" }, \
|
||||
{"no_tls1", OPT_S_NOTLS1, '-', "Just disable TLSv1"}, \
|
||||
{"no_tls1_1", OPT_S_NOTLS1_1, '-', "Just disable TLSv1.1" }, \
|
||||
@@ -254,6 +257,7 @@
|
||||
OPT_R__FIRST=1500, OPT_R_RAND, OPT_R_WRITERAND, OPT_R__LAST
|
||||
|
||||
# define OPT_R_OPTIONS \
|
||||
OPT_SECTION("Random state"), \
|
||||
{"rand", OPT_R_RAND, 's', "Load the file(s) into the random number generator"}, \
|
||||
{"writerand", OPT_R_WRITERAND, '>', "Write random data to the specified file"}
|
||||
|
||||
@@ -267,6 +271,8 @@
|
||||
extern const char OPT_HELP_STR[];
|
||||
extern const char OPT_MORE_STR[];
|
||||
extern const char OPT_SECTION_STR[];
|
||||
extern const char OPT_PARAM_STR[];
|
||||
|
||||
typedef struct options_st {
|
||||
const char *name;
|
||||
int retval;
|
||||
@@ -309,7 +315,8 @@ typedef struct string_int_pair_st {
|
||||
OPT_FMT_TEXT | OPT_FMT_HTTP | OPT_FMT_PVK)
|
||||
|
||||
/* Divide options into sections when displaying usage */
|
||||
#define OPT_SECTION(sec) {OPT_SECTION_STR, 1, '-', sec " options:\n"}
|
||||
#define OPT_SECTION(sec) { OPT_SECTION_STR, 1, '-', sec " options:\n" }
|
||||
#define OPT_PARAMETERS() { OPT_PARAM_STR, 1, '-', "Parameters:\n" }
|
||||
|
||||
char *opt_progname(const char *argv0);
|
||||
char *opt_getprog(void);
|
||||
@@ -342,7 +349,7 @@ int opt_num_rest(void);
|
||||
int opt_verify(int i, X509_VERIFY_PARAM *vpm);
|
||||
int opt_rand(int i);
|
||||
void opt_help(const OPTIONS * list);
|
||||
void opt_print(const OPTIONS * opt, int width);
|
||||
void opt_print(const OPTIONS * opt, int doingparams, int width);
|
||||
int opt_format_error(const char *s, unsigned long flags);
|
||||
int opt_isdir(const char *name);
|
||||
int opt_printf_stderr(const char *fmt, ...);
|
||||
|
||||
@@ -69,8 +69,9 @@ int config_ctx(SSL_CONF_CTX *cctx, STACK_OF(OPENSSL_STRING) *str, SSL_CTX *ctx);
|
||||
int ssl_ctx_add_crls(SSL_CTX *ctx, STACK_OF(X509_CRL) *crls,
|
||||
int crl_download);
|
||||
int ssl_load_stores(SSL_CTX *ctx, const char *vfyCApath,
|
||||
const char *vfyCAfile, const char *chCApath,
|
||||
const char *chCAfile, STACK_OF(X509_CRL) *crls,
|
||||
const char *vfyCAfile, const char *vfyCAstore,
|
||||
const char *chCApath, const char *chCAfile,
|
||||
const char *chCAstore, STACK_OF(X509_CRL) *crls,
|
||||
int crl_download);
|
||||
void ssl_ctx_security_debug(SSL_CTX *ctx, int verbose);
|
||||
int set_keylog_file(SSL_CTX *ctx, const char *keylog_file);
|
||||
|
||||
@@ -18,7 +18,11 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS info_options[] = {
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"configdir", OPT_CONFIGDIR, '-', "Default configuration file directory"},
|
||||
{"enginesdir", OPT_ENGINESDIR, '-', "Default engine module directory"},
|
||||
{"modulesdir", OPT_MODULESDIR, '-',
|
||||
|
||||
+15
-5
@@ -24,14 +24,20 @@ typedef enum OPTION_choice {
|
||||
|
||||
const OPTIONS kdf_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] kdf_name\n"},
|
||||
{OPT_HELP_STR, 1, '-', "kdf_name\t KDF algorithm.\n"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"kdfopt", OPT_KDFOPT, 's', "KDF algorithm control parameters in n:v form. "
|
||||
"See 'Supported Controls' in the EVP_KDF_ docs"},
|
||||
{"kdfopt", OPT_KDFOPT, 's', "KDF algorithm control parameters in n:v form"},
|
||||
{OPT_MORE_STR, 1, '-', "See 'Supported Controls' in the EVP_KDF_ docs\n"},
|
||||
{"keylen", OPT_KEYLEN, 's', "The size of the output derived key"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"out", OPT_OUT, '>', "Output to filename rather than stdout"},
|
||||
{"binary", OPT_BIN, '-', "Output in binary format (Default is hexadecimal "
|
||||
"output)"},
|
||||
{"binary", OPT_BIN, '-',
|
||||
"Output in binary format (default is hexadecimal)"},
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"kdf_name", 0, 0, "Name of the KDF algorithm"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
@@ -132,6 +138,10 @@ opthelp:
|
||||
BIO_write(out, dkm_bytes, dkm_len);
|
||||
} else {
|
||||
hexout = OPENSSL_buf2hexstr(dkm_bytes, dkm_len);
|
||||
if (hexout == NULL) {
|
||||
BIO_printf(bio_err, "Memory allocation failure\n");
|
||||
goto err;
|
||||
}
|
||||
BIO_printf(out, "%s\n\n", hexout);
|
||||
}
|
||||
|
||||
|
||||
+33
-20
@@ -125,18 +125,29 @@ int app_init(long mesgwin)
|
||||
}
|
||||
#endif
|
||||
|
||||
int ctx_set_verify_locations(SSL_CTX *ctx, const char *CAfile,
|
||||
const char *CApath, int noCAfile, int noCApath)
|
||||
int ctx_set_verify_locations(SSL_CTX *ctx,
|
||||
const char *CAfile, int noCAfile,
|
||||
const char *CApath, int noCApath,
|
||||
const char *CAstore, int noCAstore)
|
||||
{
|
||||
if (CAfile == NULL && CApath == NULL) {
|
||||
if (CAfile == NULL && CApath == NULL && CAstore == NULL) {
|
||||
if (!noCAfile && SSL_CTX_set_default_verify_file(ctx) <= 0)
|
||||
return 0;
|
||||
if (!noCApath && SSL_CTX_set_default_verify_dir(ctx) <= 0)
|
||||
return 0;
|
||||
if (!noCAstore && SSL_CTX_set_default_verify_store(ctx) <= 0)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
return SSL_CTX_load_verify_locations(ctx, CAfile, CApath);
|
||||
|
||||
if (CAfile != NULL && !SSL_CTX_load_verify_file(ctx, CAfile))
|
||||
return 0;
|
||||
if (CApath != NULL && !SSL_CTX_load_verify_dir(ctx, CApath))
|
||||
return 0;
|
||||
if (CAstore != NULL && !SSL_CTX_load_verify_store(ctx, CAstore))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_CT
|
||||
@@ -1068,7 +1079,9 @@ void print_array(BIO *out, const char* title, int len, const unsigned char* d)
|
||||
BIO_printf(out, "\n};\n");
|
||||
}
|
||||
|
||||
X509_STORE *setup_verify(const char *CAfile, const char *CApath, int noCAfile, int noCApath)
|
||||
X509_STORE *setup_verify(const char *CAfile, int noCAfile,
|
||||
const char *CApath, int noCApath,
|
||||
const char *CAstore, int noCAstore)
|
||||
{
|
||||
X509_STORE *store = X509_STORE_new();
|
||||
X509_LOOKUP *lookup;
|
||||
@@ -1080,7 +1093,7 @@ X509_STORE *setup_verify(const char *CAfile, const char *CApath, int noCAfile, i
|
||||
lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file());
|
||||
if (lookup == NULL)
|
||||
goto end;
|
||||
if (CAfile) {
|
||||
if (CAfile != NULL) {
|
||||
if (!X509_LOOKUP_load_file(lookup, CAfile, X509_FILETYPE_PEM)) {
|
||||
BIO_printf(bio_err, "Error loading file %s\n", CAfile);
|
||||
goto end;
|
||||
@@ -1094,7 +1107,7 @@ X509_STORE *setup_verify(const char *CAfile, const char *CApath, int noCAfile, i
|
||||
lookup = X509_STORE_add_lookup(store, X509_LOOKUP_hash_dir());
|
||||
if (lookup == NULL)
|
||||
goto end;
|
||||
if (CApath) {
|
||||
if (CApath != NULL) {
|
||||
if (!X509_LOOKUP_add_dir(lookup, CApath, X509_FILETYPE_PEM)) {
|
||||
BIO_printf(bio_err, "Error loading directory %s\n", CApath);
|
||||
goto end;
|
||||
@@ -1104,6 +1117,17 @@ X509_STORE *setup_verify(const char *CAfile, const char *CApath, int noCAfile, i
|
||||
}
|
||||
}
|
||||
|
||||
if (CAstore != NULL || !noCAstore) {
|
||||
lookup = X509_STORE_add_lookup(store, X509_LOOKUP_store());
|
||||
if (lookup == NULL)
|
||||
goto end;
|
||||
if (!X509_LOOKUP_add_store(lookup, CAstore)) {
|
||||
if (CAstore != NULL)
|
||||
BIO_printf(bio_err, "Error loading store URI %s\n", CAstore);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
ERR_clear_error();
|
||||
return store;
|
||||
end:
|
||||
@@ -2300,8 +2324,8 @@ BIO *dup_bio_out(int format)
|
||||
|
||||
if (FMT_istext(format)
|
||||
&& (prefix = getenv("HARNESS_OSSL_PREFIX")) != NULL) {
|
||||
b = BIO_push(BIO_new(apps_bf_prefix()), b);
|
||||
BIO_ctrl(b, PREFIX_CTRL_SET_PREFIX, 0, prefix);
|
||||
b = BIO_push(BIO_new(BIO_f_prefix()), b);
|
||||
BIO_set_prefix(b, prefix);
|
||||
}
|
||||
|
||||
return b;
|
||||
@@ -2318,17 +2342,6 @@ BIO *dup_bio_err(int format)
|
||||
return b;
|
||||
}
|
||||
|
||||
/*
|
||||
* Because the prefix method is created dynamically, we must also be able
|
||||
* to destroy it.
|
||||
*/
|
||||
void destroy_prefix_method(void)
|
||||
{
|
||||
BIO_METHOD *prefix_method = apps_bf_prefix();
|
||||
BIO_meth_free(prefix_method);
|
||||
prefix_method = NULL;
|
||||
}
|
||||
|
||||
void unbuffer(FILE *fp)
|
||||
{
|
||||
/*
|
||||
|
||||
@@ -1,177 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (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
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <openssl/bio.h>
|
||||
#include "apps.h"
|
||||
|
||||
static int prefix_write(BIO *b, const char *out, size_t outl,
|
||||
size_t *numwritten);
|
||||
static int prefix_read(BIO *b, char *buf, size_t size, size_t *numread);
|
||||
static int prefix_puts(BIO *b, const char *str);
|
||||
static int prefix_gets(BIO *b, char *str, int size);
|
||||
static long prefix_ctrl(BIO *b, int cmd, long arg1, void *arg2);
|
||||
static int prefix_create(BIO *b);
|
||||
static int prefix_destroy(BIO *b);
|
||||
static long prefix_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp);
|
||||
|
||||
static BIO_METHOD *prefix_meth = NULL;
|
||||
|
||||
BIO_METHOD *apps_bf_prefix(void)
|
||||
{
|
||||
if (prefix_meth == NULL) {
|
||||
if ((prefix_meth =
|
||||
BIO_meth_new(BIO_TYPE_FILTER, "Prefix filter")) == NULL
|
||||
|| !BIO_meth_set_create(prefix_meth, prefix_create)
|
||||
|| !BIO_meth_set_destroy(prefix_meth, prefix_destroy)
|
||||
|| !BIO_meth_set_write_ex(prefix_meth, prefix_write)
|
||||
|| !BIO_meth_set_read_ex(prefix_meth, prefix_read)
|
||||
|| !BIO_meth_set_puts(prefix_meth, prefix_puts)
|
||||
|| !BIO_meth_set_gets(prefix_meth, prefix_gets)
|
||||
|| !BIO_meth_set_ctrl(prefix_meth, prefix_ctrl)
|
||||
|| !BIO_meth_set_callback_ctrl(prefix_meth, prefix_callback_ctrl)) {
|
||||
BIO_meth_free(prefix_meth);
|
||||
prefix_meth = NULL;
|
||||
}
|
||||
}
|
||||
return prefix_meth;
|
||||
}
|
||||
|
||||
typedef struct prefix_ctx_st {
|
||||
char *prefix;
|
||||
int linestart; /* flag to indicate we're at the line start */
|
||||
} PREFIX_CTX;
|
||||
|
||||
static int prefix_create(BIO *b)
|
||||
{
|
||||
PREFIX_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
|
||||
|
||||
if (ctx == NULL)
|
||||
return 0;
|
||||
|
||||
ctx->prefix = NULL;
|
||||
ctx->linestart = 1;
|
||||
BIO_set_data(b, ctx);
|
||||
BIO_set_init(b, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int prefix_destroy(BIO *b)
|
||||
{
|
||||
PREFIX_CTX *ctx = BIO_get_data(b);
|
||||
|
||||
OPENSSL_free(ctx->prefix);
|
||||
OPENSSL_free(ctx);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int prefix_read(BIO *b, char *in, size_t size, size_t *numread)
|
||||
{
|
||||
return BIO_read_ex(BIO_next(b), in, size, numread);
|
||||
}
|
||||
|
||||
static int prefix_write(BIO *b, const char *out, size_t outl,
|
||||
size_t *numwritten)
|
||||
{
|
||||
PREFIX_CTX *ctx = BIO_get_data(b);
|
||||
|
||||
if (ctx == NULL)
|
||||
return 0;
|
||||
|
||||
/* If no prefix is set or if it's empty, we've got nothing to do here */
|
||||
if (ctx->prefix == NULL || *ctx->prefix == '\0') {
|
||||
/* We do note if what comes next will be a new line, though */
|
||||
if (outl > 0)
|
||||
ctx->linestart = (out[outl-1] == '\n');
|
||||
return BIO_write_ex(BIO_next(b), out, outl, numwritten);
|
||||
}
|
||||
|
||||
*numwritten = 0;
|
||||
|
||||
while (outl > 0) {
|
||||
size_t i;
|
||||
char c;
|
||||
|
||||
/* If we know that we're at the start of the line, output the prefix */
|
||||
if (ctx->linestart) {
|
||||
size_t dontcare;
|
||||
|
||||
if (!BIO_write_ex(BIO_next(b), ctx->prefix, strlen(ctx->prefix),
|
||||
&dontcare))
|
||||
return 0;
|
||||
ctx->linestart = 0;
|
||||
}
|
||||
|
||||
/* Now, go look for the next LF, or the end of the string */
|
||||
for (i = 0, c = '\0'; i < outl && (c = out[i]) != '\n'; i++)
|
||||
continue;
|
||||
if (c == '\n')
|
||||
i++;
|
||||
|
||||
/* Output what we found so far */
|
||||
while (i > 0) {
|
||||
size_t num = 0;
|
||||
|
||||
if (!BIO_write_ex(BIO_next(b), out, i, &num))
|
||||
return 0;
|
||||
out += num;
|
||||
outl -= num;
|
||||
*numwritten += num;
|
||||
i -= num;
|
||||
}
|
||||
|
||||
/* If we found a LF, what follows is a new line, so take note */
|
||||
if (c == '\n')
|
||||
ctx->linestart = 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static long prefix_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
long ret = 0;
|
||||
|
||||
switch (cmd) {
|
||||
case PREFIX_CTRL_SET_PREFIX:
|
||||
{
|
||||
PREFIX_CTX *ctx = BIO_get_data(b);
|
||||
|
||||
if (ctx == NULL)
|
||||
break;
|
||||
|
||||
OPENSSL_free(ctx->prefix);
|
||||
ctx->prefix = OPENSSL_strdup((const char *)ptr);
|
||||
ret = ctx->prefix != NULL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (BIO_next(b) != NULL)
|
||||
ret = BIO_ctrl(BIO_next(b), cmd, num, ptr);
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static long prefix_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp)
|
||||
{
|
||||
return BIO_callback_ctrl(BIO_next(b), cmd, fp);
|
||||
}
|
||||
|
||||
static int prefix_gets(BIO *b, char *buf, int size)
|
||||
{
|
||||
return BIO_gets(BIO_next(b), buf, size);
|
||||
}
|
||||
|
||||
static int prefix_puts(BIO *b, const char *str)
|
||||
{
|
||||
return BIO_write(b, str, strlen(str));
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
# Auxilliary program source
|
||||
# Auxiliary program source
|
||||
IF[{- $config{target} =~ /^(?:VC-|mingw)/ -}]
|
||||
# It's called 'init', but doesn't have much 'init' in it...
|
||||
$AUXLIBAPPSSRC=win32_init.c
|
||||
@@ -9,7 +9,7 @@ ENDIF
|
||||
|
||||
# Source for libapps
|
||||
$LIBAPPSSRC=apps.c apps_ui.c opt.c fmt.c s_cb.c s_socket.c app_rand.c \
|
||||
bf_prefix.c columns.c app_params.c names.c
|
||||
columns.c app_params.c names.c
|
||||
|
||||
IF[{- !$disabled{apps} -}]
|
||||
LIBS{noinst}=../libapps.a
|
||||
|
||||
+33
-16
@@ -26,9 +26,10 @@
|
||||
#include <openssl/x509v3.h>
|
||||
|
||||
#define MAX_OPT_HELP_WIDTH 30
|
||||
const char OPT_HELP_STR[] = "--";
|
||||
const char OPT_MORE_STR[] = "---";
|
||||
const char OPT_SECTION_STR[] = "----";
|
||||
const char OPT_HELP_STR[] = "-H";
|
||||
const char OPT_MORE_STR[] = "-M";
|
||||
const char OPT_SECTION_STR[] = "-S";
|
||||
const char OPT_PARAM_STR[] = "-P";
|
||||
|
||||
/* Our state */
|
||||
static char **argv;
|
||||
@@ -128,14 +129,16 @@ char *opt_init(int ac, char **av, const OPTIONS *o)
|
||||
opt_progname(av[0]);
|
||||
unknown = NULL;
|
||||
|
||||
for (; o->name; ++o) {
|
||||
/* Check all options up until the PARAM marker (if present) */
|
||||
for (; o->name != NULL && o->name != OPT_PARAM_STR; ++o) {
|
||||
#ifndef NDEBUG
|
||||
const OPTIONS *next;
|
||||
int duplicated, i;
|
||||
#endif
|
||||
|
||||
if (o->name == OPT_HELP_STR || o->name == OPT_MORE_STR ||
|
||||
o->name == OPT_SECTION_STR)
|
||||
if (o->name == OPT_HELP_STR
|
||||
|| o->name == OPT_MORE_STR
|
||||
|| o->name == OPT_SECTION_STR)
|
||||
continue;
|
||||
#ifndef NDEBUG
|
||||
i = o->valtype;
|
||||
@@ -146,7 +149,7 @@ char *opt_init(int ac, char **av, const OPTIONS *o)
|
||||
switch (i) {
|
||||
case 0: case '-': case '/': case '<': case '>': case 'E': case 'F':
|
||||
case 'M': case 'U': case 'f': case 'l': case 'n': case 'p': case 's':
|
||||
case 'u': case 'c':
|
||||
case 'u': case 'c': case ':':
|
||||
break;
|
||||
default:
|
||||
OPENSSL_assert(0);
|
||||
@@ -285,7 +288,7 @@ int opt_cipher(const char *name, const EVP_CIPHER **cipherp)
|
||||
*cipherp = EVP_get_cipherbyname(name);
|
||||
if (*cipherp != NULL)
|
||||
return 1;
|
||||
opt_printf_stderr("%s: Unrecognized flag %s\n", prog, name);
|
||||
opt_printf_stderr("%s: Unknown cipher: %s\n", prog, name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -297,7 +300,7 @@ int opt_md(const char *name, const EVP_MD **mdp)
|
||||
*mdp = EVP_get_digestbyname(name);
|
||||
if (*mdp != NULL)
|
||||
return 1;
|
||||
opt_printf_stderr("%s: Unrecognized flag %s\n", prog, name);
|
||||
opt_printf_stderr("%s: Unknown message digest: %s\n", prog, name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -686,6 +689,7 @@ int opt_next(void)
|
||||
switch (o->valtype) {
|
||||
default:
|
||||
case 's':
|
||||
case ':':
|
||||
/* Just a string. */
|
||||
break;
|
||||
case '/':
|
||||
@@ -758,7 +762,7 @@ int opt_next(void)
|
||||
dunno = p;
|
||||
return unknown->retval;
|
||||
}
|
||||
opt_printf_stderr("%s: Option unknown option -%s\n", prog, p);
|
||||
opt_printf_stderr("%s: Unknown option: -%s\n", prog, p);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -804,6 +808,8 @@ static const char *valtype2param(const OPTIONS *o)
|
||||
case 0:
|
||||
case '-':
|
||||
return "";
|
||||
case ':':
|
||||
return "uri";
|
||||
case 's':
|
||||
return "val";
|
||||
case '/':
|
||||
@@ -834,17 +840,26 @@ static const char *valtype2param(const OPTIONS *o)
|
||||
return "parm";
|
||||
}
|
||||
|
||||
void opt_print(const OPTIONS *o, int width)
|
||||
void opt_print(const OPTIONS *o, int doingparams, int width)
|
||||
{
|
||||
const char* help;
|
||||
char start[80 + 1];
|
||||
char *p;
|
||||
|
||||
help = o->helpstr ? o->helpstr : "(No additional info)";
|
||||
if (o->name == OPT_HELP_STR || o->name == OPT_SECTION_STR) {
|
||||
if (o->name == OPT_HELP_STR) {
|
||||
opt_printf_stderr(help, prog);
|
||||
return;
|
||||
}
|
||||
if (o->name == OPT_SECTION_STR) {
|
||||
opt_printf_stderr("\n");
|
||||
opt_printf_stderr(help, prog);
|
||||
return;
|
||||
}
|
||||
if (o->name == OPT_PARAM_STR) {
|
||||
opt_printf_stderr("\nParameters:\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Pad out prefix */
|
||||
memset(start, ' ', sizeof(start) - 1);
|
||||
@@ -860,7 +875,8 @@ void opt_print(const OPTIONS *o, int width)
|
||||
/* Build up the "-flag [param]" part. */
|
||||
p = start;
|
||||
*p++ = ' ';
|
||||
*p++ = '-';
|
||||
if (!doingparams)
|
||||
*p++ = '-';
|
||||
if (o->name[0])
|
||||
p += strlen(strcpy(p, o->name));
|
||||
else
|
||||
@@ -882,9 +898,8 @@ void opt_print(const OPTIONS *o, int width)
|
||||
void opt_help(const OPTIONS *list)
|
||||
{
|
||||
const OPTIONS *o;
|
||||
int i;
|
||||
int i, sawparams = 0, width = 5;
|
||||
int standard_prolog;
|
||||
int width = 5;
|
||||
char start[80 + 1];
|
||||
|
||||
/* Starts with its own help message? */
|
||||
@@ -910,7 +925,9 @@ void opt_help(const OPTIONS *list)
|
||||
|
||||
/* Now let's print. */
|
||||
for (o = list; o->name; o++) {
|
||||
opt_print(o, width);
|
||||
if (o->name == OPT_PARAM_STR)
|
||||
sawparams = 1;
|
||||
opt_print(o, sawparams, width);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-4
@@ -1262,27 +1262,37 @@ int ssl_ctx_add_crls(SSL_CTX *ctx, STACK_OF(X509_CRL) *crls, int crl_download)
|
||||
|
||||
int ssl_load_stores(SSL_CTX *ctx,
|
||||
const char *vfyCApath, const char *vfyCAfile,
|
||||
const char *vfyCAstore,
|
||||
const char *chCApath, const char *chCAfile,
|
||||
const char *chCAstore,
|
||||
STACK_OF(X509_CRL) *crls, int crl_download)
|
||||
{
|
||||
X509_STORE *vfy = NULL, *ch = NULL;
|
||||
int rv = 0;
|
||||
if (vfyCApath != NULL || vfyCAfile != NULL) {
|
||||
if (vfyCApath != NULL || vfyCAfile != NULL || vfyCAstore != NULL) {
|
||||
vfy = X509_STORE_new();
|
||||
if (vfy == NULL)
|
||||
goto err;
|
||||
if (!X509_STORE_load_locations(vfy, vfyCAfile, vfyCApath))
|
||||
if (vfyCAfile != NULL && !X509_STORE_load_file(vfy, vfyCAfile))
|
||||
goto err;
|
||||
if (vfyCApath != NULL && !X509_STORE_load_path(vfy, vfyCApath))
|
||||
goto err;
|
||||
if (vfyCAstore != NULL && !X509_STORE_load_store(vfy, vfyCAstore))
|
||||
goto err;
|
||||
add_crls_store(vfy, crls);
|
||||
SSL_CTX_set1_verify_cert_store(ctx, vfy);
|
||||
if (crl_download)
|
||||
store_setup_crl_download(vfy);
|
||||
}
|
||||
if (chCApath != NULL || chCAfile != NULL) {
|
||||
if (chCApath != NULL || chCAfile != NULL || chCAstore != NULL) {
|
||||
ch = X509_STORE_new();
|
||||
if (ch == NULL)
|
||||
goto err;
|
||||
if (!X509_STORE_load_locations(ch, chCAfile, chCApath))
|
||||
if (chCAfile != NULL && !X509_STORE_load_file(ch, chCAfile))
|
||||
goto err;
|
||||
if (chCApath != NULL && !X509_STORE_load_path(ch, chCApath))
|
||||
goto err;
|
||||
if (chCAstore != NULL && !X509_STORE_load_store(ch, chCAstore))
|
||||
goto err;
|
||||
SSL_CTX_set1_chain_cert_store(ctx, ch);
|
||||
}
|
||||
|
||||
@@ -366,6 +366,8 @@ static void list_options_for_command(const char *command)
|
||||
|
||||
if (o->name == OPT_HELP_STR
|
||||
|| o->name == OPT_MORE_STR
|
||||
|| o->name == OPT_SECTION_STR
|
||||
|| o->name == OPT_PARAM_STR
|
||||
|| o->name[0] == '\0')
|
||||
continue;
|
||||
BIO_printf(bio_out, "%s %c\n", o->name, c == '\0' ? '-' : c);
|
||||
@@ -617,7 +619,11 @@ typedef enum HELPLIST_CHOICE {
|
||||
} HELPLIST_CHOICE;
|
||||
|
||||
const OPTIONS list_options[] = {
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"1", OPT_ONE, '-', "List in one column"},
|
||||
{"verbose", OPT_VERBOSE, '-', "Verbose listing"},
|
||||
{"commands", OPT_COMMANDS, '-', "List of standard commands"},
|
||||
|
||||
+13
-6
@@ -26,15 +26,22 @@ typedef enum OPTION_choice {
|
||||
|
||||
const OPTIONS mac_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] mac_name\n"},
|
||||
{OPT_HELP_STR, 1, '-', "mac_name\t\t MAC algorithm (See list "
|
||||
"-mac-algorithms)"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"macopt", OPT_MACOPT, 's', "MAC algorithm parameters in n:v form. "
|
||||
"See 'PARAMETER NAMES' in the EVP_MAC_ docs"},
|
||||
{"macopt", OPT_MACOPT, 's', "MAC algorithm parameters in n:v form"},
|
||||
{OPT_MORE_STR, 1, '-', "See 'PARAMETER NAMES' in the EVP_MAC_ docs"},
|
||||
|
||||
OPT_SECTION("Input"),
|
||||
{"in", OPT_IN, '<', "Input file to MAC (default is stdin)"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"out", OPT_OUT, '>', "Output to filename rather than stdout"},
|
||||
{"binary", OPT_BIN, '-', "Output in binary format (Default is hexadecimal "
|
||||
"output)"},
|
||||
{"binary", OPT_BIN, '-',
|
||||
"Output in binary format (default is hexadecimal)"},
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"mac_name", 0, 0, "MAC algorithm"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+6
-1
@@ -20,9 +20,14 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS nseq_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"toseq", OPT_TOSEQ, '-', "Output NS Sequence file"},
|
||||
|
||||
OPT_SECTION("Input"),
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"toseq", OPT_TOSEQ, '-', "Output NS Sequence file"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
+80
-53
@@ -115,7 +115,7 @@ static int acfd = (int) INVALID_SOCKET;
|
||||
static int index_changed(CA_DB *);
|
||||
static void spawn_loop(void);
|
||||
static int print_syslog(const char *str, size_t len, void *levPtr);
|
||||
static void sock_timeout(int signum);
|
||||
static void socket_timeout(int signum);
|
||||
# endif
|
||||
|
||||
# ifndef OPENSSL_NO_SOCK
|
||||
@@ -134,11 +134,13 @@ typedef enum OPTION_choice {
|
||||
OPT_NO_CERT_CHECKS, OPT_NO_EXPLICIT, OPT_TRUST_OTHER,
|
||||
OPT_NO_INTERN, OPT_BADSIG, OPT_TEXT, OPT_REQ_TEXT, OPT_RESP_TEXT,
|
||||
OPT_REQIN, OPT_RESPIN, OPT_SIGNER, OPT_VAFILE, OPT_SIGN_OTHER,
|
||||
OPT_VERIFY_OTHER, OPT_CAFILE, OPT_CAPATH, OPT_NOCAFILE, OPT_NOCAPATH,
|
||||
OPT_VERIFY_OTHER, OPT_CAFILE, OPT_CAPATH, OPT_CASTORE, OPT_NOCAFILE,
|
||||
OPT_NOCAPATH, OPT_NOCASTORE,
|
||||
OPT_VALIDITY_PERIOD, OPT_STATUS_AGE, OPT_SIGNKEY, OPT_REQOUT,
|
||||
OPT_RESPOUT, OPT_PATH, OPT_ISSUER, OPT_CERT, OPT_SERIAL,
|
||||
OPT_INDEX, OPT_CA, OPT_NMIN, OPT_REQUEST, OPT_NDAYS, OPT_RSIGNER,
|
||||
OPT_RKEY, OPT_ROTHER, OPT_RMD, OPT_RSIGOPT, OPT_HEADER,
|
||||
OPT_PASSIN,
|
||||
OPT_RCID,
|
||||
OPT_V_ENUM,
|
||||
OPT_MD,
|
||||
@@ -146,31 +148,70 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS ocsp_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"out", OPT_OUTFILE, '>', "Output filename"},
|
||||
{"timeout", OPT_TIMEOUT, 'p',
|
||||
"Connection timeout (in seconds) to the OCSP responder"},
|
||||
{"url", OPT_URL, 's', "Responder URL"},
|
||||
{"host", OPT_HOST, 's', "TCP/IP hostname:port to connect to"},
|
||||
{"port", OPT_PORT, 'p', "Port to run responder on"},
|
||||
{"ignore_err", OPT_IGNORE_ERR, '-',
|
||||
"Ignore error on OCSP request or response and continue running"},
|
||||
{"noverify", OPT_NOVERIFY, '-', "Don't verify response at all"},
|
||||
{"nonce", OPT_NONCE, '-', "Add OCSP nonce to request"},
|
||||
{"no_nonce", OPT_NO_NONCE, '-', "Don't add OCSP nonce to request"},
|
||||
{"CAfile", OPT_CAFILE, '<', "Trusted certificates file"},
|
||||
{"CApath", OPT_CAPATH, '<', "Trusted certificates directory"},
|
||||
{"CAstore", OPT_CASTORE, ':', "Trusted certificates store URI"},
|
||||
{"no-CAfile", OPT_NOCAFILE, '-',
|
||||
"Do not load the default certificates file"},
|
||||
{"no-CApath", OPT_NOCAPATH, '-',
|
||||
"Do not load certificates from the default certificates directory"},
|
||||
{"no-CAstore", OPT_NOCAPATH, '-',
|
||||
"Do not load certificates from the default certificates store"},
|
||||
|
||||
OPT_SECTION("Responder"),
|
||||
{"timeout", OPT_TIMEOUT, 'p',
|
||||
"Connection timeout (in seconds) to the OCSP responder"},
|
||||
{"resp_no_certs", OPT_RESP_NO_CERTS, '-',
|
||||
"Don't include any certificates in response"},
|
||||
{"resp_key_id", OPT_RESP_KEY_ID, '-',
|
||||
"Identify response by signing certificate key ID"},
|
||||
# ifdef OCSP_DAEMON
|
||||
{"multi", OPT_MULTI, 'p', "run multiple responder processes"},
|
||||
# endif
|
||||
{"no_certs", OPT_NO_CERTS, '-',
|
||||
"Don't include any certificates in signed request"},
|
||||
{"badsig", OPT_BADSIG, '-',
|
||||
"Corrupt last byte of loaded OSCP response signature (for test)"},
|
||||
{"CA", OPT_CA, '<', "CA certificate"},
|
||||
{"nmin", OPT_NMIN, 'p', "Number of minutes before next update"},
|
||||
{"nrequest", OPT_REQUEST, 'p',
|
||||
"Number of requests to accept (default unlimited)"},
|
||||
{"reqin", OPT_REQIN, 's', "File with the DER-encoded request"},
|
||||
{"signer", OPT_SIGNER, '<', "Certificate to sign OCSP request with"},
|
||||
{"sign_other", OPT_SIGN_OTHER, '<',
|
||||
"Additional certificates to include in signed request"},
|
||||
{"index", OPT_INDEX, '<', "Certificate status index file"},
|
||||
{"ndays", OPT_NDAYS, 'p', "Number of days before next update"},
|
||||
{"rsigner", OPT_RSIGNER, '<',
|
||||
"Responder certificate to sign responses with"},
|
||||
{"rkey", OPT_RKEY, '<', "Responder key to sign responses with"},
|
||||
{"passin", OPT_PASSIN, 's', "Responder key pass phrase source"},
|
||||
{"rother", OPT_ROTHER, '<', "Other certificates to include in response"},
|
||||
{"rmd", OPT_RMD, 's', "Digest Algorithm to use in signature of OCSP response"},
|
||||
{"rsigopt", OPT_RSIGOPT, 's', "OCSP response signature parameter in n:v form"},
|
||||
{"header", OPT_HEADER, 's', "key=value header to add"},
|
||||
{"rcid", OPT_RCID, 's', "Use specified algorithm for cert id in response"},
|
||||
{"", OPT_MD, '-', "Any supported digest algorithm (sha1,sha256, ... )"},
|
||||
|
||||
OPT_SECTION("Client"),
|
||||
{"url", OPT_URL, 's', "Responder URL"},
|
||||
{"host", OPT_HOST, 's', "TCP/IP hostname:port to connect to"},
|
||||
{"port", OPT_PORT, 'p', "Port to run responder on"},
|
||||
{"out", OPT_OUTFILE, '>', "Output filename"},
|
||||
{"noverify", OPT_NOVERIFY, '-', "Don't verify response at all"},
|
||||
{"nonce", OPT_NONCE, '-', "Add OCSP nonce to request"},
|
||||
{"no_nonce", OPT_NO_NONCE, '-', "Don't add OCSP nonce to request"},
|
||||
{"no_signature_verify", OPT_NO_SIGNATURE_VERIFY, '-',
|
||||
"Don't check signature on response"},
|
||||
{"resp_key_id", OPT_RESP_KEY_ID, '-',
|
||||
"Identify response by signing certificate key ID"},
|
||||
{"no_cert_verify", OPT_NO_CERT_VERIFY, '-',
|
||||
"Don't check signing certificate"},
|
||||
{"text", OPT_TEXT, '-', "Print text form of request and response"},
|
||||
{"req_text", OPT_REQ_TEXT, '-', "Print text form of request"},
|
||||
{"resp_text", OPT_RESP_TEXT, '-', "Print text form of response"},
|
||||
{"no_chain", OPT_NO_CHAIN, '-', "Don't chain verify response"},
|
||||
{"no_cert_checks", OPT_NO_CERT_CHECKS, '-',
|
||||
"Don't do additional checks on signing certificate"},
|
||||
@@ -180,50 +221,21 @@ const OPTIONS ocsp_options[] = {
|
||||
"Don't verify additional certificates"},
|
||||
{"no_intern", OPT_NO_INTERN, '-',
|
||||
"Don't search certificates contained in response for signer"},
|
||||
{"badsig", OPT_BADSIG, '-',
|
||||
"Corrupt last byte of loaded OSCP response signature (for test)"},
|
||||
{"text", OPT_TEXT, '-', "Print text form of request and response"},
|
||||
{"req_text", OPT_REQ_TEXT, '-', "Print text form of request"},
|
||||
{"resp_text", OPT_RESP_TEXT, '-', "Print text form of response"},
|
||||
{"reqin", OPT_REQIN, 's', "File with the DER-encoded request"},
|
||||
{"respin", OPT_RESPIN, 's', "File with the DER-encoded response"},
|
||||
{"signer", OPT_SIGNER, '<', "Certificate to sign OCSP request with"},
|
||||
{"VAfile", OPT_VAFILE, '<', "Validator certificates file"},
|
||||
{"sign_other", OPT_SIGN_OTHER, '<',
|
||||
"Additional certificates to include in signed request"},
|
||||
{"verify_other", OPT_VERIFY_OTHER, '<',
|
||||
"Additional certificates to search for signer"},
|
||||
{"CAfile", OPT_CAFILE, '<', "Trusted certificates file"},
|
||||
{"CApath", OPT_CAPATH, '<', "Trusted certificates directory"},
|
||||
{"no-CAfile", OPT_NOCAFILE, '-',
|
||||
"Do not load the default certificates file"},
|
||||
{"no-CApath", OPT_NOCAPATH, '-',
|
||||
"Do not load certificates from the default certificates directory"},
|
||||
{"path", OPT_PATH, 's', "Path to use in OCSP request"},
|
||||
{"cert", OPT_CERT, '<', "Certificate to check"},
|
||||
{"serial", OPT_SERIAL, 's', "Serial number to check"},
|
||||
{"validity_period", OPT_VALIDITY_PERIOD, 'u',
|
||||
"Maximum validity discrepancy in seconds"},
|
||||
{"status_age", OPT_STATUS_AGE, 'p', "Maximum status age in seconds"},
|
||||
{"signkey", OPT_SIGNKEY, 's', "Private key to sign OCSP request with"},
|
||||
{"reqout", OPT_REQOUT, 's', "Output file for the DER-encoded request"},
|
||||
{"respout", OPT_RESPOUT, 's', "Output file for the DER-encoded response"},
|
||||
{"path", OPT_PATH, 's', "Path to use in OCSP request"},
|
||||
{"issuer", OPT_ISSUER, '<', "Issuer certificate"},
|
||||
{"cert", OPT_CERT, '<', "Certificate to check"},
|
||||
{"serial", OPT_SERIAL, 's', "Serial number to check"},
|
||||
{"index", OPT_INDEX, '<', "Certificate status index file"},
|
||||
{"CA", OPT_CA, '<', "CA certificate"},
|
||||
{"nmin", OPT_NMIN, 'p', "Number of minutes before next update"},
|
||||
{"nrequest", OPT_REQUEST, 'p',
|
||||
"Number of requests to accept (default unlimited)"},
|
||||
{"ndays", OPT_NDAYS, 'p', "Number of days before next update"},
|
||||
{"rsigner", OPT_RSIGNER, '<',
|
||||
"Responder certificate to sign responses with"},
|
||||
{"rkey", OPT_RKEY, '<', "Responder key to sign responses with"},
|
||||
{"rother", OPT_ROTHER, '<', "Other certificates to include in response"},
|
||||
{"rmd", OPT_RMD, 's', "Digest Algorithm to use in signature of OCSP response"},
|
||||
{"rsigopt", OPT_RSIGOPT, 's', "OCSP response signature parameter in n:v form"},
|
||||
{"header", OPT_HEADER, 's', "key=value header to add"},
|
||||
{"rcid", OPT_RCID, 's', "Use specified algorithm for cert id in response"},
|
||||
{"", OPT_MD, '-', "Any supported digest algorithm (sha1,sha256, ... )"},
|
||||
{"status_age", OPT_STATUS_AGE, 'p', "Maximum status age in seconds"},
|
||||
|
||||
OPT_V_OPTIONS,
|
||||
{NULL}
|
||||
};
|
||||
@@ -250,16 +262,17 @@ int ocsp_main(int argc, char **argv)
|
||||
X509 *signer = NULL, *rsigner = NULL;
|
||||
X509_STORE *store = NULL;
|
||||
X509_VERIFY_PARAM *vpm = NULL;
|
||||
const char *CAfile = NULL, *CApath = NULL;
|
||||
const char *CAfile = NULL, *CApath = NULL, *CAstore = NULL;
|
||||
char *header, *value;
|
||||
char *host = NULL, *port = NULL, *path = "/", *outfile = NULL;
|
||||
char *rca_filename = NULL, *reqin = NULL, *respin = NULL;
|
||||
char *reqout = NULL, *respout = NULL, *ridx_filename = NULL;
|
||||
char *rsignfile = NULL, *rkeyfile = NULL;
|
||||
char *passinarg = NULL, *passin = NULL;
|
||||
char *sign_certfile = NULL, *verify_certfile = NULL, *rcertfile = NULL;
|
||||
char *signfile = NULL, *keyfile = NULL;
|
||||
char *thost = NULL, *tport = NULL, *tpath = NULL;
|
||||
int noCAfile = 0, noCApath = 0;
|
||||
int noCAfile = 0, noCApath = 0, noCAstore = 0;
|
||||
int accept_count = -1, add_nonce = 1, noverify = 0, use_ssl = -1;
|
||||
int vpmtouched = 0, badsig = 0, i, ignore_err = 0, nmin = 0, ndays = -1;
|
||||
int req_text = 0, resp_text = 0, ret = 1;
|
||||
@@ -395,12 +408,18 @@ int ocsp_main(int argc, char **argv)
|
||||
case OPT_CAPATH:
|
||||
CApath = opt_arg();
|
||||
break;
|
||||
case OPT_CASTORE:
|
||||
CAstore = opt_arg();
|
||||
break;
|
||||
case OPT_NOCAFILE:
|
||||
noCAfile = 1;
|
||||
break;
|
||||
case OPT_NOCAPATH:
|
||||
noCApath = 1;
|
||||
break;
|
||||
case OPT_NOCASTORE:
|
||||
noCAstore = 1;
|
||||
break;
|
||||
case OPT_V_CASES:
|
||||
if (!opt_verify(o, vpm))
|
||||
goto end;
|
||||
@@ -479,6 +498,9 @@ int ocsp_main(int argc, char **argv)
|
||||
case OPT_RKEY:
|
||||
rkeyfile = opt_arg();
|
||||
break;
|
||||
case OPT_PASSIN:
|
||||
passinarg = opt_arg();
|
||||
break;
|
||||
case OPT_ROTHER:
|
||||
rcertfile = opt_arg();
|
||||
break;
|
||||
@@ -581,7 +603,11 @@ int ocsp_main(int argc, char **argv)
|
||||
"responder other certificates"))
|
||||
goto end;
|
||||
}
|
||||
rkey = load_key(rkeyfile, FORMAT_PEM, 0, NULL, NULL,
|
||||
if (!app_passwd(passinarg, NULL, &passin, NULL)) {
|
||||
BIO_printf(bio_err, "Error getting password\n");
|
||||
goto end;
|
||||
}
|
||||
rkey = load_key(rkeyfile, FORMAT_PEM, 0, passin, NULL,
|
||||
"responder private key");
|
||||
if (rkey == NULL)
|
||||
goto end;
|
||||
@@ -606,7 +632,7 @@ int ocsp_main(int argc, char **argv)
|
||||
if (multi && acbio != NULL)
|
||||
spawn_loop();
|
||||
if (acbio != NULL && req_timeout > 0)
|
||||
signal(SIGALRM, sock_timeout);
|
||||
signal(SIGALRM, socket_timeout);
|
||||
#endif
|
||||
|
||||
if (acbio != NULL)
|
||||
@@ -765,7 +791,8 @@ redo_accept:
|
||||
}
|
||||
|
||||
if (store == NULL) {
|
||||
store = setup_verify(CAfile, CApath, noCAfile, noCApath);
|
||||
store = setup_verify(CAfile, noCAfile, CApath, noCApath,
|
||||
CAstore, noCAstore);
|
||||
if (!store)
|
||||
goto end;
|
||||
}
|
||||
@@ -1372,7 +1399,7 @@ static int urldecode(char *p)
|
||||
# endif
|
||||
|
||||
# ifdef OCSP_DAEMON
|
||||
static void sock_timeout(int signum)
|
||||
static void socket_timeout(int signum)
|
||||
{
|
||||
if (acfd != (int)INVALID_SOCKET)
|
||||
(void)shutdown(acfd, SHUT_RD);
|
||||
|
||||
+18
-24
@@ -113,10 +113,10 @@ static size_t internal_trace_cb(const char *buf, size_t cnt,
|
||||
tid = CRYPTO_THREAD_get_current_id();
|
||||
hex = OPENSSL_buf2hexstr((const unsigned char *)&tid, sizeof(tid));
|
||||
BIO_snprintf(buffer, sizeof(buffer), "TRACE[%s]:%s: ",
|
||||
hex, OSSL_trace_get_category_name(category));
|
||||
hex == NULL ? "<null>" : hex,
|
||||
OSSL_trace_get_category_name(category));
|
||||
OPENSSL_free(hex);
|
||||
BIO_ctrl(trace_data->bio, PREFIX_CTRL_SET_PREFIX,
|
||||
strlen(buffer), buffer);
|
||||
BIO_set_prefix(trace_data->bio, buffer);
|
||||
break;
|
||||
case OSSL_TRACE_CTRL_WRITE:
|
||||
if (!ossl_assert(trace_data->ingroup))
|
||||
@@ -129,7 +129,7 @@ static size_t internal_trace_cb(const char *buf, size_t cnt,
|
||||
return 0;
|
||||
trace_data->ingroup = 0;
|
||||
|
||||
BIO_ctrl(trace_data->bio, PREFIX_CTRL_SET_PREFIX, 0, NULL);
|
||||
BIO_set_prefix(trace_data->bio, NULL);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -161,8 +161,7 @@ static void setup_trace_category(int category)
|
||||
if (OSSL_trace_enabled(category))
|
||||
return;
|
||||
|
||||
channel = BIO_push(BIO_new(apps_bf_prefix()),
|
||||
dup_bio_err(FORMAT_TEXT));
|
||||
channel = BIO_push(BIO_new(BIO_f_prefix()), dup_bio_err(FORMAT_TEXT));
|
||||
trace_data = OPENSSL_zalloc(sizeof(*trace_data));
|
||||
|
||||
if (trace_data == NULL
|
||||
@@ -246,22 +245,10 @@ int main(int argc, char *argv[])
|
||||
win32_utf8argv(&argc, &argv);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We use the prefix method to get the trace output we want. Since some
|
||||
* trace outputs happen with OPENSSL_cleanup(), which is run automatically
|
||||
* after exit(), we need to destroy the prefix method as late as possible.
|
||||
*/
|
||||
atexit(destroy_prefix_method);
|
||||
|
||||
#ifndef OPENSSL_NO_TRACE
|
||||
setup_trace(getenv("OPENSSL_TRACE"));
|
||||
#endif
|
||||
|
||||
p = getenv("OPENSSL_DEBUG_MEMORY");
|
||||
if (p != NULL && strcmp(p, "on") == 0)
|
||||
CRYPTO_set_mem_debug(1);
|
||||
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
|
||||
|
||||
if (getenv("OPENSSL_FIPS")) {
|
||||
BIO_printf(bio_err, "FIPS mode not supported.\n");
|
||||
return 1;
|
||||
@@ -276,6 +263,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
prog = prog_init();
|
||||
if (prog == NULL) {
|
||||
BIO_printf(bio_err,
|
||||
"FATAL: Startup failure (dev note: prog_init() failed)\n");
|
||||
ERR_print_errors(bio_err);
|
||||
ret = 1;
|
||||
goto end;
|
||||
}
|
||||
pname = opt_progname(argv[0]);
|
||||
|
||||
/* first check the program name */
|
||||
@@ -371,10 +365,6 @@ int main(int argc, char *argv[])
|
||||
BIO_free(bio_in);
|
||||
BIO_free_all(bio_out);
|
||||
apps_shutdown();
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
if (CRYPTO_mem_leaks(bio_err) <= 0)
|
||||
ret = 1;
|
||||
#endif
|
||||
BIO_free(bio_err);
|
||||
EXIT(ret);
|
||||
}
|
||||
@@ -384,9 +374,13 @@ typedef enum HELP_CHOICE {
|
||||
} HELP_CHOICE;
|
||||
|
||||
const OPTIONS help_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: help [options]\n"},
|
||||
{OPT_HELP_STR, 1, '-', " help [command]\n"},
|
||||
{OPT_HELP_STR, 1, '-', "Usage: help [options] [command]\n"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_hHELP, '-', "Display this summary"},
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"command", 0, 0, "Name of command to display help (optional)"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+15
-2
@@ -59,15 +59,24 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS passwd_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] [password]\n"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
|
||||
OPT_SECTION("Input"),
|
||||
{"in", OPT_IN, '<', "Read passwords from file"},
|
||||
{"noverify", OPT_NOVERIFY, '-',
|
||||
"Never verify when reading password from terminal"},
|
||||
{"stdin", OPT_STDIN, '-', "Read passwords from stdin"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"quiet", OPT_QUIET, '-', "No warnings"},
|
||||
{"table", OPT_TABLE, '-', "Format output as table"},
|
||||
{"reverse", OPT_REVERSE, '-', "Switch table columns"},
|
||||
|
||||
OPT_SECTION("Cryptographic"),
|
||||
{"salt", OPT_SALT, 's', "Use provided salt"},
|
||||
{"stdin", OPT_STDIN, '-', "Read passwords from stdin"},
|
||||
{"6", OPT_6, '-', "SHA512-based password algorithm"},
|
||||
{"5", OPT_5, '-', "SHA256-based password algorithm"},
|
||||
{"apr1", OPT_APR1, '-', "MD5-based password algorithm, Apache variant"},
|
||||
@@ -76,7 +85,11 @@ const OPTIONS passwd_options[] = {
|
||||
#ifndef OPENSSL_NO_DES
|
||||
{"crypt", OPT_CRYPT, '-', "Standard Unix password algorithm (default)"},
|
||||
#endif
|
||||
|
||||
OPT_R_OPTIONS,
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"password", 0, 0, "Password text to digest (optional)"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
@@ -807,7 +820,7 @@ static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p,
|
||||
(*salt_p)[i] = cov_2char[(*salt_p)[i] & 0x3f]; /* 6 bits */
|
||||
(*salt_p)[i] = 0;
|
||||
# ifdef CHARSET_EBCDIC
|
||||
/* The password encryption funtion will convert back to ASCII */
|
||||
/* The password encryption function will convert back to ASCII */
|
||||
ascii2ebcdic(*salt_p, *salt_p, saltlen);
|
||||
# endif
|
||||
}
|
||||
|
||||
+65
-39
@@ -53,27 +53,65 @@ typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_CIPHER, OPT_NOKEYS, OPT_KEYEX, OPT_KEYSIG, OPT_NOCERTS, OPT_CLCERTS,
|
||||
OPT_CACERTS, OPT_NOOUT, OPT_INFO, OPT_CHAIN, OPT_TWOPASS, OPT_NOMACVER,
|
||||
OPT_DESCERT, OPT_EXPORT, OPT_NOITER, OPT_MACITER, OPT_NOMACITER,
|
||||
OPT_DESCERT, OPT_EXPORT, OPT_ITER, OPT_NOITER, OPT_MACITER, OPT_NOMACITER,
|
||||
OPT_NOMAC, OPT_LMK, OPT_NODES, OPT_MACALG, OPT_CERTPBE, OPT_KEYPBE,
|
||||
OPT_INKEY, OPT_CERTFILE, OPT_NAME, OPT_CSP, OPT_CANAME,
|
||||
OPT_IN, OPT_OUT, OPT_PASSIN, OPT_PASSOUT, OPT_PASSWORD, OPT_CAPATH,
|
||||
OPT_CAFILE, OPT_NOCAPATH, OPT_NOCAFILE, OPT_ENGINE,
|
||||
OPT_CAFILE, OPT_CASTORE, OPT_NOCAPATH, OPT_NOCAFILE, OPT_NOCASTORE, OPT_ENGINE,
|
||||
OPT_R_ENUM
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS pkcs12_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"nokeys", OPT_NOKEYS, '-', "Don't output private keys"},
|
||||
{"keyex", OPT_KEYEX, '-', "Set MS key exchange type"},
|
||||
{"keysig", OPT_KEYSIG, '-', "Set MS key signature type"},
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
# endif
|
||||
|
||||
OPT_SECTION("CA"),
|
||||
{"CApath", OPT_CAPATH, '/', "PEM-format directory of CA's"},
|
||||
{"CAfile", OPT_CAFILE, '<', "PEM-format file of CA's"},
|
||||
{"CAstore", OPT_CASTORE, ':', "URI to store of CA's"},
|
||||
{"no-CAfile", OPT_NOCAFILE, '-',
|
||||
"Do not load the default certificates file"},
|
||||
{"no-CApath", OPT_NOCAPATH, '-',
|
||||
"Do not load certificates from the default certificates directory"},
|
||||
{"no-CAstore", OPT_NOCASTORE, '-',
|
||||
"Do not load certificates from the default certificates store"},
|
||||
|
||||
OPT_SECTION("Input"),
|
||||
{"inkey", OPT_INKEY, 's', "Private key if not infile"},
|
||||
{"certfile", OPT_CERTFILE, '<', "Load certs from file"},
|
||||
{"name", OPT_NAME, 's', "Use name as friendly name"},
|
||||
{"CSP", OPT_CSP, 's', "Microsoft CSP name"},
|
||||
{"caname", OPT_CANAME, 's',
|
||||
"Use name as CA friendly name (can be repeated)"},
|
||||
{"in", OPT_IN, '<', "Input filename"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"export", OPT_EXPORT, '-', "Output PKCS12 file"},
|
||||
{"LMK", OPT_LMK, '-',
|
||||
"Add local machine keyset attribute to private key"},
|
||||
{"macalg", OPT_MACALG, 's',
|
||||
"Digest algorithm used in MAC (default SHA1)"},
|
||||
{"keypbe", OPT_KEYPBE, 's', "Private key PBE algorithm (default 3DES)"},
|
||||
{"out", OPT_OUT, '>', "Output filename"},
|
||||
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
|
||||
{"password", OPT_PASSWORD, 's', "Set import/export password source"},
|
||||
{"nocerts", OPT_NOCERTS, '-', "Don't output certificates"},
|
||||
{"clcerts", OPT_CLCERTS, '-', "Only output client certificates"},
|
||||
{"cacerts", OPT_CACERTS, '-', "Only output CA certificates"},
|
||||
{"noout", OPT_NOOUT, '-', "Don't output anything, just verify"},
|
||||
{"info", OPT_INFO, '-', "Print info about PKCS#12 structure"},
|
||||
{"chain", OPT_CHAIN, '-', "Add certificate chain"},
|
||||
{"twopass", OPT_TWOPASS, '-', "Separate MAC, encryption passwords"},
|
||||
{"nomacver", OPT_NOMACVER, '-', "Don't verify MAC"},
|
||||
{"info", OPT_INFO, '-', "Print info about PKCS#12 structure"},
|
||||
{"nokeys", OPT_NOKEYS, '-', "Don't output private keys"},
|
||||
{"keyex", OPT_KEYEX, '-', "Set MS key exchange type"},
|
||||
{"keysig", OPT_KEYSIG, '-', "Set MS key signature type"},
|
||||
|
||||
OPT_SECTION("Encryption"),
|
||||
# ifndef OPENSSL_NO_RC2
|
||||
{"descert", OPT_DESCERT, '-',
|
||||
"Encrypt output with 3DES (default RC2-40)"},
|
||||
@@ -83,39 +121,15 @@ const OPTIONS pkcs12_options[] = {
|
||||
{"descert", OPT_DESCERT, '-', "Encrypt output with 3DES (the default)"},
|
||||
{"certpbe", OPT_CERTPBE, 's', "Certificate PBE algorithm (default 3DES)"},
|
||||
# endif
|
||||
{"export", OPT_EXPORT, '-', "Output PKCS12 file"},
|
||||
{"noiter", OPT_NOITER, '-', "Don't use encryption iteration"},
|
||||
{"maciter", OPT_MACITER, '-', "Use MAC iteration"},
|
||||
{"iter", OPT_ITER, 'p', "Specify the iteration count for encryption key and MAC"},
|
||||
{"noiter", OPT_NOITER, '-', "Don't use encryption key iteration"},
|
||||
{"maciter", OPT_MACITER, '-', "Unused, kept for backwards compatibility"},
|
||||
{"nomaciter", OPT_NOMACITER, '-', "Don't use MAC iteration"},
|
||||
{"nomac", OPT_NOMAC, '-', "Don't generate MAC"},
|
||||
{"LMK", OPT_LMK, '-',
|
||||
"Add local machine keyset attribute to private key"},
|
||||
{"nodes", OPT_NODES, '-', "Don't encrypt private keys"},
|
||||
{"macalg", OPT_MACALG, 's',
|
||||
"Digest algorithm used in MAC (default SHA1)"},
|
||||
{"keypbe", OPT_KEYPBE, 's', "Private key PBE algorithm (default 3DES)"},
|
||||
OPT_R_OPTIONS,
|
||||
{"inkey", OPT_INKEY, 's', "Private key if not infile"},
|
||||
{"certfile", OPT_CERTFILE, '<', "Load certs from file"},
|
||||
{"name", OPT_NAME, 's', "Use name as friendly name"},
|
||||
{"CSP", OPT_CSP, 's', "Microsoft CSP name"},
|
||||
{"caname", OPT_CANAME, 's',
|
||||
"Use name as CA friendly name (can be repeated)"},
|
||||
{"in", OPT_IN, '<', "Input filename"},
|
||||
{"out", OPT_OUT, '>', "Output filename"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
|
||||
{"password", OPT_PASSWORD, 's', "Set import/export password source"},
|
||||
{"CApath", OPT_CAPATH, '/', "PEM-format directory of CA's"},
|
||||
{"CAfile", OPT_CAFILE, '<', "PEM-format file of CA's"},
|
||||
{"no-CAfile", OPT_NOCAFILE, '-',
|
||||
"Do not load the default certificates file"},
|
||||
{"no-CApath", OPT_NOCAPATH, '-',
|
||||
"Do not load certificates from the default certificates directory"},
|
||||
{"", OPT_CIPHER, '-', "Any supported cipher"},
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
# endif
|
||||
|
||||
OPT_R_OPTIONS,
|
||||
{NULL}
|
||||
};
|
||||
|
||||
@@ -137,8 +151,8 @@ int pkcs12_main(int argc, char **argv)
|
||||
char *passinarg = NULL, *passoutarg = NULL, *passarg = NULL;
|
||||
char *passin = NULL, *passout = NULL, *macalg = NULL;
|
||||
char *cpass = NULL, *mpass = NULL, *badpass = NULL;
|
||||
const char *CApath = NULL, *CAfile = NULL, *prog;
|
||||
int noCApath = 0, noCAfile = 0;
|
||||
const char *CApath = NULL, *CAfile = NULL, *CAstore = NULL, *prog;
|
||||
int noCApath = 0, noCAfile = 0, noCAstore = 0;
|
||||
ENGINE *e = NULL;
|
||||
BIO *in = NULL, *out = NULL;
|
||||
PKCS12 *p12 = NULL;
|
||||
@@ -201,11 +215,16 @@ int pkcs12_main(int argc, char **argv)
|
||||
if (!opt_cipher(opt_unknown(), &enc))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_ITER:
|
||||
if (!opt_int(opt_arg(), &iter))
|
||||
goto opthelp;
|
||||
maciter = iter;
|
||||
break;
|
||||
case OPT_NOITER:
|
||||
iter = 1;
|
||||
break;
|
||||
case OPT_MACITER:
|
||||
maciter = PKCS12_DEFAULT_ITER;
|
||||
/* no-op */
|
||||
break;
|
||||
case OPT_NOMACITER:
|
||||
maciter = 1;
|
||||
@@ -270,12 +289,18 @@ int pkcs12_main(int argc, char **argv)
|
||||
case OPT_CAPATH:
|
||||
CApath = opt_arg();
|
||||
break;
|
||||
case OPT_CASTORE:
|
||||
CAstore = opt_arg();
|
||||
break;
|
||||
case OPT_CAFILE:
|
||||
CAfile = opt_arg();
|
||||
break;
|
||||
case OPT_NOCAPATH:
|
||||
noCApath = 1;
|
||||
break;
|
||||
case OPT_NOCASTORE:
|
||||
noCAstore = 1;
|
||||
break;
|
||||
case OPT_NOCAFILE:
|
||||
noCAfile = 1;
|
||||
break;
|
||||
@@ -404,7 +429,8 @@ int pkcs12_main(int argc, char **argv)
|
||||
int vret;
|
||||
STACK_OF(X509) *chain2;
|
||||
X509_STORE *store;
|
||||
if ((store = setup_verify(CAfile, CApath, noCAfile, noCApath))
|
||||
if ((store = setup_verify(CAfile, noCAfile, CApath, noCApath,
|
||||
CAstore, noCAstore))
|
||||
== NULL)
|
||||
goto export_end;
|
||||
|
||||
|
||||
+9
-4
@@ -27,9 +27,17 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS pkcs7_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"inform", OPT_INFORM, 'F', "Input format - DER or PEM"},
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
|
||||
OPT_SECTION("Input"),
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
{"inform", OPT_INFORM, 'F', "Input format - DER or PEM"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format - DER or PEM"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"noout", OPT_NOOUT, '-', "Don't output encoded data"},
|
||||
@@ -37,9 +45,6 @@ const OPTIONS pkcs7_options[] = {
|
||||
{"print", OPT_PRINT, '-', "Print out all fields of the PKCS7 structure"},
|
||||
{"print_certs", OPT_PRINT_CERTS, '-',
|
||||
"Print_certs print any certs or crl in the input"},
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+23
-15
@@ -30,31 +30,39 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS pkcs8_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"inform", OPT_INFORM, 'F', "Input format (DER or PEM)"},
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format (DER or PEM)"},
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"topk8", OPT_TOPK8, '-', "Output PKCS8 file"},
|
||||
{"noiter", OPT_NOITER, '-', "Use 1 as iteration count"},
|
||||
{"nocrypt", OPT_NOCRYPT, '-', "Use or expect unencrypted private key"},
|
||||
OPT_R_OPTIONS,
|
||||
{"v2", OPT_V2, 's', "Use PKCS#5 v2.0 and cipher"},
|
||||
{"v1", OPT_V1, 's', "Use PKCS#5 v1.5 and cipher"},
|
||||
{"v2prf", OPT_V2PRF, 's', "Set the PRF algorithm to use with PKCS#5 v2.0"},
|
||||
{"iter", OPT_ITER, 'p', "Specify the iteration count"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
|
||||
{"traditional", OPT_TRADITIONAL, '-', "use traditional format private key"},
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
{"v1", OPT_V1, 's', "Use PKCS#5 v1.5 and cipher"},
|
||||
{"v2", OPT_V2, 's', "Use PKCS#5 v2.0 and cipher"},
|
||||
{"v2prf", OPT_V2PRF, 's', "Set the PRF algorithm to use with PKCS#5 v2.0"},
|
||||
|
||||
OPT_SECTION("Input"),
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
{"inform", OPT_INFORM, 'F', "Input format (DER or PEM)"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"nocrypt", OPT_NOCRYPT, '-', "Use or expect unencrypted private key"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format (DER or PEM)"},
|
||||
{"topk8", OPT_TOPK8, '-', "Output PKCS8 file"},
|
||||
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
|
||||
{"traditional", OPT_TRADITIONAL, '-', "use traditional format private key"},
|
||||
{"iter", OPT_ITER, 'p', "Specify the iteration count"},
|
||||
{"noiter", OPT_NOITER, '-', "Use 1 as iteration count"},
|
||||
|
||||
#ifndef OPENSSL_NO_SCRYPT
|
||||
OPT_SECTION("Scrypt"),
|
||||
{"scrypt", OPT_SCRYPT, '-', "Use scrypt algorithm"},
|
||||
{"scrypt_N", OPT_SCRYPT_N, 's', "Set scrypt N parameter"},
|
||||
{"scrypt_r", OPT_SCRYPT_R, 's', "Set scrypt r parameter"},
|
||||
{"scrypt_p", OPT_SCRYPT_P, 's', "Set scrypt p parameter"},
|
||||
#endif
|
||||
|
||||
OPT_R_OPTIONS,
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+21
-15
@@ -23,27 +23,33 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS pkey_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"inform", OPT_INFORM, 'f', "Input format (DER or PEM)"},
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format (DER or PEM)"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
|
||||
{"in", OPT_IN, 's', "Input key"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"pubin", OPT_PUBIN, '-',
|
||||
"Read public key from input (default is private key)"},
|
||||
{"pubout", OPT_PUBOUT, '-', "Output public key, not private"},
|
||||
{"text_pub", OPT_TEXT_PUB, '-', "Only output public key components"},
|
||||
{"text", OPT_TEXT, '-', "Output in plaintext as well"},
|
||||
{"noout", OPT_NOOUT, '-', "Don't output the key"},
|
||||
{"", OPT_MD, '-', "Any supported cipher"},
|
||||
{"traditional", OPT_TRADITIONAL, '-',
|
||||
"Use traditional format for private keys"},
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
{"check", OPT_CHECK, '-', "Check key consistency"},
|
||||
{"pubcheck", OPT_PUB_CHECK, '-', "Check public key consistency"},
|
||||
{"", OPT_MD, '-', "Any supported cipher"},
|
||||
|
||||
OPT_SECTION("Input"),
|
||||
{"in", OPT_IN, 's', "Input key"},
|
||||
{"inform", OPT_INFORM, 'f', "Input format (DER or PEM)"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"pubin", OPT_PUBIN, '-',
|
||||
"Read public key from input (default is private key)"},
|
||||
{"traditional", OPT_TRADITIONAL, '-',
|
||||
"Use traditional format for private keys"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format (DER or PEM)"},
|
||||
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"pubout", OPT_PUBOUT, '-', "Output public key, not private"},
|
||||
{"text_pub", OPT_TEXT_PUB, '-', "Only output public key components"},
|
||||
{"text", OPT_TEXT, '-', "Output in plaintext as well"},
|
||||
{"noout", OPT_NOOUT, '-', "Don't output the key"},
|
||||
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+9
-4
@@ -22,15 +22,20 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS pkeyparam_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"text", OPT_TEXT, '-', "Print parameters as text"},
|
||||
{"noout", OPT_NOOUT, '-', "Don't output encoded parameters"},
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
{"check", OPT_CHECK, '-', "Check key param consistency"},
|
||||
|
||||
OPT_SECTION("Input"),
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"text", OPT_TEXT, '-', "Print parameters as text"},
|
||||
{"noout", OPT_NOOUT, '-', "Don't output encoded parameters"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+37
-29
@@ -49,41 +49,49 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS pkeyutl_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"in", OPT_IN, '<', "Input file - default stdin"},
|
||||
{"rawin", OPT_RAWIN, '-', "Indicate the input data is in raw form"},
|
||||
{"digest", OPT_DIGEST, 's',
|
||||
"Specify the digest algorithm when signing the raw input data"},
|
||||
{"out", OPT_OUT, '>', "Output file - default stdout"},
|
||||
{"pubin", OPT_PUBIN, '-', "Input is a public key"},
|
||||
{"certin", OPT_CERTIN, '-', "Input is a cert with a public key"},
|
||||
{"asn1parse", OPT_ASN1PARSE, '-', "asn1parse the output data"},
|
||||
{"hexdump", OPT_HEXDUMP, '-', "Hex dump output"},
|
||||
{"sign", OPT_SIGN, '-', "Sign input data with private key"},
|
||||
{"verify", OPT_VERIFY, '-', "Verify with public key"},
|
||||
{"verifyrecover", OPT_VERIFYRECOVER, '-',
|
||||
"Verify with public key, recover original data"},
|
||||
{"rev", OPT_REV, '-', "Reverse the order of the input buffer"},
|
||||
{"encrypt", OPT_ENCRYPT, '-', "Encrypt input data with public key"},
|
||||
{"decrypt", OPT_DECRYPT, '-', "Decrypt input data with private key"},
|
||||
{"derive", OPT_DERIVE, '-', "Derive shared secret"},
|
||||
{"kdf", OPT_KDF, 's', "Use KDF algorithm"},
|
||||
{"kdflen", OPT_KDFLEN, 'p', "KDF algorithm output length"},
|
||||
{"sigfile", OPT_SIGFILE, '<', "Signature file (verify operation only)"},
|
||||
{"inkey", OPT_INKEY, 's', "Input private key file"},
|
||||
{"peerkey", OPT_PEERKEY, 's', "Peer key file used in key derivation"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"peerform", OPT_PEERFORM, 'E', "Peer key format - default PEM"},
|
||||
{"keyform", OPT_KEYFORM, 'E', "Private key format - default PEM"},
|
||||
{"pkeyopt", OPT_PKEYOPT, 's', "Public key options as opt:value"},
|
||||
{"pkeyopt_passin", OPT_PKEYOPT_PASSIN, 's',
|
||||
"Public key option that is read as a passphrase argument opt:passphrase"},
|
||||
OPT_R_OPTIONS,
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
{"engine_impl", OPT_ENGINE_IMPL, '-',
|
||||
"Also use engine given by -engine for crypto operations"},
|
||||
#endif
|
||||
{"sign", OPT_SIGN, '-', "Sign input data with private key"},
|
||||
{"verify", OPT_VERIFY, '-', "Verify with public key"},
|
||||
{"encrypt", OPT_ENCRYPT, '-', "Encrypt input data with public key"},
|
||||
{"decrypt", OPT_DECRYPT, '-', "Decrypt input data with private key"},
|
||||
{"derive", OPT_DERIVE, '-', "Derive shared secret"},
|
||||
|
||||
OPT_SECTION("Input"),
|
||||
{"in", OPT_IN, '<', "Input file - default stdin"},
|
||||
{"rawin", OPT_RAWIN, '-', "Indicate the input data is in raw form"},
|
||||
{"pubin", OPT_PUBIN, '-', "Input is a public key"},
|
||||
{"inkey", OPT_INKEY, 's', "Input private key file"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"peerkey", OPT_PEERKEY, 's', "Peer key file used in key derivation"},
|
||||
{"peerform", OPT_PEERFORM, 'E', "Peer key format - default PEM"},
|
||||
{"certin", OPT_CERTIN, '-', "Input is a cert with a public key"},
|
||||
{"rev", OPT_REV, '-', "Reverse the order of the input buffer"},
|
||||
{"sigfile", OPT_SIGFILE, '<', "Signature file (verify operation only)"},
|
||||
{"keyform", OPT_KEYFORM, 'E', "Private key format - default PEM"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"out", OPT_OUT, '>', "Output file - default stdout"},
|
||||
{"asn1parse", OPT_ASN1PARSE, '-', "asn1parse the output data"},
|
||||
{"hexdump", OPT_HEXDUMP, '-', "Hex dump output"},
|
||||
{"verifyrecover", OPT_VERIFYRECOVER, '-',
|
||||
"Verify with public key, recover original data"},
|
||||
|
||||
OPT_SECTION("Signing/Derivation"),
|
||||
{"digest", OPT_DIGEST, 's',
|
||||
"Specify the digest algorithm when signing the raw input data"},
|
||||
{"pkeyopt", OPT_PKEYOPT, 's', "Public key options as opt:value"},
|
||||
{"pkeyopt_passin", OPT_PKEYOPT_PASSIN, 's',
|
||||
"Public key option that is read as a passphrase argument opt:passphrase"},
|
||||
{"kdf", OPT_KDF, 's', "Use KDF algorithm"},
|
||||
{"kdflen", OPT_KDFLEN, 'p', "KDF algorithm output length"},
|
||||
|
||||
OPT_R_OPTIONS,
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+9
-4
@@ -20,15 +20,20 @@ typedef enum OPTION_choice {
|
||||
|
||||
const OPTIONS prime_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] [number...]\n"},
|
||||
{OPT_HELP_STR, 1, '-',
|
||||
" number Number to check for primality\n"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"bits", OPT_BITS, 'p', "Size of number in bits"},
|
||||
{"checks", OPT_CHECKS, 'p', "Number of checks"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"hex", OPT_HEX, '-', "Hex output"},
|
||||
{"generate", OPT_GENERATE, '-', "Generate a prime"},
|
||||
{"bits", OPT_BITS, 'p', "Size of number in bits"},
|
||||
{"safe", OPT_SAFE, '-',
|
||||
"When used with -generate, generate a safe prime"},
|
||||
{"checks", OPT_CHECKS, 'p', "Number of checks"},
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"number", 0, 0, "Number(s) to check for primality if not generating"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
* WARNING: do not edit!
|
||||
* Generated by apps/progs.pl
|
||||
*
|
||||
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
* WARNING: do not edit!
|
||||
* Generated by apps/progs.pl
|
||||
*
|
||||
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
+9
-2
@@ -26,14 +26,20 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS provider_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] provider...\n"},
|
||||
{OPT_HELP_STR, 1, '-', " provider... Providers to load\n"},
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] [provider...]\n"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"v", OPT_V, '-', "List the algorithm names of specified provider"},
|
||||
{"vv", OPT_VV, '-', "List the algorithm names of specified providers,"},
|
||||
{OPT_MORE_STR, 0, '-', "categorised by operation type"},
|
||||
{"vvv", OPT_VVV, '-', "List the algorithm names of specified provider"},
|
||||
{OPT_MORE_STR, 0, '-', "one at a time, and list all known parameters"},
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"provider", 0, 0, "Provider(s) to load"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
@@ -264,6 +270,7 @@ int provider_main(int argc, char **argv)
|
||||
argc = opt_num_rest();
|
||||
argv = opt_rest();
|
||||
for ( ; *argv; argv++) {
|
||||
/* This isn't necessary since -- is supported. */
|
||||
if (**argv == '-') {
|
||||
BIO_printf(bio_err, "%s: Cannot mix flags and provider names.\n",
|
||||
prog);
|
||||
|
||||
+13
-6
@@ -25,16 +25,23 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS rand_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [flags] num\n"},
|
||||
{OPT_HELP_STR, 1, '-', "Valid options are:\n"},
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] num\n"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
OPT_R_OPTIONS,
|
||||
{"base64", OPT_BASE64, '-', "Base64 encode output"},
|
||||
{"hex", OPT_HEX, '-', "Hex encode output"},
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"base64", OPT_BASE64, '-', "Base64 encode output"},
|
||||
{"hex", OPT_HEX, '-', "Hex encode output"},
|
||||
|
||||
OPT_R_OPTIONS,
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"num", 0, 0, "Number of bytes to generate"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+8
-2
@@ -451,14 +451,20 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS rehash_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] [cert-directory...]\n"},
|
||||
{OPT_HELP_STR, 1, '-', "Valid options are:\n"},
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] [directory...]\n"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"h", OPT_HELP, '-', "Display this summary"},
|
||||
{"compat", OPT_COMPAT, '-', "Create both new- and old-style hash links"},
|
||||
{"old", OPT_OLD, '-', "Use old-style hash to generate links"},
|
||||
{"n", OPT_N, '-', "Do not remove existing links"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"v", OPT_VERBOSE, '-', "Verbose output"},
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"directory", 0, 0, "One or more directories to process (optional)"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+45
-32
@@ -95,37 +95,26 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS req_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"inform", OPT_INFORM, 'F', "Input format - DER or PEM"},
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format - DER or PEM"},
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
{"keygen_engine", OPT_KEYGEN_ENGINE, 's',
|
||||
"Specify engine to be used for key generation operations"},
|
||||
#endif
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"key", OPT_KEY, 's', "Private key to use"},
|
||||
{"keyform", OPT_KEYFORM, 'f', "Key file format"},
|
||||
{"pubkey", OPT_PUBKEY, '-', "Output public key"},
|
||||
{"inform", OPT_INFORM, 'F', "Input format - DER or PEM"},
|
||||
{"verify", OPT_VERIFY, '-', "Verify signature on REQ"},
|
||||
|
||||
OPT_SECTION("Certificate"),
|
||||
{"new", OPT_NEW, '-', "New request"},
|
||||
{"config", OPT_CONFIG, '<', "Request template file"},
|
||||
{"keyout", OPT_KEYOUT, '>', "File to send the key to"},
|
||||
{"passin", OPT_PASSIN, 's', "Private key password source"},
|
||||
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
|
||||
OPT_R_OPTIONS,
|
||||
{"newkey", OPT_NEWKEY, 's', "Specify as type:bits"},
|
||||
{"pkeyopt", OPT_PKEYOPT, 's', "Public key options as opt:value"},
|
||||
{"sigopt", OPT_SIGOPT, 's', "Signature parameter in n:v form"},
|
||||
{"batch", OPT_BATCH, '-',
|
||||
"Do not ask anything during request generation"},
|
||||
{"newhdr", OPT_NEWHDR, '-', "Output \"NEW\" in the header lines"},
|
||||
{"modulus", OPT_MODULUS, '-', "RSA modulus"},
|
||||
{"verify", OPT_VERIFY, '-', "Verify signature on REQ"},
|
||||
{"nodes", OPT_NODES, '-', "Don't encrypt the output key"},
|
||||
{"noout", OPT_NOOUT, '-', "Do not output REQ"},
|
||||
{"verbose", OPT_VERBOSE, '-', "Verbose output"},
|
||||
{"utf8", OPT_UTF8, '-', "Input characters are UTF8 (default ASCII)"},
|
||||
{"nameopt", OPT_NAMEOPT, 's', "Various certificate name options"},
|
||||
{"reqopt", OPT_REQOPT, 's', "Various request text options"},
|
||||
{"text", OPT_TEXT, '-', "Text form of request"},
|
||||
{"x509", OPT_X509, '-',
|
||||
"Output a x509 structure instead of a cert request"},
|
||||
"Output an x509 structure instead of a cert request"},
|
||||
{OPT_MORE_STR, 1, 1, "(Required by some CA's)"},
|
||||
{"subj", OPT_SUBJ, 's', "Set or modify request subject"},
|
||||
{"subject", OPT_SUBJECT, '-', "Output the request's subject"},
|
||||
@@ -140,18 +129,37 @@ const OPTIONS req_options[] = {
|
||||
{"reqexts", OPT_REQEXTS, 's',
|
||||
"Request extension section (override value in config file)"},
|
||||
{"precert", OPT_PRECERT, '-', "Add a poison extension (implies -new)"},
|
||||
|
||||
OPT_SECTION("Keys and Signing"),
|
||||
{"key", OPT_KEY, 's', "Private key to use"},
|
||||
{"keyform", OPT_KEYFORM, 'f', "Key file format"},
|
||||
{"pubkey", OPT_PUBKEY, '-', "Output public key"},
|
||||
{"keyout", OPT_KEYOUT, '>', "File to send the key to"},
|
||||
{"passin", OPT_PASSIN, 's', "Private key password source"},
|
||||
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
|
||||
{"newkey", OPT_NEWKEY, 's', "Specify as type:bits"},
|
||||
{"pkeyopt", OPT_PKEYOPT, 's', "Public key options as opt:value"},
|
||||
{"sigopt", OPT_SIGOPT, 's', "Signature parameter in n:v form"},
|
||||
{"", OPT_MD, '-', "Any supported digest"},
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
{"keygen_engine", OPT_KEYGEN_ENGINE, 's',
|
||||
"Specify engine to be used for key generation operations"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SM2
|
||||
{"sm2-id", OPT_SM2ID, 's',
|
||||
"Specify an ID string to verify an SM2 certificate request"},
|
||||
{"sm2-hex-id", OPT_SM2HEXID, 's',
|
||||
"Specify a hex ID string to verify an SM2 certificate request"},
|
||||
#endif
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format - DER or PEM"},
|
||||
{"batch", OPT_BATCH, '-',
|
||||
"Do not ask anything during request generation"},
|
||||
{"verbose", OPT_VERBOSE, '-', "Verbose output"},
|
||||
{"nodes", OPT_NODES, '-', "Don't encrypt the output key"},
|
||||
{"noout", OPT_NOOUT, '-', "Do not output REQ"},
|
||||
{"newhdr", OPT_NEWHDR, '-', "Output \"NEW\" in the header lines"},
|
||||
{"modulus", OPT_MODULUS, '-', "RSA modulus"},
|
||||
|
||||
OPT_R_OPTIONS,
|
||||
{NULL}
|
||||
};
|
||||
|
||||
@@ -206,9 +214,12 @@ static int duplicated(LHASH_OF(OPENSSL_STRING) *addexts, char *kv)
|
||||
*p = '\0';
|
||||
|
||||
/* Finally have a clean "key"; see if it's there [by attempt to add it]. */
|
||||
if ((p = (char *)lh_OPENSSL_STRING_insert(addexts, (OPENSSL_STRING*)kv))
|
||||
!= NULL || lh_OPENSSL_STRING_error(addexts)) {
|
||||
OPENSSL_free(p != NULL ? p : kv);
|
||||
p = (char *)lh_OPENSSL_STRING_insert(addexts, (OPENSSL_STRING*)kv);
|
||||
if (p != NULL) {
|
||||
OPENSSL_free(p);
|
||||
return 1;
|
||||
} else if (lh_OPENSSL_STRING_error(addexts)) {
|
||||
OPENSSL_free(kv);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -468,12 +479,14 @@ int req_main(int argc, char **argv)
|
||||
|
||||
if (verbose)
|
||||
BIO_printf(bio_err, "Using configuration from %s\n", template);
|
||||
req_conf = app_load_config(template);
|
||||
if ((req_conf = app_load_config(template)) == NULL)
|
||||
goto end;
|
||||
if (addext_bio) {
|
||||
if (verbose)
|
||||
BIO_printf(bio_err,
|
||||
"Using additional configuration from command line\n");
|
||||
addext_conf = app_load_config_bio(addext_bio, NULL);
|
||||
if ((addext_conf = app_load_config_bio(addext_bio, NULL)) == NULL)
|
||||
goto end;
|
||||
}
|
||||
if (template != default_config_file && !app_load_modules(req_conf))
|
||||
goto end;
|
||||
|
||||
+18
-11
@@ -37,29 +37,36 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS rsa_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"inform", OPT_INFORM, 'f', "Input format, one of DER PEM"},
|
||||
{"outform", OPT_OUTFORM, 'f', "Output format, one of DER PEM PVK"},
|
||||
{"check", OPT_CHECK, '-', "Verify key consistency"},
|
||||
{"", OPT_CIPHER, '-', "Any supported cipher"},
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
# endif
|
||||
|
||||
OPT_SECTION("Input"),
|
||||
{"in", OPT_IN, 's', "Input file"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"inform", OPT_INFORM, 'f', "Input format, one of DER PEM"},
|
||||
{"pubin", OPT_PUBIN, '-', "Expect a public key in input file"},
|
||||
{"pubout", OPT_PUBOUT, '-', "Output a public key"},
|
||||
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"RSAPublicKey_in", OPT_RSAPUBKEY_IN, '-', "Input is an RSAPublicKey"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"outform", OPT_OUTFORM, 'f', "Output format, one of DER PEM PVK"},
|
||||
{"pubout", OPT_PUBOUT, '-', "Output a public key"},
|
||||
{"RSAPublicKey_out", OPT_RSAPUBKEY_OUT, '-', "Output is an RSAPublicKey"},
|
||||
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
|
||||
{"noout", OPT_NOOUT, '-', "Don't print key out"},
|
||||
{"text", OPT_TEXT, '-', "Print the key in text"},
|
||||
{"modulus", OPT_MODULUS, '-', "Print the RSA key modulus"},
|
||||
{"check", OPT_CHECK, '-', "Verify key consistency"},
|
||||
{"", OPT_CIPHER, '-', "Any supported cipher"},
|
||||
|
||||
# if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4)
|
||||
OPT_SECTION("PVK"),
|
||||
{"pvk-strong", OPT_PVK_STRONG, '-', "Enable 'Strong' PVK encoding level (default)"},
|
||||
{"pvk-weak", OPT_PVK_WEAK, '-', "Enable 'Weak' PVK encoding level"},
|
||||
{"pvk-none", OPT_PVK_NONE, '-', "Don't enforce PVK encoding"},
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
# endif
|
||||
{NULL}
|
||||
};
|
||||
|
||||
+17
-11
@@ -38,31 +38,37 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS rsautl_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"sign", OPT_SIGN, '-', "Sign with private key"},
|
||||
{"verify", OPT_VERIFY, '-', "Verify with public key"},
|
||||
{"encrypt", OPT_ENCRYPT, '-', "Encrypt with public key"},
|
||||
{"decrypt", OPT_DECRYPT, '-', "Decrypt with private key"},
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
# endif
|
||||
|
||||
OPT_SECTION("Input"),
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"inkey", OPT_INKEY, 's', "Input key"},
|
||||
{"keyform", OPT_KEYFORM, 'E', "Private key format - default PEM"},
|
||||
{"pubin", OPT_PUBIN, '-', "Input is an RSA public"},
|
||||
{"certin", OPT_CERTIN, '-', "Input is a cert carrying an RSA public key"},
|
||||
{"rev", OPT_REV, '-', "Reverse the order of the input buffer"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"ssl", OPT_SSL, '-', "Use SSL v2 padding"},
|
||||
{"raw", OPT_RSA_RAW, '-', "Use no padding"},
|
||||
{"pkcs", OPT_PKCS, '-', "Use PKCS#1 v1.5 padding (default)"},
|
||||
{"x931", OPT_X931, '-', "Use ANSI X9.31 padding"},
|
||||
{"oaep", OPT_OAEP, '-', "Use PKCS#1 OAEP"},
|
||||
{"sign", OPT_SIGN, '-', "Sign with private key"},
|
||||
{"verify", OPT_VERIFY, '-', "Verify with public key"},
|
||||
{"asn1parse", OPT_ASN1PARSE, '-',
|
||||
"Run output through asn1parse; useful with -verify"},
|
||||
{"hexdump", OPT_HEXDUMP, '-', "Hex dump output"},
|
||||
{"x931", OPT_X931, '-', "Use ANSI X9.31 padding"},
|
||||
{"rev", OPT_REV, '-', "Reverse the order of the input buffer"},
|
||||
{"encrypt", OPT_ENCRYPT, '-', "Encrypt with public key"},
|
||||
{"decrypt", OPT_DECRYPT, '-', "Decrypt with private key"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
|
||||
OPT_R_OPTIONS,
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
# endif
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+131
-87
@@ -581,9 +581,11 @@ typedef enum OPTION_choice {
|
||||
OPT_SSL3, OPT_SSL_CONFIG,
|
||||
OPT_TLS1_3, OPT_TLS1_2, OPT_TLS1_1, OPT_TLS1, OPT_DTLS, OPT_DTLS1,
|
||||
OPT_DTLS1_2, OPT_SCTP, OPT_TIMEOUT, OPT_MTU, OPT_KEYFORM, OPT_PASS,
|
||||
OPT_CERT_CHAIN, OPT_CAPATH, OPT_NOCAPATH, OPT_CHAINCAPATH, OPT_VERIFYCAPATH,
|
||||
OPT_KEY, OPT_RECONNECT, OPT_BUILD_CHAIN, OPT_CAFILE, OPT_NOCAFILE,
|
||||
OPT_CHAINCAFILE, OPT_VERIFYCAFILE, OPT_NEXTPROTONEG, OPT_ALPN,
|
||||
OPT_CERT_CHAIN, OPT_KEY, OPT_RECONNECT, OPT_BUILD_CHAIN,
|
||||
OPT_NEXTPROTONEG, OPT_ALPN,
|
||||
OPT_CAPATH, OPT_NOCAPATH, OPT_CHAINCAPATH, OPT_VERIFYCAPATH,
|
||||
OPT_CAFILE, OPT_NOCAFILE, OPT_CHAINCAFILE, OPT_VERIFYCAFILE,
|
||||
OPT_CASTORE, OPT_NOCASTORE, OPT_CHAINCASTORE, OPT_VERIFYCASTORE,
|
||||
OPT_SERVERINFO, OPT_STARTTLS, OPT_SERVERNAME, OPT_NOSERVERNAME, OPT_ASYNC,
|
||||
OPT_USE_SRTP, OPT_KEYMATEXPORT, OPT_KEYMATEXPORTLEN, OPT_PROTOHOST,
|
||||
OPT_MAXFRAGLEN, OPT_MAX_SEND_FRAG, OPT_SPLIT_SEND_FRAG, OPT_MAX_PIPELINES,
|
||||
@@ -603,7 +605,23 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS s_client_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] [host:port]\n"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
{"ssl_client_engine", OPT_SSL_CLIENT_ENGINE, 's',
|
||||
"Specify engine to be used for client certificate operations"},
|
||||
#endif
|
||||
{"ssl_config", OPT_SSL_CONFIG, 's', "Use specified configuration file"},
|
||||
#ifndef OPENSSL_NO_CT
|
||||
{"ct", OPT_CT, '-', "Request and parse SCTs (also enables OCSP stapling)"},
|
||||
{"noct", OPT_NOCT, '-', "Do not request or parse SCTs (default)"},
|
||||
{"ctlogfile", OPT_CTLOG_FILE, '<', "CT log list CONF file"},
|
||||
#endif
|
||||
|
||||
OPT_SECTION("Network"),
|
||||
{"host", OPT_HOST, 's', "Use -connect instead"},
|
||||
{"port", OPT_PORT, 'p', "Use -connect instead"},
|
||||
{"connect", OPT_CONNECT, 's',
|
||||
@@ -620,6 +638,18 @@ const OPTIONS s_client_options[] = {
|
||||
#ifdef AF_INET6
|
||||
{"6", OPT_6, '-', "Use IPv6 only"},
|
||||
#endif
|
||||
{"maxfraglen", OPT_MAXFRAGLEN, 'p',
|
||||
"Enable Maximum Fragment Length Negotiation (len values: 512, 1024, 2048 and 4096)"},
|
||||
{"max_send_frag", OPT_MAX_SEND_FRAG, 'p', "Maximum Size of send frames "},
|
||||
{"split_send_frag", OPT_SPLIT_SEND_FRAG, 'p',
|
||||
"Size used to split data for encrypt pipelines"},
|
||||
{"max_pipelines", OPT_MAX_PIPELINES, 'p',
|
||||
"Maximum number of encrypt/decrypt pipelines to be used"},
|
||||
{"read_buf", OPT_READ_BUF, 'p',
|
||||
"Default read buffer size to be used for connections"},
|
||||
{"fallback_scsv", OPT_FALLBACKSCSV, '-', "Send the fallback SCSV"},
|
||||
|
||||
OPT_SECTION("Identity"),
|
||||
{"verify", OPT_VERIFY, 'p', "Turn on peer certificate verification"},
|
||||
{"cert", OPT_CERT, '<', "Certificate file to use, PEM format assumed"},
|
||||
{"certform", OPT_CERTFORM, 'F',
|
||||
@@ -630,10 +660,13 @@ const OPTIONS s_client_options[] = {
|
||||
{"pass", OPT_PASS, 's', "Private key file pass phrase source"},
|
||||
{"CApath", OPT_CAPATH, '/', "PEM format directory of CA's"},
|
||||
{"CAfile", OPT_CAFILE, '<', "PEM format file of CA's"},
|
||||
{"CAstore", OPT_CAFILE, ':', "URI to store of CA's"},
|
||||
{"no-CAfile", OPT_NOCAFILE, '-',
|
||||
"Do not load the default certificates file"},
|
||||
{"no-CApath", OPT_NOCAPATH, '-',
|
||||
"Do not load certificates from the default certificates directory"},
|
||||
{"no-CAstore", OPT_NOCAPATH, '-',
|
||||
"Do not load certificates from the default certificates store"},
|
||||
{"requestCAfile", OPT_REQCAFILE, '<',
|
||||
"PEM format file of CA names to send to the server"},
|
||||
{"dane_tlsa_domain", OPT_DANE_TLSA_DOMAIN, 's', "DANE TLSA base domain"},
|
||||
@@ -641,16 +674,19 @@ const OPTIONS s_client_options[] = {
|
||||
"DANE TLSA rrdata presentation form"},
|
||||
{"dane_ee_no_namechecks", OPT_DANE_EE_NO_NAME, '-',
|
||||
"Disable name checks when matching DANE-EE(3) TLSA records"},
|
||||
{"psk_identity", OPT_PSK_IDENTITY, 's', "PSK identity"},
|
||||
{"psk", OPT_PSK, 's', "PSK in hex (without 0x)"},
|
||||
{"psk_session", OPT_PSK_SESS, '<', "File to read PSK SSL session from"},
|
||||
{"name", OPT_PROTOHOST, 's',
|
||||
"Hostname to use for \"-starttls lmtp\", \"-starttls smtp\" or \"-starttls xmpp[-server]\""},
|
||||
|
||||
OPT_SECTION("Session"),
|
||||
{"reconnect", OPT_RECONNECT, '-',
|
||||
"Drop and re-make the connection with the same Session-ID"},
|
||||
{"showcerts", OPT_SHOWCERTS, '-',
|
||||
"Show all certificates sent by the server"},
|
||||
{"debug", OPT_DEBUG, '-', "Extra output"},
|
||||
{"msg", OPT_MSG, '-', "Show protocol messages"},
|
||||
{"msgfile", OPT_MSGFILE, '>',
|
||||
"File to send output of -msg or -trace, instead of stdout"},
|
||||
{"nbio_test", OPT_NBIO_TEST, '-', "More ssl protocol testing"},
|
||||
{"state", OPT_STATE, '-', "Print the ssl states"},
|
||||
{"sess_out", OPT_SESS_OUT, '>', "File to write SSL session to"},
|
||||
{"sess_in", OPT_SESS_IN, '<', "File to read SSL session from"},
|
||||
|
||||
OPT_SECTION("Input/Output"),
|
||||
{"crlf", OPT_CRLF, '-', "Convert LF from terminal into CRLF"},
|
||||
{"quiet", OPT_QUIET, '-', "No s_client output"},
|
||||
{"ign_eof", OPT_IGN_EOF, '-', "Ignore input eof (default when -quiet)"},
|
||||
@@ -659,47 +695,35 @@ const OPTIONS s_client_options[] = {
|
||||
"Use the appropriate STARTTLS command before starting TLS"},
|
||||
{"xmpphost", OPT_XMPPHOST, 's',
|
||||
"Alias of -name option for \"-starttls xmpp[-server]\""},
|
||||
OPT_R_OPTIONS,
|
||||
{"sess_out", OPT_SESS_OUT, '>', "File to write SSL session to"},
|
||||
{"sess_in", OPT_SESS_IN, '<', "File to read SSL session from"},
|
||||
#ifndef OPENSSL_NO_SRTP
|
||||
{"use_srtp", OPT_USE_SRTP, 's',
|
||||
"Offer SRTP key management with a colon-separated profile list"},
|
||||
#endif
|
||||
{"keymatexport", OPT_KEYMATEXPORT, 's',
|
||||
"Export keying material using label"},
|
||||
{"keymatexportlen", OPT_KEYMATEXPORTLEN, 'p',
|
||||
"Export len bytes of keying material (default 20)"},
|
||||
{"maxfraglen", OPT_MAXFRAGLEN, 'p',
|
||||
"Enable Maximum Fragment Length Negotiation (len values: 512, 1024, 2048 and 4096)"},
|
||||
{"fallback_scsv", OPT_FALLBACKSCSV, '-', "Send the fallback SCSV"},
|
||||
{"name", OPT_PROTOHOST, 's',
|
||||
"Hostname to use for \"-starttls lmtp\", \"-starttls smtp\" or \"-starttls xmpp[-server]\""},
|
||||
{"CRL", OPT_CRL, '<', "CRL file to use"},
|
||||
{"crl_download", OPT_CRL_DOWNLOAD, '-', "Download CRL from distribution points"},
|
||||
{"CRLform", OPT_CRLFORM, 'F', "CRL format (PEM or DER) PEM is default"},
|
||||
{"verify_return_error", OPT_VERIFY_RET_ERROR, '-',
|
||||
"Close connection on verification error"},
|
||||
{"verify_quiet", OPT_VERIFY_QUIET, '-', "Restrict verify output to errors"},
|
||||
{"brief", OPT_BRIEF, '-',
|
||||
"Restrict output to brief summary of connection parameters"},
|
||||
{"prexit", OPT_PREXIT, '-',
|
||||
"Print session information when the program exits"},
|
||||
|
||||
OPT_SECTION("Debug"),
|
||||
{"showcerts", OPT_SHOWCERTS, '-',
|
||||
"Show all certificates sent by the server"},
|
||||
{"debug", OPT_DEBUG, '-', "Extra output"},
|
||||
{"msg", OPT_MSG, '-', "Show protocol messages"},
|
||||
{"msgfile", OPT_MSGFILE, '>',
|
||||
"File to send output of -msg or -trace, instead of stdout"},
|
||||
{"nbio_test", OPT_NBIO_TEST, '-', "More ssl protocol testing"},
|
||||
{"state", OPT_STATE, '-', "Print the ssl states"},
|
||||
{"keymatexport", OPT_KEYMATEXPORT, 's',
|
||||
"Export keying material using label"},
|
||||
{"keymatexportlen", OPT_KEYMATEXPORTLEN, 'p',
|
||||
"Export len bytes of keying material (default 20)"},
|
||||
{"security_debug", OPT_SECURITY_DEBUG, '-',
|
||||
"Enable security debug messages"},
|
||||
{"security_debug_verbose", OPT_SECURITY_DEBUG_VERBOSE, '-',
|
||||
"Output more security debug output"},
|
||||
{"cert_chain", OPT_CERT_CHAIN, '<',
|
||||
"Certificate chain file (in PEM format)"},
|
||||
{"chainCApath", OPT_CHAINCAPATH, '/',
|
||||
"Use dir as certificate store path to build CA certificate chain"},
|
||||
{"verifyCApath", OPT_VERIFYCAPATH, '/',
|
||||
"Use dir as certificate store path to verify CA certificate"},
|
||||
{"build_chain", OPT_BUILD_CHAIN, '-', "Build certificate chain"},
|
||||
{"chainCAfile", OPT_CHAINCAFILE, '<',
|
||||
"CA file for certificate chain (PEM format)"},
|
||||
{"verifyCAfile", OPT_VERIFYCAFILE, '<',
|
||||
"CA file for certificate verification (PEM format)"},
|
||||
#ifndef OPENSSL_NO_SSL_TRACE
|
||||
{"trace", OPT_TRACE, '-', "Show trace output of protocol messages"},
|
||||
#endif
|
||||
#ifdef WATT32
|
||||
{"wdebug", OPT_WDEBUG, '-', "WATT-32 tcp debugging"},
|
||||
#endif
|
||||
{"keylogfile", OPT_KEYLOG_FILE, '>', "Write TLS secrets to file"},
|
||||
{"nocommands", OPT_NOCMDS, '-', "Do not use interactive command letters"},
|
||||
{"servername", OPT_SERVERNAME, 's',
|
||||
"Set TLS extension servername (SNI) in ClientHello (default)"},
|
||||
@@ -715,17 +739,9 @@ const OPTIONS s_client_options[] = {
|
||||
{"alpn", OPT_ALPN, 's',
|
||||
"Enable ALPN extension, considering named protocols supported (comma-separated list)"},
|
||||
{"async", OPT_ASYNC, '-', "Support asynchronous operation"},
|
||||
{"ssl_config", OPT_SSL_CONFIG, 's', "Use specified configuration file"},
|
||||
{"max_send_frag", OPT_MAX_SEND_FRAG, 'p', "Maximum Size of send frames "},
|
||||
{"split_send_frag", OPT_SPLIT_SEND_FRAG, 'p',
|
||||
"Size used to split data for encrypt pipelines"},
|
||||
{"max_pipelines", OPT_MAX_PIPELINES, 'p',
|
||||
"Maximum number of encrypt/decrypt pipelines to be used"},
|
||||
{"read_buf", OPT_READ_BUF, 'p',
|
||||
"Default read buffer size to be used for connections"},
|
||||
OPT_S_OPTIONS,
|
||||
OPT_V_OPTIONS,
|
||||
OPT_X_OPTIONS,
|
||||
{"nbio", OPT_NBIO, '-', "Use non-blocking IO"},
|
||||
|
||||
OPT_SECTION("Protocol and version"),
|
||||
#ifndef OPENSSL_NO_SSL3
|
||||
{"ssl3", OPT_SSL3, '-', "Just use SSLv3"},
|
||||
#endif
|
||||
@@ -757,16 +773,16 @@ const OPTIONS s_client_options[] = {
|
||||
{"sctp", OPT_SCTP, '-', "Use SCTP"},
|
||||
{"sctp_label_bug", OPT_SCTP_LABEL_BUG, '-', "Enable SCTP label length bug"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SSL_TRACE
|
||||
{"trace", OPT_TRACE, '-', "Show trace output of protocol messages"},
|
||||
#ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
{"nextprotoneg", OPT_NEXTPROTONEG, 's',
|
||||
"Enable NPN extension, considering named protocols supported (comma-separated list)"},
|
||||
#endif
|
||||
#ifdef WATT32
|
||||
{"wdebug", OPT_WDEBUG, '-', "WATT-32 tcp debugging"},
|
||||
{"early_data", OPT_EARLY_DATA, '<', "File to send as early data"},
|
||||
{"enable_pha", OPT_ENABLE_PHA, '-', "Enable post-handshake-authentication"},
|
||||
#ifndef OPENSSL_NO_SRTP
|
||||
{"use_srtp", OPT_USE_SRTP, 's',
|
||||
"Offer SRTP key management with a colon-separated profile list"},
|
||||
#endif
|
||||
{"nbio", OPT_NBIO, '-', "Use non-blocking IO"},
|
||||
{"psk_identity", OPT_PSK_IDENTITY, 's', "PSK identity"},
|
||||
{"psk", OPT_PSK, 's', "PSK in hex (without 0x)"},
|
||||
{"psk_session", OPT_PSK_SESS, '<', "File to read PSK SSL session from"},
|
||||
#ifndef OPENSSL_NO_SRP
|
||||
{"srpuser", OPT_SRPUSER, 's', "SRP authentication for 'user'"},
|
||||
{"srppass", OPT_SRPPASS, 's', "Password for 'user'"},
|
||||
@@ -776,24 +792,36 @@ const OPTIONS s_client_options[] = {
|
||||
"Tolerate other than the known g N values."},
|
||||
{"srp_strength", OPT_SRP_STRENGTH, 'p', "Minimal length in bits for N"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
{"nextprotoneg", OPT_NEXTPROTONEG, 's',
|
||||
"Enable NPN extension, considering named protocols supported (comma-separated list)"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
{"ssl_client_engine", OPT_SSL_CLIENT_ENGINE, 's',
|
||||
"Specify engine to be used for client certificate operations"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CT
|
||||
{"ct", OPT_CT, '-', "Request and parse SCTs (also enables OCSP stapling)"},
|
||||
{"noct", OPT_NOCT, '-', "Do not request or parse SCTs (default)"},
|
||||
{"ctlogfile", OPT_CTLOG_FILE, '<', "CT log list CONF file"},
|
||||
#endif
|
||||
{"keylogfile", OPT_KEYLOG_FILE, '>', "Write TLS secrets to file"},
|
||||
{"early_data", OPT_EARLY_DATA, '<', "File to send as early data"},
|
||||
{"enable_pha", OPT_ENABLE_PHA, '-', "Enable post-handshake-authentication"},
|
||||
{NULL, OPT_EOF, 0x00, NULL}
|
||||
|
||||
OPT_R_OPTIONS,
|
||||
OPT_S_OPTIONS,
|
||||
OPT_V_OPTIONS,
|
||||
{"CRL", OPT_CRL, '<', "CRL file to use"},
|
||||
{"crl_download", OPT_CRL_DOWNLOAD, '-', "Download CRL from distribution points"},
|
||||
{"CRLform", OPT_CRLFORM, 'F', "CRL format (PEM or DER) PEM is default"},
|
||||
{"verify_return_error", OPT_VERIFY_RET_ERROR, '-',
|
||||
"Close connection on verification error"},
|
||||
{"verify_quiet", OPT_VERIFY_QUIET, '-', "Restrict verify output to errors"},
|
||||
{"cert_chain", OPT_CERT_CHAIN, '<',
|
||||
"Certificate chain file (in PEM format)"},
|
||||
{"chainCApath", OPT_CHAINCAPATH, '/',
|
||||
"Use dir as certificate store path to build CA certificate chain"},
|
||||
{"chainCAstore", OPT_CHAINCASTORE, ':',
|
||||
"CA store URI for certificate chain"},
|
||||
{"verifyCAfile", OPT_VERIFYCAFILE, '<',
|
||||
"CA file for certificate verification (PEM format)"},
|
||||
{"verifyCApath", OPT_VERIFYCAPATH, '/',
|
||||
"Use dir as certificate store path to verify CA certificate"},
|
||||
{"verifyCAstore", OPT_VERIFYCASTORE, ':',
|
||||
"CA store URI for certificate verification"},
|
||||
{"build_chain", OPT_BUILD_CHAIN, '-', "Build certificate chain"},
|
||||
{"chainCAfile", OPT_CHAINCAFILE, '<',
|
||||
"CA file for certificate chain (PEM format)"},
|
||||
OPT_X_OPTIONS,
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"host:port", 0, 0, "Where to connect; same as -connect option"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
typedef enum PROTOCOL_choice {
|
||||
@@ -899,22 +927,23 @@ int s_client_main(int argc, char **argv)
|
||||
int dane_ee_no_name = 0;
|
||||
STACK_OF(X509_CRL) *crls = NULL;
|
||||
const SSL_METHOD *meth = TLS_client_method();
|
||||
const char *CApath = NULL, *CAfile = NULL;
|
||||
const char *CApath = NULL, *CAfile = NULL, *CAstore = NULL;
|
||||
char *cbuf = NULL, *sbuf = NULL, *mbuf = NULL;
|
||||
char *proxystr = NULL, *proxyuser = NULL;
|
||||
char *proxypassarg = NULL, *proxypass = NULL;
|
||||
char *connectstr = NULL, *bindstr = NULL;
|
||||
char *cert_file = NULL, *key_file = NULL, *chain_file = NULL;
|
||||
char *chCApath = NULL, *chCAfile = NULL, *host = NULL;
|
||||
char *chCApath = NULL, *chCAfile = NULL, *chCAstore = NULL, *host = NULL;
|
||||
char *port = OPENSSL_strdup(PORT);
|
||||
char *bindhost = NULL, *bindport = NULL;
|
||||
char *passarg = NULL, *pass = NULL, *vfyCApath = NULL, *vfyCAfile = NULL;
|
||||
char *passarg = NULL, *pass = NULL;
|
||||
char *vfyCApath = NULL, *vfyCAfile = NULL, *vfyCAstore = NULL;
|
||||
char *ReqCAfile = NULL;
|
||||
char *sess_in = NULL, *crl_file = NULL, *p;
|
||||
const char *protohost = NULL;
|
||||
struct timeval timeout, *timeoutp;
|
||||
fd_set readfds, writefds;
|
||||
int noCApath = 0, noCAfile = 0;
|
||||
int noCApath = 0, noCAfile = 0, noCAstore = 0;
|
||||
int build_chain = 0, cbuf_len, cbuf_off, cert_format = FORMAT_PEM;
|
||||
int key_format = FORMAT_PEM, crlf = 0, full_log = 1, mbuf_len = 0;
|
||||
int prexit = 0;
|
||||
@@ -1416,6 +1445,18 @@ int s_client_main(int argc, char **argv)
|
||||
case OPT_VERIFYCAFILE:
|
||||
vfyCAfile = opt_arg();
|
||||
break;
|
||||
case OPT_CASTORE:
|
||||
CAstore = opt_arg();
|
||||
break;
|
||||
case OPT_NOCASTORE:
|
||||
noCAstore = 1;
|
||||
break;
|
||||
case OPT_CHAINCASTORE:
|
||||
chCAstore = opt_arg();
|
||||
break;
|
||||
case OPT_VERIFYCASTORE:
|
||||
vfyCAstore = opt_arg();
|
||||
break;
|
||||
case OPT_DANE_TLSA_DOMAIN:
|
||||
dane_tlsa_domain = opt_arg();
|
||||
break;
|
||||
@@ -1796,7 +1837,9 @@ int s_client_main(int argc, char **argv)
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!ssl_load_stores(ctx, vfyCApath, vfyCAfile, chCApath, chCAfile,
|
||||
if (!ssl_load_stores(ctx,
|
||||
vfyCApath, vfyCAfile, vfyCAstore,
|
||||
chCApath, chCAfile, chCAstore,
|
||||
crls, crl_download)) {
|
||||
BIO_printf(bio_err, "Error loading store locations\n");
|
||||
ERR_print_errors(bio_err);
|
||||
@@ -1925,7 +1968,8 @@ int s_client_main(int argc, char **argv)
|
||||
|
||||
SSL_CTX_set_verify(ctx, verify, verify_callback);
|
||||
|
||||
if (!ctx_set_verify_locations(ctx, CAfile, CApath, noCAfile, noCApath)) {
|
||||
if (!ctx_set_verify_locations(ctx, CAfile, noCAfile, CApath, noCApath,
|
||||
CAstore, noCAstore)) {
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
|
||||
+134
-87
@@ -182,9 +182,6 @@ static unsigned int psk_server_cb(SSL *ssl, const char *identity,
|
||||
}
|
||||
#endif
|
||||
|
||||
#define TLS13_AES_128_GCM_SHA256_BYTES ((const unsigned char *)"\x13\x01")
|
||||
#define TLS13_AES_256_GCM_SHA384_BYTES ((const unsigned char *)"\x13\x02")
|
||||
|
||||
static int psk_find_session_cb(SSL *ssl, const unsigned char *identity,
|
||||
size_t identity_len, SSL_SESSION **sess)
|
||||
{
|
||||
@@ -738,7 +735,9 @@ typedef enum OPTION_choice {
|
||||
OPT_CAPATH, OPT_NOCAPATH, OPT_CHAINCAPATH, OPT_VERIFYCAPATH, OPT_NO_CACHE,
|
||||
OPT_EXT_CACHE, OPT_CRLFORM, OPT_VERIFY_RET_ERROR, OPT_VERIFY_QUIET,
|
||||
OPT_BUILD_CHAIN, OPT_CAFILE, OPT_NOCAFILE, OPT_CHAINCAFILE,
|
||||
OPT_VERIFYCAFILE, OPT_NBIO, OPT_NBIO_TEST, OPT_IGN_EOF, OPT_NO_IGN_EOF,
|
||||
OPT_VERIFYCAFILE,
|
||||
OPT_CASTORE, OPT_NOCASTORE, OPT_CHAINCASTORE, OPT_VERIFYCASTORE,
|
||||
OPT_NBIO, OPT_NBIO_TEST, OPT_IGN_EOF, OPT_NO_IGN_EOF,
|
||||
OPT_DEBUG, OPT_TLSEXTDEBUG, OPT_STATUS, OPT_STATUS_VERBOSE,
|
||||
OPT_STATUS_TIMEOUT, OPT_STATUS_URL, OPT_STATUS_FILE, OPT_MSG, OPT_MSGFILE,
|
||||
OPT_TRACE, OPT_SECURITY_DEBUG, OPT_SECURITY_DEBUG_VERBOSE, OPT_STATE,
|
||||
@@ -762,26 +761,50 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS s_server_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"ssl_config", OPT_SSL_CONFIG, 's',
|
||||
"Configure SSL_CTX using the configuration 'val'"},
|
||||
#ifndef OPENSSL_NO_SSL_TRACE
|
||||
{"trace", OPT_TRACE, '-', "trace protocol messages"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
|
||||
OPT_SECTION("Network"),
|
||||
{"port", OPT_PORT, 'p',
|
||||
"TCP/IP port to listen on for connections (default is " PORT ")"},
|
||||
{"accept", OPT_ACCEPT, 's',
|
||||
"TCP/IP optional host and port to listen on for connections (default is *:" PORT ")"},
|
||||
#ifdef AF_UNIX
|
||||
{"unix", OPT_UNIX, 's', "Unix domain socket to accept on"},
|
||||
{"unlink", OPT_UNLINK, '-', "For -unix, unlink existing socket first"},
|
||||
#endif
|
||||
{"4", OPT_4, '-', "Use IPv4 only"},
|
||||
{"6", OPT_6, '-', "Use IPv6 only"},
|
||||
#ifdef AF_UNIX
|
||||
{"unlink", OPT_UNLINK, '-', "For -unix, unlink existing socket first"},
|
||||
#endif
|
||||
|
||||
OPT_SECTION("Identity"),
|
||||
{"context", OPT_CONTEXT, 's', "Set session ID context"},
|
||||
{"CAfile", OPT_CAFILE, '<', "PEM format file of CA's"},
|
||||
{"CApath", OPT_CAPATH, '/', "PEM format directory of CA's"},
|
||||
{"CAstore", OPT_CASTORE, ':', "URI to store of CA's"},
|
||||
{"no-CAfile", OPT_NOCAFILE, '-',
|
||||
"Do not load the default certificates file"},
|
||||
{"no-CApath", OPT_NOCAPATH, '-',
|
||||
"Do not load certificates from the default certificates directory"},
|
||||
{"no-CAstore", OPT_NOCASTORE, '-',
|
||||
"Do not load certificates from the default certificates store URI"},
|
||||
{"nocert", OPT_NOCERT, '-', "Don't use any certificates (Anon-DH)"},
|
||||
{"verify", OPT_VERIFY, 'n', "Turn on peer certificate verification"},
|
||||
{"Verify", OPT_UPPER_V_VERIFY, 'n',
|
||||
"Turn on peer certificate verification, must have a cert"},
|
||||
{"cert", OPT_CERT, '<', "Certificate file to use; default is " TEST_CERT},
|
||||
{"cert2", OPT_CERT2, '<',
|
||||
"Certificate file to use for servername; default is" TEST_CERT2},
|
||||
{"key2", OPT_KEY2, '<',
|
||||
"-Private Key file to use for servername if not in -cert2"},
|
||||
{"nameopt", OPT_NAMEOPT, 's', "Various certificate name options"},
|
||||
{"naccept", OPT_NACCEPT, 'p', "Terminate after #num connections"},
|
||||
{"serverinfo", OPT_SERVERINFO, 's',
|
||||
"PEM serverinfo file for certificate"},
|
||||
{"certform", OPT_CERTFORM, 'F',
|
||||
@@ -801,39 +824,24 @@ const OPTIONS s_server_options[] = {
|
||||
{"dkeyform", OPT_DKEYFORM, 'F',
|
||||
"Second key format (PEM, DER or ENGINE) PEM default"},
|
||||
{"dpass", OPT_DPASS, 's', "Second private key file pass phrase source"},
|
||||
{"servername", OPT_SERVERNAME, 's',
|
||||
"Servername for HostName TLS extension"},
|
||||
{"servername_fatal", OPT_SERVERNAME_FATAL, '-',
|
||||
"mismatch send fatal alert (default warning alert)"},
|
||||
|
||||
{"nbio_test", OPT_NBIO_TEST, '-', "Test with the non-blocking test bio"},
|
||||
{"crlf", OPT_CRLF, '-', "Convert LF from terminal into CRLF"},
|
||||
{"debug", OPT_DEBUG, '-', "Print more output"},
|
||||
{"msg", OPT_MSG, '-', "Show protocol messages"},
|
||||
{"msgfile", OPT_MSGFILE, '>',
|
||||
"File to send output of -msg or -trace, instead of stdout"},
|
||||
{"state", OPT_STATE, '-', "Print the SSL states"},
|
||||
{"CAfile", OPT_CAFILE, '<', "PEM format file of CA's"},
|
||||
{"CApath", OPT_CAPATH, '/', "PEM format directory of CA's"},
|
||||
{"no-CAfile", OPT_NOCAFILE, '-',
|
||||
"Do not load the default certificates file"},
|
||||
{"no-CApath", OPT_NOCAPATH, '-',
|
||||
"Do not load certificates from the default certificates directory"},
|
||||
{"nocert", OPT_NOCERT, '-', "Don't use any certificates (Anon-DH)"},
|
||||
|
||||
{"quiet", OPT_QUIET, '-', "No server output"},
|
||||
{"no_resume_ephemeral", OPT_NO_RESUME_EPHEMERAL, '-',
|
||||
"Disable caching and tickets if ephemeral (EC)DH is used"},
|
||||
{"www", OPT_WWW, '-', "Respond to a 'GET /' with a status page"},
|
||||
{"WWW", OPT_UPPER_WWW, '-', "Respond to a 'GET with the file ./path"},
|
||||
{"servername", OPT_SERVERNAME, 's',
|
||||
"Servername for HostName TLS extension"},
|
||||
{"servername_fatal", OPT_SERVERNAME_FATAL, '-',
|
||||
"mismatch send fatal alert (default warning alert)"},
|
||||
{"cert2", OPT_CERT2, '<',
|
||||
"Certificate file to use for servername; default is" TEST_CERT2},
|
||||
{"key2", OPT_KEY2, '<',
|
||||
"-Private Key file to use for servername if not in -cert2"},
|
||||
{"tlsextdebug", OPT_TLSEXTDEBUG, '-',
|
||||
"Hex dump of all TLS extensions received"},
|
||||
{"HTTP", OPT_HTTP, '-', "Like -WWW but ./path includes HTTP headers"},
|
||||
{"id_prefix", OPT_ID_PREFIX, 's',
|
||||
"Generate SSL/TLS session IDs prefixed by arg"},
|
||||
OPT_R_OPTIONS,
|
||||
{"keymatexport", OPT_KEYMATEXPORT, 's',
|
||||
"Export keying material using label"},
|
||||
{"keymatexportlen", OPT_KEYMATEXPORTLEN, 'p',
|
||||
@@ -841,14 +849,14 @@ const OPTIONS s_server_options[] = {
|
||||
{"CRL", OPT_CRL, '<', "CRL file to use"},
|
||||
{"crl_download", OPT_CRL_DOWNLOAD, '-',
|
||||
"Download CRL from distribution points"},
|
||||
{"cert_chain", OPT_CERT_CHAIN, '<',
|
||||
"certificate chain file in PEM format"},
|
||||
{"dcert_chain", OPT_DCERT_CHAIN, '<',
|
||||
"second certificate chain file in PEM format"},
|
||||
{"chainCApath", OPT_CHAINCAPATH, '/',
|
||||
"use dir as certificate store path to build CA certificate chain"},
|
||||
{"chainCAstore", OPT_CHAINCASTORE, ':',
|
||||
"use URI as certificate store to build CA certificate chain"},
|
||||
{"verifyCApath", OPT_VERIFYCAPATH, '/',
|
||||
"use dir as certificate store path to verify CA certificate"},
|
||||
{"verifyCAstore", OPT_VERIFYCASTORE, ':',
|
||||
"use URI as certificate store to verify CA certificate"},
|
||||
{"no_cache", OPT_NO_CACHE, '-', "Disable session cache"},
|
||||
{"ext_cache", OPT_EXT_CACHE, '-',
|
||||
"Disable internal cache, setup and use external cache"},
|
||||
@@ -857,14 +865,13 @@ const OPTIONS s_server_options[] = {
|
||||
"Close connection on verification error"},
|
||||
{"verify_quiet", OPT_VERIFY_QUIET, '-',
|
||||
"No verify output except verify errors"},
|
||||
{"build_chain", OPT_BUILD_CHAIN, '-', "Build certificate chain"},
|
||||
{"chainCAfile", OPT_CHAINCAFILE, '<',
|
||||
"CA file for certificate chain (PEM format)"},
|
||||
{"verifyCAfile", OPT_VERIFYCAFILE, '<',
|
||||
"CA file for certificate verification (PEM format)"},
|
||||
{"ign_eof", OPT_IGN_EOF, '-', "ignore input eof (default when -quiet)"},
|
||||
{"no_ign_eof", OPT_NO_IGN_EOF, '-', "Do not ignore input eof"},
|
||||
|
||||
#ifndef OPENSSL_NO_OCSP
|
||||
OPT_SECTION("OCSP"),
|
||||
{"status", OPT_STATUS, '-', "Request certificate status from server"},
|
||||
{"status_verbose", OPT_STATUS_VERBOSE, '-',
|
||||
"Print more output in certificate status callback"},
|
||||
@@ -874,9 +881,8 @@ const OPTIONS s_server_options[] = {
|
||||
{"status_file", OPT_STATUS_FILE, '<',
|
||||
"File containing DER encoded OCSP Response"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SSL_TRACE
|
||||
{"trace", OPT_TRACE, '-', "trace protocol messages"},
|
||||
#endif
|
||||
|
||||
OPT_SECTION("Debug"),
|
||||
{"security_debug", OPT_SECURITY_DEBUG, '-',
|
||||
"Print output from SSL/TLS security framework"},
|
||||
{"security_debug_verbose", OPT_SECURITY_DEBUG_VERBOSE, '-',
|
||||
@@ -885,20 +891,28 @@ const OPTIONS s_server_options[] = {
|
||||
"Restrict output to brief summary of connection parameters"},
|
||||
{"rev", OPT_REV, '-',
|
||||
"act as a simple test server which just sends back with the received text reversed"},
|
||||
{"debug", OPT_DEBUG, '-', "Print more output"},
|
||||
{"msg", OPT_MSG, '-', "Show protocol messages"},
|
||||
{"msgfile", OPT_MSGFILE, '>',
|
||||
"File to send output of -msg or -trace, instead of stdout"},
|
||||
{"state", OPT_STATE, '-', "Print the SSL states"},
|
||||
{"async", OPT_ASYNC, '-', "Operate in asynchronous mode"},
|
||||
{"ssl_config", OPT_SSL_CONFIG, 's',
|
||||
"Configure SSL_CTX using the configuration 'val'"},
|
||||
{"max_send_frag", OPT_MAX_SEND_FRAG, 'p', "Maximum Size of send frames "},
|
||||
{"split_send_frag", OPT_SPLIT_SEND_FRAG, 'p',
|
||||
"Size used to split data for encrypt pipelines"},
|
||||
{"max_pipelines", OPT_MAX_PIPELINES, 'p',
|
||||
"Maximum number of encrypt/decrypt pipelines to be used"},
|
||||
{"naccept", OPT_NACCEPT, 'p', "Terminate after #num connections"},
|
||||
{"keylogfile", OPT_KEYLOG_FILE, '>', "Write TLS secrets to file"},
|
||||
|
||||
OPT_SECTION("Network"),
|
||||
{"nbio", OPT_NBIO, '-', "Use non-blocking IO"},
|
||||
{"timeout", OPT_TIMEOUT, '-', "Enable timeouts"},
|
||||
{"mtu", OPT_MTU, 'p', "Set link layer MTU"},
|
||||
{"read_buf", OPT_READ_BUF, 'p',
|
||||
"Default read buffer size to be used for connections"},
|
||||
OPT_S_OPTIONS,
|
||||
OPT_V_OPTIONS,
|
||||
OPT_X_OPTIONS,
|
||||
{"nbio", OPT_NBIO, '-', "Use non-blocking IO"},
|
||||
{"split_send_frag", OPT_SPLIT_SEND_FRAG, 'p',
|
||||
"Size used to split data for encrypt pipelines"},
|
||||
{"max_send_frag", OPT_MAX_SEND_FRAG, 'p', "Maximum Size of send frames "},
|
||||
|
||||
OPT_SECTION("Server identity"),
|
||||
{"psk_identity", OPT_PSK_IDENTITY, 's', "PSK identity to expect"},
|
||||
#ifndef OPENSSL_NO_PSK
|
||||
{"psk_hint", OPT_PSK_HINT, 's', "PSK identity hint to use"},
|
||||
@@ -910,6 +924,19 @@ const OPTIONS s_server_options[] = {
|
||||
{"srpuserseed", OPT_SRPUSERSEED, 's',
|
||||
"A seed string for a default user salt"},
|
||||
#endif
|
||||
|
||||
OPT_SECTION("Protocol and version"),
|
||||
{"max_early_data", OPT_MAX_EARLY, 'n',
|
||||
"The maximum number of bytes of early data as advertised in tickets"},
|
||||
{"recv_max_early_data", OPT_RECV_MAX_EARLY, 'n',
|
||||
"The maximum number of bytes of early data (hard limit)"},
|
||||
{"early_data", OPT_EARLY_DATA, '-', "Attempt to read early data"},
|
||||
{"num_tickets", OPT_S_NUM_TICKETS, 'n',
|
||||
"The number of TLSv1.3 session tickets that a server will automatically issue" },
|
||||
{"anti_replay", OPT_ANTI_REPLAY, '-', "Switch on anti-replay protection (default)"},
|
||||
{"no_anti_replay", OPT_NO_ANTI_REPLAY, '-', "Switch off anti-replay protection"},
|
||||
{"http_server_binmode", OPT_HTTP_SERVER_BINMODE, '-', "opening files in binary mode when acting as http server (-WWW and -HTTP)"},
|
||||
{"stateless", OPT_STATELESS, '-', "Require TLSv1.3 cookies"},
|
||||
#ifndef OPENSSL_NO_SSL3
|
||||
{"ssl3", OPT_SSL3, '-', "Just talk SSLv3"},
|
||||
#endif
|
||||
@@ -927,12 +954,9 @@ const OPTIONS s_server_options[] = {
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DTLS
|
||||
{"dtls", OPT_DTLS, '-', "Use any DTLS version"},
|
||||
{"timeout", OPT_TIMEOUT, '-', "Enable timeouts"},
|
||||
{"mtu", OPT_MTU, 'p', "Set link layer MTU"},
|
||||
{"listen", OPT_LISTEN, '-',
|
||||
"Listen for a DTLS ClientHello with a cookie and then connect"},
|
||||
#endif
|
||||
{"stateless", OPT_STATELESS, '-', "Require TLSv1.3 cookies"},
|
||||
#ifndef OPENSSL_NO_DTLS1
|
||||
{"dtls1", OPT_DTLS1, '-', "Just talk DTLSv1"},
|
||||
#endif
|
||||
@@ -943,34 +967,32 @@ const OPTIONS s_server_options[] = {
|
||||
{"sctp", OPT_SCTP, '-', "Use SCTP"},
|
||||
{"sctp_label_bug", OPT_SCTP_LABEL_BUG, '-', "Enable SCTP label length bug"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SRTP
|
||||
{"use_srtp", OPT_SRTP_PROFILES, 's',
|
||||
"Offer SRTP key management with a colon-separated profile list"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DH
|
||||
{"no_dhe", OPT_NO_DHE, '-', "Disable ephemeral DH"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
{"nextprotoneg", OPT_NEXTPROTONEG, 's',
|
||||
"Set the advertised protocols for the NPN extension (comma-separated list)"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SRTP
|
||||
{"use_srtp", OPT_SRTP_PROFILES, 's',
|
||||
"Offer SRTP key management with a colon-separated profile list"},
|
||||
#endif
|
||||
{"alpn", OPT_ALPN, 's',
|
||||
"Set the advertised protocols for the ALPN extension (comma-separated list)"},
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
{"keylogfile", OPT_KEYLOG_FILE, '>', "Write TLS secrets to file"},
|
||||
{"max_early_data", OPT_MAX_EARLY, 'n',
|
||||
"The maximum number of bytes of early data as advertised in tickets"},
|
||||
{"recv_max_early_data", OPT_RECV_MAX_EARLY, 'n',
|
||||
"The maximum number of bytes of early data (hard limit)"},
|
||||
{"early_data", OPT_EARLY_DATA, '-', "Attempt to read early data"},
|
||||
{"num_tickets", OPT_S_NUM_TICKETS, 'n',
|
||||
"The number of TLSv1.3 session tickets that a server will automatically issue" },
|
||||
{"anti_replay", OPT_ANTI_REPLAY, '-', "Switch on anti-replay protection (default)"},
|
||||
{"no_anti_replay", OPT_NO_ANTI_REPLAY, '-', "Switch off anti-replay protection"},
|
||||
{"http_server_binmode", OPT_HTTP_SERVER_BINMODE, '-', "opening files in binary mode when acting as http server (-WWW and -HTTP)"},
|
||||
{NULL, OPT_EOF, 0, NULL}
|
||||
|
||||
OPT_R_OPTIONS,
|
||||
OPT_S_OPTIONS,
|
||||
OPT_V_OPTIONS,
|
||||
{"cert_chain", OPT_CERT_CHAIN, '<',
|
||||
"certificate chain file in PEM format"},
|
||||
{"dcert_chain", OPT_DCERT_CHAIN, '<',
|
||||
"second certificate chain file in PEM format"},
|
||||
{"build_chain", OPT_BUILD_CHAIN, '-', "Build certificate chain"},
|
||||
{"chainCAfile", OPT_CHAINCAFILE, '<',
|
||||
"CA file for certificate chain (PEM format)"},
|
||||
OPT_X_OPTIONS,
|
||||
{NULL}
|
||||
};
|
||||
|
||||
#define IS_PROT_FLAG(o) \
|
||||
@@ -989,9 +1011,11 @@ int s_server_main(int argc, char *argv[])
|
||||
STACK_OF(X509_CRL) *crls = NULL;
|
||||
X509 *s_cert = NULL, *s_dcert = NULL;
|
||||
X509_VERIFY_PARAM *vpm = NULL;
|
||||
const char *CApath = NULL, *CAfile = NULL, *chCApath = NULL, *chCAfile = NULL;
|
||||
const char *CApath = NULL, *CAfile = NULL, *CAstore = NULL;
|
||||
const char *chCApath = NULL, *chCAfile = NULL, *chCAstore = NULL;
|
||||
char *dpassarg = NULL, *dpass = NULL;
|
||||
char *passarg = NULL, *pass = NULL, *vfyCApath = NULL, *vfyCAfile = NULL;
|
||||
char *passarg = NULL, *pass = NULL;
|
||||
char *vfyCApath = NULL, *vfyCAfile = NULL, *vfyCAstore = NULL;
|
||||
char *crl_file = NULL, *prog;
|
||||
#ifdef AF_UNIX
|
||||
int unlink_unix_path = 0;
|
||||
@@ -1003,14 +1027,14 @@ int s_server_main(int argc, char *argv[])
|
||||
int no_dhe = 0;
|
||||
#endif
|
||||
int nocert = 0, ret = 1;
|
||||
int noCApath = 0, noCAfile = 0;
|
||||
int noCApath = 0, noCAfile = 0, noCAstore = 0;
|
||||
int s_cert_format = FORMAT_PEM, s_key_format = FORMAT_PEM;
|
||||
int s_dcert_format = FORMAT_PEM, s_dkey_format = FORMAT_PEM;
|
||||
int rev = 0, naccept = -1, sdebug = 0;
|
||||
int socket_family = AF_UNSPEC, socket_type = SOCK_STREAM, protocol = 0;
|
||||
int state = 0, crl_format = FORMAT_PEM, crl_download = 0;
|
||||
char *host = NULL;
|
||||
char *port = BUF_strdup(PORT);
|
||||
char *port = OPENSSL_strdup(PORT);
|
||||
unsigned char *context = NULL;
|
||||
OPTION_CHOICE o;
|
||||
EVP_PKEY *s_key2 = NULL;
|
||||
@@ -1159,7 +1183,7 @@ int s_server_main(int argc, char *argv[])
|
||||
#ifdef AF_UNIX
|
||||
case OPT_UNIX:
|
||||
socket_family = AF_UNIX;
|
||||
OPENSSL_free(host); host = BUF_strdup(opt_arg());
|
||||
OPENSSL_free(host); host = OPENSSL_strdup(opt_arg());
|
||||
OPENSSL_free(port); port = NULL;
|
||||
break;
|
||||
case OPT_UNLINK:
|
||||
@@ -1261,6 +1285,18 @@ int s_server_main(int argc, char *argv[])
|
||||
case OPT_VERIFYCAPATH:
|
||||
vfyCApath = opt_arg();
|
||||
break;
|
||||
case OPT_CASTORE:
|
||||
CAstore = opt_arg();
|
||||
break;
|
||||
case OPT_NOCASTORE:
|
||||
noCAstore = 1;
|
||||
break;
|
||||
case OPT_CHAINCASTORE:
|
||||
chCAstore = opt_arg();
|
||||
break;
|
||||
case OPT_VERIFYCASTORE:
|
||||
vfyCAstore = opt_arg();
|
||||
break;
|
||||
case OPT_NO_CACHE:
|
||||
no_cache = 1;
|
||||
break;
|
||||
@@ -1883,7 +1919,8 @@ int s_server_main(int argc, char *argv[])
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!ctx_set_verify_locations(ctx, CAfile, CApath, noCAfile, noCApath)) {
|
||||
if (!ctx_set_verify_locations(ctx, CAfile, noCAfile, CApath, noCApath,
|
||||
CAstore, noCAstore)) {
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
@@ -1895,7 +1932,9 @@ int s_server_main(int argc, char *argv[])
|
||||
|
||||
ssl_ctx_add_crls(ctx, crls, 0);
|
||||
|
||||
if (!ssl_load_stores(ctx, vfyCApath, vfyCAfile, chCApath, chCAfile,
|
||||
if (!ssl_load_stores(ctx,
|
||||
vfyCApath, vfyCAfile, vfyCAstore,
|
||||
chCApath, chCAfile, chCAstore,
|
||||
crls, crl_download)) {
|
||||
BIO_printf(bio_err, "Error loading store locations\n");
|
||||
ERR_print_errors(bio_err);
|
||||
@@ -1944,8 +1983,8 @@ int s_server_main(int argc, char *argv[])
|
||||
if (async)
|
||||
SSL_CTX_set_mode(ctx2, SSL_MODE_ASYNC);
|
||||
|
||||
if (!ctx_set_verify_locations(ctx2, CAfile, CApath, noCAfile,
|
||||
noCApath)) {
|
||||
if (!ctx_set_verify_locations(ctx2, CAfile, noCAfile, CApath,
|
||||
noCApath, CAstore, noCAstore)) {
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
@@ -2555,8 +2594,8 @@ static int sv_body(int s, int stype, int prot, unsigned char *context)
|
||||
continue;
|
||||
}
|
||||
if (buf[0] == 'P') {
|
||||
static const char *str = "Lets print some clear text\n";
|
||||
BIO_write(SSL_get_wbio(con), str, strlen(str));
|
||||
static const char str[] = "Lets print some clear text\n";
|
||||
BIO_write(SSL_get_wbio(con), str, sizeof(str) -1);
|
||||
}
|
||||
if (buf[0] == 'S') {
|
||||
print_stats(bio_s_out, SSL_get_SSL_CTX(con));
|
||||
@@ -3214,6 +3253,12 @@ static int www_body(int s, int stype, int prot, unsigned char *context)
|
||||
if (e[0] == ' ')
|
||||
break;
|
||||
|
||||
if (e[0] == ':') {
|
||||
/* Windows drive. We treat this the same way as ".." */
|
||||
dot = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (dot) {
|
||||
case 1:
|
||||
dot = (e[0] == '.') ? 2 : 0;
|
||||
@@ -3222,11 +3267,11 @@ static int www_body(int s, int stype, int prot, unsigned char *context)
|
||||
dot = (e[0] == '.') ? 3 : 0;
|
||||
break;
|
||||
case 3:
|
||||
dot = (e[0] == '/') ? -1 : 0;
|
||||
dot = (e[0] == '/' || e[0] == '\\') ? -1 : 0;
|
||||
break;
|
||||
}
|
||||
if (dot == 0)
|
||||
dot = (e[0] == '/') ? 1 : 0;
|
||||
dot = (e[0] == '/' || e[0] == '\\') ? 1 : 0;
|
||||
}
|
||||
dot = (dot == 3) || (dot == -1); /* filename contains ".."
|
||||
* component */
|
||||
@@ -3240,11 +3285,11 @@ static int www_body(int s, int stype, int prot, unsigned char *context)
|
||||
|
||||
if (dot) {
|
||||
BIO_puts(io, text);
|
||||
BIO_printf(io, "'%s' contains '..' reference\r\n", p);
|
||||
BIO_printf(io, "'%s' contains '..' or ':'\r\n", p);
|
||||
break;
|
||||
}
|
||||
|
||||
if (*p == '/') {
|
||||
if (*p == '/' || *p == '\\') {
|
||||
BIO_puts(io, text);
|
||||
BIO_printf(io, "'%s' is an invalid path\r\n", p);
|
||||
break;
|
||||
@@ -3499,6 +3544,8 @@ static int generate_session_id(SSL *ssl, unsigned char *id,
|
||||
unsigned int *id_len)
|
||||
{
|
||||
unsigned int count = 0;
|
||||
unsigned int session_id_prefix_len = strlen(session_id_prefix);
|
||||
|
||||
do {
|
||||
if (RAND_bytes(id, *id_len) <= 0)
|
||||
return 0;
|
||||
@@ -3510,8 +3557,8 @@ static int generate_session_id(SSL *ssl, unsigned char *id,
|
||||
* conflicts.
|
||||
*/
|
||||
memcpy(id, session_id_prefix,
|
||||
(strlen(session_id_prefix) < *id_len) ?
|
||||
strlen(session_id_prefix) : *id_len);
|
||||
(session_id_prefix_len < *id_len) ?
|
||||
session_id_prefix_len : *id_len);
|
||||
}
|
||||
while (SSL_has_matching_session_id(ssl, id, *id_len) &&
|
||||
(++count < MAX_SESSION_ID_ATTEMPTS));
|
||||
|
||||
+39
-21
@@ -45,34 +45,25 @@ static const size_t fmt_http_get_cmd_size = sizeof(fmt_http_get_cmd) - 2;
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_CONNECT, OPT_CIPHER, OPT_CIPHERSUITES, OPT_CERT, OPT_NAMEOPT, OPT_KEY,
|
||||
OPT_CAPATH, OPT_CAFILE, OPT_NOCAPATH, OPT_NOCAFILE, OPT_NEW, OPT_REUSE,
|
||||
OPT_BUGS, OPT_VERIFY, OPT_TIME, OPT_SSL3,
|
||||
OPT_CAPATH, OPT_CAFILE, OPT_CASTORE,
|
||||
OPT_NOCAPATH, OPT_NOCAFILE, OPT_NOCASTORE,
|
||||
OPT_NEW, OPT_REUSE, OPT_BUGS, OPT_VERIFY, OPT_TIME, OPT_SSL3,
|
||||
OPT_WWW, OPT_TLS1, OPT_TLS1_1, OPT_TLS1_2, OPT_TLS1_3
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS s_time_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
|
||||
OPT_SECTION("Connection"),
|
||||
{"connect", OPT_CONNECT, 's',
|
||||
"Where to connect as post:port (default is " SSL_CONNECT_NAME ")"},
|
||||
{"cipher", OPT_CIPHER, 's', "TLSv1.2 and below cipher list to be used"},
|
||||
{"ciphersuites", OPT_CIPHERSUITES, 's',
|
||||
"Specify TLSv1.3 ciphersuites to be used"},
|
||||
{"cert", OPT_CERT, '<', "Cert file to use, PEM format assumed"},
|
||||
{"nameopt", OPT_NAMEOPT, 's', "Various certificate name options"},
|
||||
{"key", OPT_KEY, '<', "File with key, PEM; default is -cert file"},
|
||||
{"CApath", OPT_CAPATH, '/', "PEM format directory of CA's"},
|
||||
{"cafile", OPT_CAFILE, '<', "PEM format file of CA's"},
|
||||
{"no-CAfile", OPT_NOCAFILE, '-',
|
||||
"Do not load the default certificates file"},
|
||||
{"no-CApath", OPT_NOCAPATH, '-',
|
||||
"Do not load certificates from the default certificates directory"},
|
||||
{"new", OPT_NEW, '-', "Just time new connections"},
|
||||
{"reuse", OPT_REUSE, '-', "Just time connection reuse"},
|
||||
{"bugs", OPT_BUGS, '-', "Turn on SSL bug compatibility"},
|
||||
{"verify", OPT_VERIFY, 'p',
|
||||
"Turn on peer certificate verification, set depth"},
|
||||
{"time", OPT_TIME, 'p', "Seconds to collect data, default " SECONDSSTR},
|
||||
{"www", OPT_WWW, 's', "Fetch specified page from the site"},
|
||||
{"cipher", OPT_CIPHER, 's', "TLSv1.2 and below cipher list to be used"},
|
||||
{"ciphersuites", OPT_CIPHERSUITES, 's',
|
||||
"Specify TLSv1.3 ciphersuites to be used"},
|
||||
#ifndef OPENSSL_NO_SSL3
|
||||
{"ssl3", OPT_SSL3, '-', "Just use SSLv3"},
|
||||
#endif
|
||||
@@ -88,6 +79,25 @@ const OPTIONS s_time_options[] = {
|
||||
#ifndef OPENSSL_NO_TLS1_3
|
||||
{"tls1_3", OPT_TLS1_3, '-', "Just use TLSv1.3"},
|
||||
#endif
|
||||
{"verify", OPT_VERIFY, 'p',
|
||||
"Turn on peer certificate verification, set depth"},
|
||||
{"time", OPT_TIME, 'p', "Seconds to collect data, default " SECONDSSTR},
|
||||
{"www", OPT_WWW, 's', "Fetch specified page from the site"},
|
||||
|
||||
OPT_SECTION("Certificate"),
|
||||
{"nameopt", OPT_NAMEOPT, 's', "Various certificate name options"},
|
||||
{"cert", OPT_CERT, '<', "Cert file to use, PEM format assumed"},
|
||||
{"key", OPT_KEY, '<', "File with key, PEM; default is -cert file"},
|
||||
{"cafile", OPT_CAFILE, '<', "PEM format file of CA's"},
|
||||
{"CApath", OPT_CAPATH, '/', "PEM format directory of CA's"},
|
||||
{"CAstore", OPT_CASTORE, ':', "URI to store of CA's"},
|
||||
{"no-CAfile", OPT_NOCAFILE, '-',
|
||||
"Do not load the default certificates file"},
|
||||
{"no-CApath", OPT_NOCAPATH, '-',
|
||||
"Do not load certificates from the default certificates directory"},
|
||||
{"no-CAstore", OPT_NOCASTORE, '-',
|
||||
"Do not load certificates from the default certificates store URI"},
|
||||
|
||||
{NULL}
|
||||
};
|
||||
|
||||
@@ -105,11 +115,12 @@ int s_time_main(int argc, char **argv)
|
||||
SSL *scon = NULL;
|
||||
SSL_CTX *ctx = NULL;
|
||||
const SSL_METHOD *meth = NULL;
|
||||
char *CApath = NULL, *CAfile = NULL, *cipher = NULL, *ciphersuites = NULL;
|
||||
char *CApath = NULL, *CAfile = NULL, *CAstore = NULL;
|
||||
char *cipher = NULL, *ciphersuites = NULL;
|
||||
char *www_path = NULL;
|
||||
char *host = SSL_CONNECT_NAME, *certfile = NULL, *keyfile = NULL, *prog;
|
||||
double totalTime = 0.0;
|
||||
int noCApath = 0, noCAfile = 0;
|
||||
int noCApath = 0, noCAfile = 0, noCAstore = 0;
|
||||
int maxtime = SECONDS, nConn = 0, perform = 3, ret = 1, i, st_bugs = 0;
|
||||
long bytes_read = 0, finishtime = 0;
|
||||
OPTION_CHOICE o;
|
||||
@@ -167,6 +178,12 @@ int s_time_main(int argc, char **argv)
|
||||
case OPT_NOCAFILE:
|
||||
noCAfile = 1;
|
||||
break;
|
||||
case OPT_CASTORE:
|
||||
CAstore = opt_arg();
|
||||
break;
|
||||
case OPT_NOCASTORE:
|
||||
noCAstore = 1;
|
||||
break;
|
||||
case OPT_CIPHER:
|
||||
cipher = opt_arg();
|
||||
break;
|
||||
@@ -236,7 +253,8 @@ int s_time_main(int argc, char **argv)
|
||||
if (!set_cert_stuff(ctx, certfile, keyfile))
|
||||
goto end;
|
||||
|
||||
if (!ctx_set_verify_locations(ctx, CAfile, CApath, noCAfile, noCApath)) {
|
||||
if (!ctx_set_verify_locations(ctx, CAfile, noCAfile, CApath, noCApath,
|
||||
CAstore, noCAstore)) {
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
|
||||
+8
-3
@@ -25,16 +25,21 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS sess_id_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"context", OPT_CONTEXT, 's', "Set the session ID context"},
|
||||
|
||||
OPT_SECTION("Input"),
|
||||
{"in", OPT_IN, 's', "Input file - default stdin"},
|
||||
{"inform", OPT_INFORM, 'F', "Input format - default PEM (DER or PEM)"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"out", OPT_OUT, '>', "Output file - default stdout"},
|
||||
{"outform", OPT_OUTFORM, 'f',
|
||||
"Output format - default PEM (PEM, DER or NSS)"},
|
||||
{"in", OPT_IN, 's', "Input file - default stdin"},
|
||||
{"out", OPT_OUT, '>', "Output file - default stdout"},
|
||||
{"text", OPT_TEXT, '-', "Print ssl session id details"},
|
||||
{"cert", OPT_CERT, '-', "Output certificate "},
|
||||
{"noout", OPT_NOOUT, '-', "Don't output the encoded session info"},
|
||||
{"context", OPT_CONTEXT, 's', "Set the session ID context"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+64
-39
@@ -41,71 +41,89 @@ typedef enum OPTION_choice {
|
||||
OPT_CRLFEOL, OPT_ENGINE, OPT_PASSIN,
|
||||
OPT_TO, OPT_FROM, OPT_SUBJECT, OPT_SIGNER, OPT_RECIP, OPT_MD,
|
||||
OPT_CIPHER, OPT_INKEY, OPT_KEYFORM, OPT_CERTFILE, OPT_CAFILE,
|
||||
OPT_CAPATH, OPT_CASTORE, OPT_NOCAFILE, OPT_NOCAPATH, OPT_NOCASTORE,
|
||||
OPT_R_ENUM,
|
||||
OPT_V_ENUM,
|
||||
OPT_CAPATH, OPT_NOCAFILE, OPT_NOCAPATH, OPT_IN, OPT_INFORM, OPT_OUT,
|
||||
OPT_IN, OPT_INFORM, OPT_OUT,
|
||||
OPT_OUTFORM, OPT_CONTENT
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS smime_options[] = {
|
||||
{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"},
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] [cert...]\n"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"encrypt", OPT_ENCRYPT, '-', "Encrypt message"},
|
||||
{"decrypt", OPT_DECRYPT, '-', "Decrypt encrypted message"},
|
||||
{"sign", OPT_SIGN, '-', "Sign message"},
|
||||
{"verify", OPT_VERIFY, '-', "Verify signed message"},
|
||||
{"pk7out", OPT_PK7OUT, '-', "Output PKCS#7 structure"},
|
||||
{"nointern", OPT_NOINTERN, '-',
|
||||
"Don't search certificates in message for signer"},
|
||||
{"nosigs", OPT_NOSIGS, '-', "Don't verify message signature"},
|
||||
{"noverify", OPT_NOVERIFY, '-', "Don't verify signers certificate"},
|
||||
{"nocerts", OPT_NOCERTS, '-',
|
||||
"Don't include signers certificate when signing"},
|
||||
{"nodetach", OPT_NODETACH, '-', "Use opaque signing"},
|
||||
{"noattr", OPT_NOATTR, '-', "Don't include any signed attributes"},
|
||||
{"binary", OPT_BINARY, '-', "Don't translate message to text"},
|
||||
{"certfile", OPT_CERTFILE, '<', "Other certificates file"},
|
||||
{"signer", OPT_SIGNER, 's', "Signer certificate file"},
|
||||
{"recip", OPT_RECIP, '<', "Recipient certificate file for decryption"},
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
{"inform", OPT_INFORM, 'c', "Input format SMIME (default), PEM or DER"},
|
||||
{"inkey", OPT_INKEY, 's',
|
||||
"Input private key (if not signer or recipient)"},
|
||||
{"keyform", OPT_KEYFORM, 'f', "Input private key format (PEM or ENGINE)"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"outform", OPT_OUTFORM, 'c',
|
||||
"Output format SMIME (default), PEM or DER"},
|
||||
{"inkey", OPT_INKEY, 's',
|
||||
"Input private key (if not signer or recipient)"},
|
||||
{"keyform", OPT_KEYFORM, 'f', "Input private key format (PEM or ENGINE)"},
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
{"stream", OPT_STREAM, '-', "Enable CMS streaming" },
|
||||
{"indef", OPT_INDEF, '-', "Same as -stream" },
|
||||
{"noindef", OPT_NOINDEF, '-', "Disable CMS streaming"},
|
||||
|
||||
OPT_SECTION("Action"),
|
||||
{"encrypt", OPT_ENCRYPT, '-', "Encrypt message"},
|
||||
{"decrypt", OPT_DECRYPT, '-', "Decrypt encrypted message"},
|
||||
{"sign", OPT_SIGN, '-', "Sign message"},
|
||||
{"resign", OPT_RESIGN, '-', "Resign a signed message"},
|
||||
{"verify", OPT_VERIFY, '-', "Verify signed message"},
|
||||
|
||||
OPT_SECTION("Signing/Encryption"),
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"md", OPT_MD, 's', "Digest algorithm to use when signing or resigning"},
|
||||
{"", OPT_CIPHER, '-', "Any supported cipher"},
|
||||
{"pk7out", OPT_PK7OUT, '-', "Output PKCS#7 structure"},
|
||||
{"nointern", OPT_NOINTERN, '-',
|
||||
"Don't search certificates in message for signer"},
|
||||
{"nodetach", OPT_NODETACH, '-', "Use opaque signing"},
|
||||
{"noattr", OPT_NOATTR, '-', "Don't include any signed attributes"},
|
||||
{"binary", OPT_BINARY, '-', "Don't translate message to text"},
|
||||
{"signer", OPT_SIGNER, 's', "Signer certificate file"},
|
||||
{"content", OPT_CONTENT, '<',
|
||||
"Supply or override content for detached signature"},
|
||||
{"nocerts", OPT_NOCERTS, '-',
|
||||
"Don't include signers certificate when signing"},
|
||||
|
||||
OPT_SECTION("Verification/Decryption"),
|
||||
{"nosigs", OPT_NOSIGS, '-', "Don't verify message signature"},
|
||||
{"noverify", OPT_NOVERIFY, '-', "Don't verify signers certificate"},
|
||||
|
||||
{"certfile", OPT_CERTFILE, '<', "Other certificates file"},
|
||||
{"recip", OPT_RECIP, '<', "Recipient certificate file for decryption"},
|
||||
|
||||
OPT_SECTION("Email"),
|
||||
{"to", OPT_TO, 's', "To address"},
|
||||
{"from", OPT_FROM, 's', "From address"},
|
||||
{"subject", OPT_SUBJECT, 's', "Subject"},
|
||||
{"text", OPT_TEXT, '-', "Include or delete text MIME headers"},
|
||||
{"nosmimecap", OPT_NOSMIMECAP, '-', "Omit the SMIMECapabilities attribute"},
|
||||
|
||||
OPT_SECTION("Certificate chain"),
|
||||
{"CApath", OPT_CAPATH, '/', "Trusted certificates directory"},
|
||||
{"CAfile", OPT_CAFILE, '<', "Trusted certificates file"},
|
||||
{"CAstore", OPT_CASTORE, ':', "Trusted certificates store URI"},
|
||||
{"no-CAfile", OPT_NOCAFILE, '-',
|
||||
"Do not load the default certificates file"},
|
||||
{"no-CApath", OPT_NOCAPATH, '-',
|
||||
"Do not load certificates from the default certificates directory"},
|
||||
{"resign", OPT_RESIGN, '-', "Resign a signed message"},
|
||||
{"no-CAstore", OPT_NOCASTORE, '-',
|
||||
"Do not load certificates from the default certificates store"},
|
||||
{"nochain", OPT_NOCHAIN, '-',
|
||||
"set PKCS7_NOCHAIN so certificates contained in the message are not used as untrusted CAs" },
|
||||
{"nosmimecap", OPT_NOSMIMECAP, '-', "Omit the SMIMECapabilities attribute"},
|
||||
{"stream", OPT_STREAM, '-', "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"},
|
||||
|
||||
OPT_R_OPTIONS,
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"md", OPT_MD, 's', "Digest algorithm to use when signing or resigning"},
|
||||
{"", OPT_CIPHER, '-', "Any supported cipher"},
|
||||
OPT_V_OPTIONS,
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"cert", 0, 0, "Recipient certs, used when encrypting"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
@@ -121,12 +139,12 @@ int smime_main(int argc, char **argv)
|
||||
X509_VERIFY_PARAM *vpm = NULL;
|
||||
const EVP_CIPHER *cipher = NULL;
|
||||
const EVP_MD *sign_md = NULL;
|
||||
const char *CAfile = NULL, *CApath = NULL, *prog = NULL;
|
||||
const char *CAfile = NULL, *CApath = NULL, *CAstore = NULL, *prog = NULL;
|
||||
char *certfile = NULL, *keyfile = NULL, *contfile = NULL;
|
||||
char *infile = NULL, *outfile = NULL, *signerfile = NULL, *recipfile = NULL;
|
||||
char *passinarg = NULL, *passin = NULL, *to = NULL, *from = NULL, *subject = NULL;
|
||||
OPTION_CHOICE o;
|
||||
int noCApath = 0, noCAfile = 0;
|
||||
int noCApath = 0, noCAfile = 0, noCAstore = 0;
|
||||
int flags = PKCS7_DETACHED, operation = 0, ret = 0, indef = 0;
|
||||
int informat = FORMAT_SMIME, outformat = FORMAT_SMIME, keyform =
|
||||
FORMAT_PEM;
|
||||
@@ -302,12 +320,18 @@ int smime_main(int argc, char **argv)
|
||||
case OPT_CAPATH:
|
||||
CApath = opt_arg();
|
||||
break;
|
||||
case OPT_CASTORE:
|
||||
CAstore = opt_arg();
|
||||
break;
|
||||
case OPT_NOCAFILE:
|
||||
noCAfile = 1;
|
||||
break;
|
||||
case OPT_NOCAPATH:
|
||||
noCApath = 1;
|
||||
break;
|
||||
case OPT_NOCASTORE:
|
||||
noCAstore = 1;
|
||||
break;
|
||||
case OPT_CONTENT:
|
||||
contfile = opt_arg();
|
||||
break;
|
||||
@@ -473,7 +497,8 @@ int smime_main(int argc, char **argv)
|
||||
goto end;
|
||||
|
||||
if (operation == SMIME_VERIFY) {
|
||||
if ((store = setup_verify(CAfile, CApath, noCAfile, noCApath)) == NULL)
|
||||
if ((store = setup_verify(CAfile, noCAfile, CApath, noCApath,
|
||||
CAstore, noCAstore)) == NULL)
|
||||
goto end;
|
||||
X509_STORE_set_verify_cb(store, smime_cb);
|
||||
if (vpmtouched)
|
||||
|
||||
+459
-601
@@ -17,6 +17,9 @@
|
||||
#define EdDSA_SECONDS 10
|
||||
#define SM2_SECONDS 10
|
||||
|
||||
/* We need to use some deprecated APIs */
|
||||
#define OPENSSL_SUPPRESS_DEPRECATED
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -41,7 +44,9 @@
|
||||
#ifndef OPENSSL_NO_DES
|
||||
# include <openssl/des.h>
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||
#include <openssl/aes.h>
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
# include <openssl/camellia.h>
|
||||
#endif
|
||||
@@ -133,72 +138,9 @@ typedef struct openssl_speed_sec_st {
|
||||
|
||||
static volatile int run = 0;
|
||||
|
||||
static int mr = 0;
|
||||
static int mr = 0; /* machine-readeable output format to merge fork results */
|
||||
static int usertime = 1;
|
||||
|
||||
#ifndef OPENSSL_NO_MD2
|
||||
static int EVP_Digest_MD2_loop(void *args);
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_MDC2
|
||||
static int EVP_Digest_MDC2_loop(void *args);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_MD4
|
||||
static int EVP_Digest_MD4_loop(void *args);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_MD5
|
||||
static int MD5_loop(void *args);
|
||||
static int HMAC_loop(void *args);
|
||||
#endif
|
||||
static int SHA1_loop(void *args);
|
||||
static int SHA256_loop(void *args);
|
||||
static int SHA512_loop(void *args);
|
||||
#ifndef OPENSSL_NO_WHIRLPOOL
|
||||
static int WHIRLPOOL_loop(void *args);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RMD160
|
||||
static int EVP_Digest_RMD160_loop(void *args);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC4
|
||||
static int RC4_loop(void *args);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DES
|
||||
static int DES_ncbc_encrypt_loop(void *args);
|
||||
static int DES_ede3_cbc_encrypt_loop(void *args);
|
||||
#endif
|
||||
static int AES_cbc_128_encrypt_loop(void *args);
|
||||
static int AES_cbc_192_encrypt_loop(void *args);
|
||||
static int AES_cbc_256_encrypt_loop(void *args);
|
||||
#if !OPENSSL_API_3
|
||||
static int AES_ige_128_encrypt_loop(void *args);
|
||||
static int AES_ige_192_encrypt_loop(void *args);
|
||||
static int AES_ige_256_encrypt_loop(void *args);
|
||||
#endif
|
||||
static int CRYPTO_gcm128_aad_loop(void *args);
|
||||
static int RAND_bytes_loop(void *args);
|
||||
static int EVP_Update_loop(void *args);
|
||||
static int EVP_Update_loop_ccm(void *args);
|
||||
static int EVP_Update_loop_aead(void *args);
|
||||
static int EVP_Digest_loop(void *args);
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
static int RSA_sign_loop(void *args);
|
||||
static int RSA_verify_loop(void *args);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
static int DSA_sign_loop(void *args);
|
||||
static int DSA_verify_loop(void *args);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
static int ECDSA_sign_loop(void *args);
|
||||
static int ECDSA_verify_loop(void *args);
|
||||
static int EdDSA_sign_loop(void *args);
|
||||
static int EdDSA_verify_loop(void *args);
|
||||
# ifndef OPENSSL_NO_SM2
|
||||
static int SM2_sign_loop(void *args);
|
||||
static int SM2_verify_loop(void *args);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
static double Time_F(int s);
|
||||
static void print_message(const char *s, long num, int length, int tm);
|
||||
static void pkey_print_message(const char *str, const char *str2,
|
||||
@@ -211,6 +153,7 @@ static int do_multi(int multi, int size_num);
|
||||
static const int lengths_list[] = {
|
||||
16, 64, 256, 1024, 8 * 1024, 16 * 1024
|
||||
};
|
||||
#define SIZE_NUM OSSL_NELEM(lengths_list)
|
||||
static const int *lengths = lengths_list;
|
||||
|
||||
static const int aead_lengths_list[] = {
|
||||
@@ -292,8 +235,6 @@ static double Time_F(int s)
|
||||
static void multiblock_speed(const EVP_CIPHER *evp_cipher, int lengths_single,
|
||||
const openssl_speed_sec_t *seconds);
|
||||
|
||||
#define found(value, pairs, result)\
|
||||
opt_found(value, result, pairs, OSSL_NELEM(pairs))
|
||||
static int opt_found(const char *name, unsigned int *result,
|
||||
const OPT_PAIR pairs[], unsigned int nbelem)
|
||||
{
|
||||
@@ -306,6 +247,8 @@ static int opt_found(const char *name, unsigned int *result,
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#define opt_found(value, pairs, result)\
|
||||
opt_found(value, result, pairs, OSSL_NELEM(pairs))
|
||||
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
@@ -315,18 +258,10 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS speed_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] ciphers...\n"},
|
||||
{OPT_HELP_STR, 1, '-', "Valid options are:\n"},
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] [algorithm...]\n"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"evp", OPT_EVP, 's', "Use EVP-named cipher or digest"},
|
||||
{"hmac", OPT_HMAC, 's', "HMAC using EVP-named digest"},
|
||||
#ifndef OPENSSL_NO_CMAC
|
||||
{"cmac", OPT_CMAC, 's', "CMAC using EVP-named cipher"},
|
||||
#endif
|
||||
{"decrypt", OPT_DECRYPT, '-',
|
||||
"Time decryption instead of encryption (only EVP)"},
|
||||
{"aead", OPT_AEAD, '-',
|
||||
"Benchmark EVP-named AEAD cipher in TLS-like sequence"},
|
||||
{"mb", OPT_MB, '-',
|
||||
"Enable (tls1>=1) multi-block mode on EVP-named cipher"},
|
||||
{"mr", OPT_MR, '-', "Produce machine readable output"},
|
||||
@@ -337,58 +272,51 @@ const OPTIONS speed_options[] = {
|
||||
{"async_jobs", OPT_ASYNCJOBS, 'p',
|
||||
"Enable async mode and start specified number of jobs"},
|
||||
#endif
|
||||
OPT_R_OPTIONS,
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
{"primes", OPT_PRIMES, 'p', "Specify number of primes (for RSA only)"},
|
||||
|
||||
OPT_SECTION("Selection"),
|
||||
{"evp", OPT_EVP, 's', "Use EVP-named cipher or digest"},
|
||||
{"hmac", OPT_HMAC, 's', "HMAC using EVP-named digest"},
|
||||
#ifndef OPENSSL_NO_CMAC
|
||||
{"cmac", OPT_CMAC, 's', "CMAC using EVP-named cipher"},
|
||||
#endif
|
||||
{"decrypt", OPT_DECRYPT, '-',
|
||||
"Time decryption instead of encryption (only EVP)"},
|
||||
{"aead", OPT_AEAD, '-',
|
||||
"Benchmark EVP-named AEAD cipher in TLS-like sequence"},
|
||||
|
||||
OPT_SECTION("Timing"),
|
||||
{"elapsed", OPT_ELAPSED, '-',
|
||||
"Use wall-clock time instead of CPU user time as divisor"},
|
||||
{"primes", OPT_PRIMES, 'p', "Specify number of primes (for RSA only)"},
|
||||
{"seconds", OPT_SECONDS, 'p',
|
||||
"Run benchmarks for specified amount of seconds"},
|
||||
{"bytes", OPT_BYTES, 'p',
|
||||
"Run [non-PKI] benchmarks on custom-sized buffer"},
|
||||
{"misalign", OPT_MISALIGN, 'p',
|
||||
"Use specified offset to mis-align buffers"},
|
||||
|
||||
OPT_R_OPTIONS,
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"algorithm", 0, 0, "Algorithm(s) to test (optional; otherwise tests all)"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
#define D_MD2 0
|
||||
#define D_MDC2 1
|
||||
#define D_MD4 2
|
||||
#define D_MD5 3
|
||||
#define D_HMAC 4
|
||||
#define D_SHA1 5
|
||||
#define D_RMD160 6
|
||||
#define D_RC4 7
|
||||
#define D_CBC_DES 8
|
||||
#define D_EDE3_DES 9
|
||||
#define D_CBC_IDEA 10
|
||||
#define D_CBC_SEED 11
|
||||
#define D_CBC_RC2 12
|
||||
#define D_CBC_RC5 13
|
||||
#define D_CBC_BF 14
|
||||
#define D_CBC_CAST 15
|
||||
#define D_CBC_128_AES 16
|
||||
#define D_CBC_192_AES 17
|
||||
#define D_CBC_256_AES 18
|
||||
#define D_CBC_128_CML 19
|
||||
#define D_CBC_192_CML 20
|
||||
#define D_CBC_256_CML 21
|
||||
#define D_EVP 22
|
||||
#define D_SHA256 23
|
||||
#define D_SHA512 24
|
||||
#define D_WHIRLPOOL 25
|
||||
#define D_IGE_128_AES 26
|
||||
#define D_IGE_192_AES 27
|
||||
#define D_IGE_256_AES 28
|
||||
#define D_GHASH 29
|
||||
#define D_RAND 30
|
||||
#define D_EVP_HMAC 31
|
||||
#define D_EVP_CMAC 32
|
||||
|
||||
/* name of algorithms to test */
|
||||
static const char *names[] = {
|
||||
enum {
|
||||
D_MD2, D_MDC2, D_MD4, D_MD5 , D_HMAC, D_SHA1, D_RMD160, D_RC4,
|
||||
D_CBC_DES, D_EDE3_DES, D_CBC_IDEA, D_CBC_SEED,
|
||||
D_CBC_RC2, D_CBC_RC5, D_CBC_BF, D_CBC_CAST,
|
||||
D_CBC_128_AES, D_CBC_192_AES, D_CBC_256_AES,
|
||||
D_CBC_128_CML, D_CBC_192_CML, D_CBC_256_CML,
|
||||
D_EVP, D_SHA256, D_SHA512, D_WHIRLPOOL,
|
||||
D_IGE_128_AES, D_IGE_192_AES, D_IGE_256_AES,
|
||||
D_GHASH, D_RAND, D_EVP_HMAC, D_EVP_CMAC, ALGOR_NUM
|
||||
};
|
||||
/* name of algorithms to test. MUST BE KEEP IN SYNC with above enum ! */
|
||||
static const char *names[ALGOR_NUM] = {
|
||||
"md2", "mdc2", "md4", "md5", "hmac(md5)", "sha1", "rmd160", "rc4",
|
||||
"des cbc", "des ede3", "idea cbc", "seed cbc",
|
||||
"rc2 cbc", "rc5-32/12 cbc", "blowfish cbc", "cast cbc",
|
||||
@@ -398,17 +326,16 @@ static const char *names[] = {
|
||||
"aes-128 ige", "aes-192 ige", "aes-256 ige", "ghash",
|
||||
"rand", "hmac", "cmac"
|
||||
};
|
||||
#define ALGOR_NUM OSSL_NELEM(names)
|
||||
|
||||
/* list of configured algorithm (remaining) */
|
||||
/* list of configured algorithm (remaining), with some few alias */
|
||||
static const OPT_PAIR doit_choices[] = {
|
||||
#ifndef OPENSSL_NO_MD2
|
||||
#if !defined(OPENSSL_NO_MD2) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
{"md2", D_MD2},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_MDC2
|
||||
#if !defined(OPENSSL_NO_MDC2) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
{"mdc2", D_MDC2},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_MD4
|
||||
#if !defined(OPENSSL_NO_MD4) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
{"md4", D_MD4},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_MD5
|
||||
@@ -418,34 +345,34 @@ static const OPT_PAIR doit_choices[] = {
|
||||
{"sha1", D_SHA1},
|
||||
{"sha256", D_SHA256},
|
||||
{"sha512", D_SHA512},
|
||||
#ifndef OPENSSL_NO_WHIRLPOOL
|
||||
#if !defined(OPENSSL_NO_WHIRLPOOL) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
{"whirlpool", D_WHIRLPOOL},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RMD160
|
||||
#if !defined(OPENSSL_NO_RMD160) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
{"ripemd", D_RMD160},
|
||||
{"rmd160", D_RMD160},
|
||||
{"ripemd160", D_RMD160},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC4
|
||||
#if !defined(OPENSSL_NO_RC4) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
{"rc4", D_RC4},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DES
|
||||
{"des-cbc", D_CBC_DES},
|
||||
{"des-ede3", D_EDE3_DES},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||
{"aes-128-cbc", D_CBC_128_AES},
|
||||
{"aes-192-cbc", D_CBC_192_AES},
|
||||
{"aes-256-cbc", D_CBC_256_AES},
|
||||
#if !OPENSSL_API_3
|
||||
{"aes-128-ige", D_IGE_128_AES},
|
||||
{"aes-192-ige", D_IGE_192_AES},
|
||||
{"aes-256-ige", D_IGE_256_AES},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC2
|
||||
#if !defined(OPENSSL_NO_RC2) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
{"rc2-cbc", D_CBC_RC2},
|
||||
{"rc2", D_CBC_RC2},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC5
|
||||
#if !defined(OPENSSL_NO_RC5) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
{"rc5-cbc", D_CBC_RC5},
|
||||
{"rc5", D_CBC_RC5},
|
||||
#endif
|
||||
@@ -453,16 +380,16 @@ static const OPT_PAIR doit_choices[] = {
|
||||
{"idea-cbc", D_CBC_IDEA},
|
||||
{"idea", D_CBC_IDEA},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SEED
|
||||
#if !defined(OPENSSL_NO_SEED) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
{"seed-cbc", D_CBC_SEED},
|
||||
{"seed", D_CBC_SEED},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_BF
|
||||
#if !defined(OPENSSL_NO_BF) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
{"bf-cbc", D_CBC_BF},
|
||||
{"blowfish", D_CBC_BF},
|
||||
{"bf", D_CBC_BF},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAST
|
||||
#if !defined(OPENSSL_NO_CAST) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
{"cast-cbc", D_CBC_CAST},
|
||||
{"cast", D_CBC_CAST},
|
||||
{"cast5", D_CBC_CAST},
|
||||
@@ -471,31 +398,24 @@ static const OPT_PAIR doit_choices[] = {
|
||||
{"rand", D_RAND}
|
||||
};
|
||||
|
||||
static double results[ALGOR_NUM][OSSL_NELEM(lengths_list)];
|
||||
static double results[ALGOR_NUM][SIZE_NUM];
|
||||
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
# define R_DSA_512 0
|
||||
# define R_DSA_1024 1
|
||||
# define R_DSA_2048 2
|
||||
static const OPT_PAIR dsa_choices[] = {
|
||||
enum { R_DSA_512, R_DSA_1024, R_DSA_2048, DSA_NUM };
|
||||
static const OPT_PAIR dsa_choices[DSA_NUM] = {
|
||||
{"dsa512", R_DSA_512},
|
||||
{"dsa1024", R_DSA_1024},
|
||||
{"dsa2048", R_DSA_2048}
|
||||
};
|
||||
# define DSA_NUM OSSL_NELEM(dsa_choices)
|
||||
|
||||
static double dsa_results[DSA_NUM][2]; /* 2 ops: sign then verify */
|
||||
#endif /* OPENSSL_NO_DSA */
|
||||
|
||||
#define R_RSA_512 0
|
||||
#define R_RSA_1024 1
|
||||
#define R_RSA_2048 2
|
||||
#define R_RSA_3072 3
|
||||
#define R_RSA_4096 4
|
||||
#define R_RSA_7680 5
|
||||
#define R_RSA_15360 6
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
static const OPT_PAIR rsa_choices[] = {
|
||||
enum {
|
||||
R_RSA_512, R_RSA_1024, R_RSA_2048, R_RSA_3072, R_RSA_4096, R_RSA_7680,
|
||||
R_RSA_15360, RSA_NUM
|
||||
};
|
||||
static const OPT_PAIR rsa_choices[RSA_NUM] = {
|
||||
{"rsa512", R_RSA_512},
|
||||
{"rsa1024", R_RSA_1024},
|
||||
{"rsa2048", R_RSA_2048},
|
||||
@@ -504,42 +424,22 @@ static const OPT_PAIR rsa_choices[] = {
|
||||
{"rsa7680", R_RSA_7680},
|
||||
{"rsa15360", R_RSA_15360}
|
||||
};
|
||||
# define RSA_NUM OSSL_NELEM(rsa_choices)
|
||||
|
||||
static double rsa_results[RSA_NUM][2]; /* 2 ops: sign then verify */
|
||||
#endif /* OPENSSL_NO_RSA */
|
||||
|
||||
enum {
|
||||
R_EC_P160,
|
||||
R_EC_P192,
|
||||
R_EC_P224,
|
||||
R_EC_P256,
|
||||
R_EC_P384,
|
||||
R_EC_P521,
|
||||
#ifndef OPENSSL_NO_EC2M
|
||||
R_EC_K163,
|
||||
R_EC_K233,
|
||||
R_EC_K283,
|
||||
R_EC_K409,
|
||||
R_EC_K571,
|
||||
R_EC_B163,
|
||||
R_EC_B233,
|
||||
R_EC_B283,
|
||||
R_EC_B409,
|
||||
R_EC_B571,
|
||||
#endif
|
||||
R_EC_BRP256R1,
|
||||
R_EC_BRP256T1,
|
||||
R_EC_BRP384R1,
|
||||
R_EC_BRP384T1,
|
||||
R_EC_BRP512R1,
|
||||
R_EC_BRP512T1,
|
||||
R_EC_X25519,
|
||||
R_EC_X448
|
||||
};
|
||||
|
||||
#ifndef OPENSSL_NO_EC
|
||||
static OPT_PAIR ecdsa_choices[] = {
|
||||
enum ec_curves_t {
|
||||
R_EC_P160, R_EC_P192, R_EC_P224, R_EC_P256, R_EC_P384, R_EC_P521,
|
||||
# ifndef OPENSSL_NO_EC2M
|
||||
R_EC_K163, R_EC_K233, R_EC_K283, R_EC_K409, R_EC_K571,
|
||||
R_EC_B163, R_EC_B233, R_EC_B283, R_EC_B409, R_EC_B571,
|
||||
# endif
|
||||
R_EC_BRP256R1, R_EC_BRP256T1, R_EC_BRP384R1, R_EC_BRP384T1,
|
||||
R_EC_BRP512R1, R_EC_BRP512T1, ECDSA_NUM
|
||||
};
|
||||
/* list of ecdsa curves */
|
||||
static const OPT_PAIR ecdsa_choices[ECDSA_NUM] = {
|
||||
{"ecdsap160", R_EC_P160},
|
||||
{"ecdsap192", R_EC_P192},
|
||||
{"ecdsap224", R_EC_P224},
|
||||
@@ -565,11 +465,9 @@ static OPT_PAIR ecdsa_choices[] = {
|
||||
{"ecdsabrp512r1", R_EC_BRP512R1},
|
||||
{"ecdsabrp512t1", R_EC_BRP512T1}
|
||||
};
|
||||
# define ECDSA_NUM OSSL_NELEM(ecdsa_choices)
|
||||
|
||||
static double ecdsa_results[ECDSA_NUM][2]; /* 2 ops: sign then verify */
|
||||
|
||||
static const OPT_PAIR ecdh_choices[] = {
|
||||
enum { R_EC_X25519 = ECDSA_NUM, R_EC_X448, EC_NUM };
|
||||
/* list of ecdh curves, extension of |ecdsa_choices| list above */
|
||||
static const OPT_PAIR ecdh_choices[EC_NUM] = {
|
||||
{"ecdhp160", R_EC_P160},
|
||||
{"ecdhp192", R_EC_P192},
|
||||
{"ecdhp224", R_EC_P224},
|
||||
@@ -597,29 +495,25 @@ static const OPT_PAIR ecdh_choices[] = {
|
||||
{"ecdhx25519", R_EC_X25519},
|
||||
{"ecdhx448", R_EC_X448}
|
||||
};
|
||||
# define EC_NUM OSSL_NELEM(ecdh_choices)
|
||||
|
||||
static double ecdh_results[EC_NUM][1]; /* 1 op: derivation */
|
||||
static double ecdh_results[EC_NUM][1]; /* 1 op: derivation */
|
||||
static double ecdsa_results[ECDSA_NUM][2]; /* 2 ops: sign then verify */
|
||||
|
||||
#define R_EC_Ed25519 0
|
||||
#define R_EC_Ed448 1
|
||||
static OPT_PAIR eddsa_choices[] = {
|
||||
enum { R_EC_Ed25519, R_EC_Ed448, EdDSA_NUM };
|
||||
static const OPT_PAIR eddsa_choices[EdDSA_NUM] = {
|
||||
{"ed25519", R_EC_Ed25519},
|
||||
{"ed448", R_EC_Ed448}
|
||||
};
|
||||
# define EdDSA_NUM OSSL_NELEM(eddsa_choices)
|
||||
|
||||
};
|
||||
static double eddsa_results[EdDSA_NUM][2]; /* 2 ops: sign then verify */
|
||||
|
||||
# ifndef OPENSSL_NO_SM2
|
||||
# define R_EC_CURVESM2 0
|
||||
static OPT_PAIR sm2_choices[] = {
|
||||
enum { R_EC_CURVESM2, SM2_NUM };
|
||||
static const OPT_PAIR sm2_choices[SM2_NUM] = {
|
||||
{"curveSM2", R_EC_CURVESM2}
|
||||
};
|
||||
# define SM2_ID "TLSv1.3+GM+Cipher+Suite"
|
||||
# define SM2_ID_LEN sizeof("TLSv1.3+GM+Cipher+Suite") - 1
|
||||
# define SM2_NUM OSSL_NELEM(sm2_choices)
|
||||
|
||||
static double sm2_results[SM2_NUM][2]; /* 2 ops: sign then verify */
|
||||
# endif /* OPENSSL_NO_SM2 */
|
||||
#endif /* OPENSSL_NO_EC */
|
||||
@@ -674,9 +568,9 @@ static int run_benchmark(int async_jobs, int (*loop_function) (void *),
|
||||
static unsigned int testnum;
|
||||
|
||||
/* Nb of iterations to do per algorithm and key-size */
|
||||
static long c[ALGOR_NUM][OSSL_NELEM(lengths_list)];
|
||||
static long c[ALGOR_NUM][SIZE_NUM];
|
||||
|
||||
#ifndef OPENSSL_NO_MD2
|
||||
#if !defined(OPENSSL_NO_MD2) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
static int EVP_Digest_MD2_loop(void *args)
|
||||
{
|
||||
loopargs_t *tempargs = *(loopargs_t **) args;
|
||||
@@ -693,7 +587,7 @@ static int EVP_Digest_MD2_loop(void *args)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_MDC2
|
||||
#if !defined(OPENSSL_NO_MDC2) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
static int EVP_Digest_MDC2_loop(void *args)
|
||||
{
|
||||
loopargs_t *tempargs = *(loopargs_t **) args;
|
||||
@@ -710,7 +604,7 @@ static int EVP_Digest_MDC2_loop(void *args)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_MD4
|
||||
#if !defined(OPENSSL_NO_MD4) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
static int EVP_Digest_MD4_loop(void *args)
|
||||
{
|
||||
loopargs_t *tempargs = *(loopargs_t **) args;
|
||||
@@ -789,7 +683,7 @@ static int SHA512_loop(void *args)
|
||||
return count;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_WHIRLPOOL
|
||||
#if !defined(OPENSSL_NO_WHIRLPOOL) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
static int WHIRLPOOL_loop(void *args)
|
||||
{
|
||||
loopargs_t *tempargs = *(loopargs_t **) args;
|
||||
@@ -802,7 +696,7 @@ static int WHIRLPOOL_loop(void *args)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_RMD160
|
||||
#if !defined(OPENSSL_NO_RMD160) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
static int EVP_Digest_RMD160_loop(void *args)
|
||||
{
|
||||
loopargs_t *tempargs = *(loopargs_t **) args;
|
||||
@@ -818,7 +712,7 @@ static int EVP_Digest_RMD160_loop(void *args)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_RC4
|
||||
#if !defined(OPENSSL_NO_RC4) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
static RC4_KEY rc4_ks;
|
||||
static int RC4_loop(void *args)
|
||||
{
|
||||
@@ -833,16 +727,14 @@ static int RC4_loop(void *args)
|
||||
|
||||
#ifndef OPENSSL_NO_DES
|
||||
static unsigned char DES_iv[8];
|
||||
static DES_key_schedule sch;
|
||||
static DES_key_schedule sch2;
|
||||
static DES_key_schedule sch3;
|
||||
static DES_key_schedule sch[3];
|
||||
static int DES_ncbc_encrypt_loop(void *args)
|
||||
{
|
||||
loopargs_t *tempargs = *(loopargs_t **) args;
|
||||
unsigned char *buf = tempargs->buf;
|
||||
int count;
|
||||
for (count = 0; COND(c[D_CBC_DES][testnum]); count++)
|
||||
DES_ncbc_encrypt(buf, buf, lengths[testnum], &sch,
|
||||
DES_ncbc_encrypt(buf, buf, lengths[testnum], &sch[0],
|
||||
&DES_iv, DES_ENCRYPT);
|
||||
return count;
|
||||
}
|
||||
@@ -854,7 +746,7 @@ static int DES_ede3_cbc_encrypt_loop(void *args)
|
||||
int count;
|
||||
for (count = 0; COND(c[D_EDE3_DES][testnum]); count++)
|
||||
DES_ede3_cbc_encrypt(buf, buf, lengths[testnum],
|
||||
&sch, &sch2, &sch3, &DES_iv, DES_ENCRYPT);
|
||||
&sch[0], &sch[1], &sch[2], &DES_iv, DES_ENCRYPT);
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
@@ -862,6 +754,8 @@ static int DES_ede3_cbc_encrypt_loop(void *args)
|
||||
#define MAX_BLOCK_SIZE 128
|
||||
|
||||
static unsigned char iv[2 * MAX_BLOCK_SIZE / 8];
|
||||
|
||||
#ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||
static AES_KEY aes_ks1, aes_ks2, aes_ks3;
|
||||
static int AES_cbc_128_encrypt_loop(void *args)
|
||||
{
|
||||
@@ -896,7 +790,6 @@ static int AES_cbc_256_encrypt_loop(void *args)
|
||||
return count;
|
||||
}
|
||||
|
||||
#if !OPENSSL_API_3
|
||||
static int AES_ige_128_encrypt_loop(void *args)
|
||||
{
|
||||
loopargs_t *tempargs = *(loopargs_t **) args;
|
||||
@@ -932,7 +825,6 @@ static int AES_ige_256_encrypt_loop(void *args)
|
||||
(size_t)lengths[testnum], &aes_ks3, iv, AES_ENCRYPT);
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int CRYPTO_gcm128_aad_loop(void *args)
|
||||
{
|
||||
@@ -944,6 +836,7 @@ static int CRYPTO_gcm128_aad_loop(void *args)
|
||||
CRYPTO_gcm128_aad(gcm_ctx, buf, lengths[testnum]);
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int RAND_bytes_loop(void *args)
|
||||
{
|
||||
@@ -956,7 +849,6 @@ static int RAND_bytes_loop(void *args)
|
||||
return count;
|
||||
}
|
||||
|
||||
static long save_count = 0;
|
||||
static int decrypt = 0;
|
||||
static int EVP_Update_loop(void *args)
|
||||
{
|
||||
@@ -964,11 +856,9 @@ static int EVP_Update_loop(void *args)
|
||||
unsigned char *buf = tempargs->buf;
|
||||
EVP_CIPHER_CTX *ctx = tempargs->ctx;
|
||||
int outl, count, rc;
|
||||
#ifndef SIGALRM
|
||||
int nb_iter = save_count * 4 * lengths[0] / lengths[testnum];
|
||||
#endif
|
||||
|
||||
if (decrypt) {
|
||||
for (count = 0; COND(nb_iter); count++) {
|
||||
for (count = 0; COND(c[D_EVP][testnum]); count++) {
|
||||
rc = EVP_DecryptUpdate(ctx, buf, &outl, buf, lengths[testnum]);
|
||||
if (rc != 1) {
|
||||
/* reset iv in case of counter overflow */
|
||||
@@ -976,7 +866,7 @@ static int EVP_Update_loop(void *args)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (count = 0; COND(nb_iter); count++) {
|
||||
for (count = 0; COND(c[D_EVP][testnum]); count++) {
|
||||
rc = EVP_EncryptUpdate(ctx, buf, &outl, buf, lengths[testnum]);
|
||||
if (rc != 1) {
|
||||
/* reset iv in case of counter overflow */
|
||||
@@ -1003,11 +893,9 @@ static int EVP_Update_loop_ccm(void *args)
|
||||
EVP_CIPHER_CTX *ctx = tempargs->ctx;
|
||||
int outl, count;
|
||||
unsigned char tag[12];
|
||||
#ifndef SIGALRM
|
||||
int nb_iter = save_count * 4 * lengths[0] / lengths[testnum];
|
||||
#endif
|
||||
|
||||
if (decrypt) {
|
||||
for (count = 0; COND(nb_iter); count++) {
|
||||
for (count = 0; COND(c[D_EVP][testnum]); count++) {
|
||||
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, sizeof(tag), tag);
|
||||
/* reset iv */
|
||||
EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv);
|
||||
@@ -1015,7 +903,7 @@ static int EVP_Update_loop_ccm(void *args)
|
||||
EVP_DecryptUpdate(ctx, buf, &outl, buf, lengths[testnum]);
|
||||
}
|
||||
} else {
|
||||
for (count = 0; COND(nb_iter); count++) {
|
||||
for (count = 0; COND(c[D_EVP][testnum]); count++) {
|
||||
/* restore iv length field */
|
||||
EVP_EncryptUpdate(ctx, NULL, &outl, NULL, lengths[testnum]);
|
||||
/* counter is reset on every update */
|
||||
@@ -1042,11 +930,9 @@ static int EVP_Update_loop_aead(void *args)
|
||||
int outl, count;
|
||||
unsigned char aad[13] = { 0xcc };
|
||||
unsigned char faketag[16] = { 0xcc };
|
||||
#ifndef SIGALRM
|
||||
int nb_iter = save_count * 4 * lengths[0] / lengths[testnum];
|
||||
#endif
|
||||
|
||||
if (decrypt) {
|
||||
for (count = 0; COND(nb_iter); count++) {
|
||||
for (count = 0; COND(c[D_EVP][testnum]); count++) {
|
||||
EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv);
|
||||
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG,
|
||||
sizeof(faketag), faketag);
|
||||
@@ -1055,7 +941,7 @@ static int EVP_Update_loop_aead(void *args)
|
||||
EVP_DecryptFinal_ex(ctx, buf + outl, &outl);
|
||||
}
|
||||
} else {
|
||||
for (count = 0; COND(nb_iter); count++) {
|
||||
for (count = 0; COND(c[D_EVP][testnum]); count++) {
|
||||
EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv);
|
||||
EVP_EncryptUpdate(ctx, NULL, &outl, aad, sizeof(aad));
|
||||
EVP_EncryptUpdate(ctx, buf, &outl, buf, lengths[testnum]);
|
||||
@@ -1072,11 +958,8 @@ static int EVP_Digest_loop(void *args)
|
||||
unsigned char *buf = tempargs->buf;
|
||||
unsigned char md[EVP_MAX_MD_SIZE];
|
||||
int count;
|
||||
#ifndef SIGALRM
|
||||
int nb_iter = save_count * 4 * lengths[0] / lengths[testnum];
|
||||
#endif
|
||||
|
||||
for (count = 0; COND(nb_iter); count++) {
|
||||
for (count = 0; COND(c[D_EVP][testnum]); count++) {
|
||||
if (!EVP_Digest(buf, lengths[testnum], md, NULL, evp_md, NULL))
|
||||
return -1;
|
||||
}
|
||||
@@ -1091,11 +974,8 @@ static int EVP_HMAC_loop(void *args)
|
||||
unsigned char *buf = tempargs->buf;
|
||||
unsigned char no_key[32];
|
||||
int count;
|
||||
#ifndef SIGALRM
|
||||
int nb_iter = save_count * 4 * lengths[0] / lengths[testnum];
|
||||
#endif
|
||||
|
||||
for (count = 0; COND(nb_iter); count++) {
|
||||
for (count = 0; COND(c[D_EVP_HMAC][testnum]); count++) {
|
||||
if (HMAC(evp_hmac_md, no_key, sizeof(no_key), buf, lengths[testnum],
|
||||
NULL, NULL) == NULL)
|
||||
return -1;
|
||||
@@ -1116,11 +996,8 @@ static int EVP_CMAC_loop(void *args)
|
||||
unsigned char mac[16];
|
||||
size_t len = sizeof(mac);
|
||||
int count;
|
||||
#ifndef SIGALRM
|
||||
int nb_iter = save_count * 4 * lengths[0] / lengths[testnum];
|
||||
#endif
|
||||
|
||||
for (count = 0; COND(nb_iter); count++) {
|
||||
for (count = 0; COND(c[D_EVP_CMAC][testnum]); count++) {
|
||||
if (!CMAC_Init(cmac_ctx, key, sizeof(key), evp_cmac_cipher, NULL)
|
||||
|| !CMAC_Update(cmac_ctx, buf, lengths[testnum])
|
||||
|| !CMAC_Final(cmac_ctx, mac, &len))
|
||||
@@ -1399,8 +1276,6 @@ static int run_benchmark(int async_jobs,
|
||||
OSSL_ASYNC_FD job_fd = 0;
|
||||
size_t num_job_fds = 0;
|
||||
|
||||
run = 1;
|
||||
|
||||
if (async_jobs == 0) {
|
||||
return loop_function((void *)&loopargs);
|
||||
}
|
||||
@@ -1542,6 +1417,9 @@ static int run_benchmark(int async_jobs,
|
||||
return error ? -1 : total_op_count;
|
||||
}
|
||||
|
||||
#define stop_it(do_it, test_num)\
|
||||
memset(do_it + test_num, 0, OSSL_NELEM(do_it) - test_num);
|
||||
|
||||
int speed_main(int argc, char **argv)
|
||||
{
|
||||
ENGINE *e = NULL;
|
||||
@@ -1552,11 +1430,11 @@ int speed_main(int argc, char **argv)
|
||||
double d = 0.0;
|
||||
OPTION_CHOICE o;
|
||||
int async_init = 0, multiblock = 0, pr_header = 0;
|
||||
int doit[ALGOR_NUM] = { 0 };
|
||||
uint8_t doit[ALGOR_NUM] = { 0 };
|
||||
int ret = 1, misalign = 0, lengths_single = 0, aead = 0;
|
||||
long count = 0;
|
||||
unsigned int size_num = OSSL_NELEM(lengths_list);
|
||||
unsigned int i, k, loop, loopargs_len = 0, async_jobs = 0;
|
||||
unsigned int size_num = SIZE_NUM;
|
||||
unsigned int i, k, loopargs_len = 0, async_jobs = 0;
|
||||
int keylen;
|
||||
int buflen;
|
||||
#ifndef NO_FORK
|
||||
@@ -1571,28 +1449,29 @@ int speed_main(int argc, char **argv)
|
||||
EdDSA_SECONDS, SM2_SECONDS };
|
||||
|
||||
/* What follows are the buffers and key material. */
|
||||
#ifndef OPENSSL_NO_RC5
|
||||
#if !defined(OPENSSL_NO_RC5) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
RC5_32_KEY rc5_ks;
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC2
|
||||
#if !defined(OPENSSL_NO_RC2) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
RC2_KEY rc2_ks;
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_IDEA
|
||||
IDEA_KEY_SCHEDULE idea_ks;
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SEED
|
||||
#if !defined(OPENSSL_NO_SEED) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
SEED_KEY_SCHEDULE seed_ks;
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_BF
|
||||
#if !defined(OPENSSL_NO_BF) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
BF_KEY bf_ks;
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAST
|
||||
#if !defined(OPENSSL_NO_CAST) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
CAST_KEY cast_ks;
|
||||
#endif
|
||||
static const unsigned char key16[16] = {
|
||||
0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
|
||||
0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12
|
||||
};
|
||||
#ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||
static const unsigned char key24[24] = {
|
||||
0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
|
||||
0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,
|
||||
@@ -1604,62 +1483,45 @@ int speed_main(int argc, char **argv)
|
||||
0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34,
|
||||
0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, 0x56
|
||||
};
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
static const unsigned char ckey24[24] = {
|
||||
0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
|
||||
0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,
|
||||
0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34
|
||||
};
|
||||
static const unsigned char ckey32[32] = {
|
||||
0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
|
||||
0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,
|
||||
0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34,
|
||||
0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, 0x56
|
||||
};
|
||||
CAMELLIA_KEY camellia_ks1, camellia_ks2, camellia_ks3;
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DES
|
||||
static DES_cblock key = {
|
||||
0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0
|
||||
};
|
||||
static DES_cblock key2 = {
|
||||
0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12
|
||||
};
|
||||
static DES_cblock key3 = {
|
||||
0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34
|
||||
};
|
||||
#if !defined(OPENSSL_NO_CAMELLIA) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
CAMELLIA_KEY camellia_ks[3];
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
static const unsigned int rsa_bits[RSA_NUM] = {
|
||||
512, 1024, 2048, 3072, 4096, 7680, 15360
|
||||
static const struct {
|
||||
const unsigned char *data;
|
||||
unsigned int length;
|
||||
unsigned int bits;
|
||||
} rsa_keys[] = {
|
||||
{ test512, sizeof(test512), 512 },
|
||||
{ test1024, sizeof(test1024), 1024 },
|
||||
{ test2048, sizeof(test2048), 2048 },
|
||||
{ test3072, sizeof(test3072), 3072 },
|
||||
{ test4096, sizeof(test4096), 4092 },
|
||||
{ test7680, sizeof(test7680), 7680 },
|
||||
{ test15360, sizeof(test15360), 15360 }
|
||||
};
|
||||
static const unsigned char *rsa_data[RSA_NUM] = {
|
||||
test512, test1024, test2048, test3072, test4096, test7680, test15360
|
||||
};
|
||||
static const int rsa_data_length[RSA_NUM] = {
|
||||
sizeof(test512), sizeof(test1024),
|
||||
sizeof(test2048), sizeof(test3072),
|
||||
sizeof(test4096), sizeof(test7680),
|
||||
sizeof(test15360)
|
||||
};
|
||||
int rsa_doit[RSA_NUM] = { 0 };
|
||||
uint8_t rsa_doit[RSA_NUM] = { 0 };
|
||||
int primes = RSA_DEFAULT_PRIME_NUM;
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
static const unsigned int dsa_bits[DSA_NUM] = { 512, 1024, 2048 };
|
||||
int dsa_doit[DSA_NUM] = { 0 };
|
||||
uint8_t dsa_doit[DSA_NUM] = { 0 };
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
/*
|
||||
* We only test over the following curves as they are representative, To
|
||||
* add tests over more curves, simply add the curve NID and curve name to
|
||||
* the following arrays and increase the |ecdh_choices| list accordingly.
|
||||
*/
|
||||
static const struct {
|
||||
typedef struct ec_curve_st {
|
||||
const char *name;
|
||||
unsigned int nid;
|
||||
unsigned int bits;
|
||||
} test_curves[] = {
|
||||
size_t sigsize; /* only used for EdDSA curves */
|
||||
} EC_CURVE;
|
||||
/*
|
||||
* We only test over the following curves as they are representative, To
|
||||
* add tests over more curves, simply add the curve NID and curve name to
|
||||
* the following arrays and increase the |ecdh_choices| and |ecdsa_choices|
|
||||
* lists accordingly.
|
||||
*/
|
||||
static const EC_CURVE ec_curves[EC_NUM] = {
|
||||
/* Prime Curves */
|
||||
{"secp160r1", NID_secp160r1, 160},
|
||||
{"nistp192", NID_X9_62_prime192v1, 192},
|
||||
@@ -1690,33 +1552,36 @@ int speed_main(int argc, char **argv)
|
||||
{"X25519", NID_X25519, 253},
|
||||
{"X448", NID_X448, 448}
|
||||
};
|
||||
static const struct {
|
||||
const char *name;
|
||||
unsigned int nid;
|
||||
unsigned int bits;
|
||||
size_t sigsize;
|
||||
} test_ed_curves[] = {
|
||||
static const EC_CURVE ed_curves[EdDSA_NUM] = {
|
||||
/* EdDSA */
|
||||
{"Ed25519", NID_ED25519, 253, 64},
|
||||
{"Ed448", NID_ED448, 456, 114}
|
||||
};
|
||||
# ifndef OPENSSL_NO_SM2
|
||||
static const struct {
|
||||
const char *name;
|
||||
unsigned int nid;
|
||||
unsigned int bits;
|
||||
} test_sm2_curves[] = {
|
||||
static const EC_CURVE sm2_curves[SM2_NUM] = {
|
||||
/* SM2 */
|
||||
{"CurveSM2", NID_sm2, 256}
|
||||
};
|
||||
uint8_t sm2_doit[SM2_NUM] = { 0 };
|
||||
# endif
|
||||
uint8_t ecdsa_doit[ECDSA_NUM] = { 0 };
|
||||
uint8_t ecdh_doit[EC_NUM] = { 0 };
|
||||
uint8_t eddsa_doit[EdDSA_NUM] = { 0 };
|
||||
|
||||
/* checks declarated curves against choices list. */
|
||||
OPENSSL_assert(ed_curves[EdDSA_NUM - 1].nid == NID_ED448);
|
||||
OPENSSL_assert(strcmp(eddsa_choices[EdDSA_NUM - 1].name, "ed448") == 0);
|
||||
|
||||
OPENSSL_assert(ec_curves[EC_NUM - 1].nid == NID_X448);
|
||||
OPENSSL_assert(strcmp(ecdh_choices[EC_NUM - 1].name, "ecdhx448") == 0);
|
||||
|
||||
OPENSSL_assert(ec_curves[ECDSA_NUM - 1].nid == NID_brainpoolP512t1);
|
||||
OPENSSL_assert(strcmp(ecdsa_choices[ECDSA_NUM - 1].name, "ecdsabrp512t1") == 0);
|
||||
|
||||
# ifndef OPENSSL_NO_SM2
|
||||
OPENSSL_assert(sm2_curves[SM2_NUM - 1].nid == NID_sm2);
|
||||
OPENSSL_assert(strcmp(sm2_choices[SM2_NUM - 1].name, "curveSM2") == 0);
|
||||
# endif
|
||||
int ecdsa_doit[ECDSA_NUM] = { 0 };
|
||||
int ecdh_doit[EC_NUM] = { 0 };
|
||||
int eddsa_doit[EdDSA_NUM] = { 0 };
|
||||
int sm2_doit[SM2_NUM] = { 0 };
|
||||
OPENSSL_assert(OSSL_NELEM(test_curves) >= EC_NUM);
|
||||
OPENSSL_assert(OSSL_NELEM(test_ed_curves) >= EdDSA_NUM);
|
||||
OPENSSL_assert(OSSL_NELEM(test_sm2_curves) >= SM2_NUM);
|
||||
#endif /* ndef OPENSSL_NO_EC */
|
||||
|
||||
prog = opt_init(argc, argv, speed_options);
|
||||
@@ -1847,95 +1712,101 @@ int speed_main(int argc, char **argv)
|
||||
|
||||
/* Remaining arguments are algorithms. */
|
||||
for (; *argv; argv++) {
|
||||
if (found(*argv, doit_choices, &i)) {
|
||||
const char *algo = *argv;
|
||||
|
||||
if (opt_found(algo, doit_choices, &i)) {
|
||||
doit[i] = 1;
|
||||
continue;
|
||||
}
|
||||
#ifndef OPENSSL_NO_DES
|
||||
if (strcmp(*argv, "des") == 0) {
|
||||
if (strcmp(algo, "des") == 0) {
|
||||
doit[D_CBC_DES] = doit[D_EDE3_DES] = 1;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (strcmp(*argv, "sha") == 0) {
|
||||
if (strcmp(algo, "sha") == 0) {
|
||||
doit[D_SHA1] = doit[D_SHA256] = doit[D_SHA512] = 1;
|
||||
continue;
|
||||
}
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
if (strcmp(*argv, "openssl") == 0)
|
||||
continue;
|
||||
if (strcmp(*argv, "rsa") == 0) {
|
||||
for (loop = 0; loop < OSSL_NELEM(rsa_doit); loop++)
|
||||
rsa_doit[loop] = 1;
|
||||
continue;
|
||||
}
|
||||
if (found(*argv, rsa_choices, &i)) {
|
||||
rsa_doit[i] = 1;
|
||||
if (strcmp(algo, "openssl") == 0) /* just for compatibility */
|
||||
continue;
|
||||
if (strncmp(algo, "rsa", 3) == 0) {
|
||||
if (algo[3] == '\0') {
|
||||
memset(rsa_doit, 1, sizeof(rsa_doit));
|
||||
continue;
|
||||
}
|
||||
if (opt_found(algo, rsa_choices, &i)) {
|
||||
rsa_doit[i] = 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
if (strcmp(*argv, "dsa") == 0) {
|
||||
dsa_doit[R_DSA_512] = dsa_doit[R_DSA_1024] =
|
||||
dsa_doit[R_DSA_2048] = 1;
|
||||
continue;
|
||||
}
|
||||
if (found(*argv, dsa_choices, &i)) {
|
||||
dsa_doit[i] = 2;
|
||||
continue;
|
||||
if (strncmp(algo, "dsa", 3) == 0) {
|
||||
if (algo[3] == '\0') {
|
||||
memset(dsa_doit, 1, sizeof(dsa_doit));
|
||||
continue;
|
||||
}
|
||||
if (opt_found(algo, dsa_choices, &i)) {
|
||||
dsa_doit[i] = 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (strcmp(*argv, "aes") == 0) {
|
||||
#ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||
if (strcmp(algo, "aes") == 0) {
|
||||
doit[D_CBC_128_AES] = doit[D_CBC_192_AES] = doit[D_CBC_256_AES] = 1;
|
||||
continue;
|
||||
}
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
if (strcmp(*argv, "camellia") == 0) {
|
||||
#endif
|
||||
#if !defined(OPENSSL_NO_CAMELLIA) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
if (strcmp(algo, "camellia") == 0) {
|
||||
doit[D_CBC_128_CML] = doit[D_CBC_192_CML] = doit[D_CBC_256_CML] = 1;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
if (strcmp(*argv, "ecdsa") == 0) {
|
||||
for (loop = 0; loop < OSSL_NELEM(ecdsa_doit); loop++)
|
||||
ecdsa_doit[loop] = 1;
|
||||
if (strncmp(algo, "ecdsa", 5) == 0) {
|
||||
if (algo[5] == '\0') {
|
||||
memset(ecdsa_doit, 1, sizeof(ecdsa_doit));
|
||||
continue;
|
||||
}
|
||||
if (opt_found(algo, ecdsa_choices, &i)) {
|
||||
ecdsa_doit[i] = 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (strncmp(algo, "ecdh", 4) == 0) {
|
||||
if (algo[4] == '\0') {
|
||||
memset(ecdh_doit, 1, sizeof(ecdh_doit));
|
||||
continue;
|
||||
}
|
||||
if (opt_found(algo, ecdh_choices, &i)) {
|
||||
ecdh_doit[i] = 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (strcmp(algo, "eddsa") == 0) {
|
||||
memset(eddsa_doit, 1, sizeof(eddsa_doit));
|
||||
continue;
|
||||
}
|
||||
if (found(*argv, ecdsa_choices, &i)) {
|
||||
ecdsa_doit[i] = 2;
|
||||
continue;
|
||||
}
|
||||
if (strcmp(*argv, "ecdh") == 0) {
|
||||
for (loop = 0; loop < OSSL_NELEM(ecdh_doit); loop++)
|
||||
ecdh_doit[loop] = 1;
|
||||
continue;
|
||||
}
|
||||
if (found(*argv, ecdh_choices, &i)) {
|
||||
ecdh_doit[i] = 2;
|
||||
continue;
|
||||
}
|
||||
if (strcmp(*argv, "eddsa") == 0) {
|
||||
for (loop = 0; loop < OSSL_NELEM(eddsa_doit); loop++)
|
||||
eddsa_doit[loop] = 1;
|
||||
continue;
|
||||
}
|
||||
if (found(*argv, eddsa_choices, &i)) {
|
||||
if (opt_found(algo, eddsa_choices, &i)) {
|
||||
eddsa_doit[i] = 2;
|
||||
continue;
|
||||
}
|
||||
# ifndef OPENSSL_NO_SM2
|
||||
if (strcmp(*argv, "sm2") == 0) {
|
||||
for (loop = 0; loop < OSSL_NELEM(sm2_doit); loop++)
|
||||
sm2_doit[loop] = 1;
|
||||
if (strcmp(algo, "sm2") == 0) {
|
||||
memset(sm2_doit, 1, sizeof(sm2_doit));
|
||||
continue;
|
||||
}
|
||||
if (found(*argv, sm2_choices, &i)) {
|
||||
if (opt_found(algo, sm2_choices, &i)) {
|
||||
sm2_doit[i] = 2;
|
||||
continue;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
BIO_printf(bio_err, "%s: Unknown algorithm %s\n", prog, *argv);
|
||||
#endif /* OPENSSL_NO_EC */
|
||||
BIO_printf(bio_err, "%s: Unknown algorithm %s\n", prog, algo);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -2018,27 +1889,20 @@ int speed_main(int argc, char **argv)
|
||||
|
||||
/* No parameters; turn on everything. */
|
||||
if (argc == 0 && !doit[D_EVP] && !doit[D_EVP_HMAC] && !doit[D_EVP_CMAC]) {
|
||||
for (i = 0; i < ALGOR_NUM; i++)
|
||||
if (i != D_EVP && i != D_EVP_HMAC && i != D_EVP_CMAC)
|
||||
doit[i] = 1;
|
||||
memset(doit, 1, sizeof(doit));
|
||||
doit[D_EVP] = doit[D_EVP_HMAC] = doit[D_EVP_CMAC] = 0;
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
for (i = 0; i < RSA_NUM; i++)
|
||||
rsa_doit[i] = 1;
|
||||
memset(rsa_doit, 1, sizeof(rsa_doit));
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
for (i = 0; i < DSA_NUM; i++)
|
||||
dsa_doit[i] = 1;
|
||||
memset(dsa_doit, 1, sizeof(dsa_doit));
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
for (loop = 0; loop < OSSL_NELEM(ecdsa_doit); loop++)
|
||||
ecdsa_doit[loop] = 1;
|
||||
for (loop = 0; loop < OSSL_NELEM(ecdh_doit); loop++)
|
||||
ecdh_doit[loop] = 1;
|
||||
for (loop = 0; loop < OSSL_NELEM(eddsa_doit); loop++)
|
||||
eddsa_doit[loop] = 1;
|
||||
memset(ecdsa_doit, 1, sizeof(ecdsa_doit));
|
||||
memset(ecdh_doit, 1, sizeof(ecdh_doit));
|
||||
memset(eddsa_doit, 1, sizeof(eddsa_doit));
|
||||
# ifndef OPENSSL_NO_SM2
|
||||
for (loop = 0; loop < OSSL_NELEM(sm2_doit); loop++)
|
||||
sm2_doit[loop] = 1;
|
||||
memset(sm2_doit, 1, sizeof(sm2_doit));
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
@@ -2058,11 +1922,10 @@ int speed_main(int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
for (k = 0; k < RSA_NUM; k++) {
|
||||
const unsigned char *p;
|
||||
const unsigned char *p = rsa_keys[k].data;
|
||||
|
||||
p = rsa_data[k];
|
||||
loopargs[i].rsa_key[k] =
|
||||
d2i_RSAPrivateKey(NULL, &p, rsa_data_length[k]);
|
||||
d2i_RSAPrivateKey(NULL, &p, rsa_keys[k].length);
|
||||
if (loopargs[i].rsa_key[k] == NULL) {
|
||||
BIO_printf(bio_err,
|
||||
"internal error loading RSA key number %d\n", k);
|
||||
@@ -2079,41 +1942,59 @@ int speed_main(int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DES
|
||||
DES_set_key_unchecked(&key, &sch);
|
||||
DES_set_key_unchecked(&key2, &sch2);
|
||||
DES_set_key_unchecked(&key3, &sch3);
|
||||
if (doit[D_CBC_DES] || doit[D_EDE3_DES]) {
|
||||
static DES_cblock keys[] = {
|
||||
{ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 }, /* keys[0] */
|
||||
{ 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12 }, /* keys[1] */
|
||||
{ 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34 } /* keys[3] */
|
||||
};
|
||||
DES_set_key_unchecked(&keys[0], &sch[0]);
|
||||
DES_set_key_unchecked(&keys[1], &sch[1]);
|
||||
DES_set_key_unchecked(&keys[2], &sch[2]);
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||
AES_set_encrypt_key(key16, 128, &aes_ks1);
|
||||
AES_set_encrypt_key(key24, 192, &aes_ks2);
|
||||
AES_set_encrypt_key(key32, 256, &aes_ks3);
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
Camellia_set_key(key16, 128, &camellia_ks1);
|
||||
Camellia_set_key(ckey24, 192, &camellia_ks2);
|
||||
Camellia_set_key(ckey32, 256, &camellia_ks3);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_IDEA
|
||||
IDEA_set_encrypt_key(key16, &idea_ks);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SEED
|
||||
SEED_set_key(key16, &seed_ks);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC4
|
||||
RC4_set_key(&rc4_ks, 16, key16);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC2
|
||||
RC2_set_key(&rc2_ks, 16, key16, 128);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC5
|
||||
if (!RC5_32_set_key(&rc5_ks, 16, key16, 12)) {
|
||||
BIO_printf(bio_err, "Failed setting RC5 key\n");
|
||||
goto end;
|
||||
#if !defined(OPENSSL_NO_CAMELLIA) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
if (doit[D_CBC_128_CML] || doit[D_CBC_192_CML] || doit[D_CBC_256_CML]) {
|
||||
Camellia_set_key(key16, 128, &camellia_ks[0]);
|
||||
Camellia_set_key(key24, 192, &camellia_ks[1]);
|
||||
Camellia_set_key(key32, 256, &camellia_ks[2]);
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_BF
|
||||
BF_set_key(&bf_ks, 16, key16);
|
||||
#ifndef OPENSSL_NO_IDEA
|
||||
if (doit[D_CBC_IDEA])
|
||||
IDEA_set_encrypt_key(key16, &idea_ks);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAST
|
||||
CAST_set_key(&cast_ks, 16, key16);
|
||||
#if !defined(OPENSSL_NO_SEED) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
if (doit[D_CBC_SEED])
|
||||
SEED_set_key(key16, &seed_ks);
|
||||
#endif
|
||||
#if !defined(OPENSSL_NO_RC4) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
if (doit[D_RC4])
|
||||
RC4_set_key(&rc4_ks, 16, key16);
|
||||
#endif
|
||||
#if !defined(OPENSSL_NO_RC2) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
if (doit[D_CBC_RC2])
|
||||
RC2_set_key(&rc2_ks, 16, key16, 128);
|
||||
#endif
|
||||
#if !defined(OPENSSL_NO_RC5) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
if (doit[D_CBC_RC5])
|
||||
if (!RC5_32_set_key(&rc5_ks, 16, key16, 12)) {
|
||||
BIO_printf(bio_err, "Failed setting RC5 key\n");
|
||||
goto end;
|
||||
}
|
||||
#endif
|
||||
#if !defined(OPENSSL_NO_BF) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
if (doit[D_CBC_BF])
|
||||
BF_set_key(&bf_ks, 16, key16);
|
||||
#endif
|
||||
#if !defined(OPENSSL_NO_CAST) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
if (doit[D_CBC_CAST])
|
||||
CAST_set_key(&cast_ks, 16, key16);
|
||||
#endif
|
||||
#ifndef SIGALRM
|
||||
# ifndef OPENSSL_NO_DES
|
||||
@@ -2128,7 +2009,6 @@ int speed_main(int argc, char **argv)
|
||||
(DES_cblock *)loopargs[0].buf, &sch, DES_ENCRYPT);
|
||||
d = Time_F(STOP);
|
||||
} while (d < 3);
|
||||
save_count = count;
|
||||
c[D_MD2][0] = count / 10;
|
||||
c[D_MDC2][0] = count / 10;
|
||||
c[D_MD4][0] = count;
|
||||
@@ -2151,6 +2031,7 @@ int speed_main(int argc, char **argv)
|
||||
c[D_CBC_128_CML][0] = count;
|
||||
c[D_CBC_192_CML][0] = count;
|
||||
c[D_CBC_256_CML][0] = count;
|
||||
c[D_EVP][0] = count;
|
||||
c[D_SHA256][0] = count;
|
||||
c[D_SHA512][0] = count;
|
||||
c[D_WHIRLPOOL][0] = count;
|
||||
@@ -2159,12 +2040,12 @@ int speed_main(int argc, char **argv)
|
||||
c[D_IGE_256_AES][0] = count;
|
||||
c[D_GHASH][0] = count;
|
||||
c[D_RAND][0] = count;
|
||||
c[D_EVP_HMAC][0] = count;
|
||||
c[D_EVP_CMAC][0] = count;
|
||||
|
||||
for (i = 1; i < size_num; i++) {
|
||||
long l0, l1;
|
||||
|
||||
l0 = (long)lengths[0];
|
||||
l1 = (long)lengths[i];
|
||||
long l0 = (long)lengths[0];
|
||||
long l1 = (long)lengths[i];
|
||||
|
||||
c[D_MD2][i] = c[D_MD2][0] * 4 * l0 / l1;
|
||||
c[D_MDC2][i] = c[D_MDC2][0] * 4 * l0 / l1;
|
||||
@@ -2173,11 +2054,14 @@ int speed_main(int argc, char **argv)
|
||||
c[D_HMAC][i] = c[D_HMAC][0] * 4 * l0 / l1;
|
||||
c[D_SHA1][i] = c[D_SHA1][0] * 4 * l0 / l1;
|
||||
c[D_RMD160][i] = c[D_RMD160][0] * 4 * l0 / l1;
|
||||
c[D_EVP][i] = = c[D_EVP][0] * 4 * l0 / l1;
|
||||
c[D_SHA256][i] = c[D_SHA256][0] * 4 * l0 / l1;
|
||||
c[D_SHA512][i] = c[D_SHA512][0] * 4 * l0 / l1;
|
||||
c[D_WHIRLPOOL][i] = c[D_WHIRLPOOL][0] * 4 * l0 / l1;
|
||||
c[D_GHASH][i] = c[D_GHASH][0] * 4 * l0 / l1;
|
||||
c[D_RAND][i] = c[D_RAND][0] * 4 * l0 / l1;
|
||||
c[D_EVP_HMAC][i] = = c[D_EVP_HMAC][0] * 4 * l0 / l1;
|
||||
c[D_EVP_CMAC][i] = = c[D_EVP_CMAC][0] * 4 * l0 / l1;
|
||||
|
||||
l0 = (long)lengths[i - 1];
|
||||
|
||||
@@ -2349,7 +2233,7 @@ int speed_main(int argc, char **argv)
|
||||
# ifndef OPENSSL_NO_SM2
|
||||
sm2_c[R_EC_SM2P256][0] = count / 1800;
|
||||
# endif
|
||||
# endif
|
||||
# endif /* OPENSSL_NO_EC */
|
||||
|
||||
# else
|
||||
/* not worth fixing */
|
||||
@@ -2359,7 +2243,7 @@ int speed_main(int argc, char **argv)
|
||||
signal(SIGALRM, alarmed);
|
||||
#endif /* SIGALRM */
|
||||
|
||||
#ifndef OPENSSL_NO_MD2
|
||||
#if !defined(OPENSSL_NO_MD2) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
if (doit[D_MD2]) {
|
||||
for (testnum = 0; testnum < size_num; testnum++) {
|
||||
print_message(names[D_MD2], c[D_MD2][testnum], lengths[testnum],
|
||||
@@ -2371,7 +2255,7 @@ int speed_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_MDC2
|
||||
#if !defined(OPENSSL_NO_MDC2) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
if (doit[D_MDC2]) {
|
||||
for (testnum = 0; testnum < size_num; testnum++) {
|
||||
print_message(names[D_MDC2], c[D_MDC2][testnum], lengths[testnum],
|
||||
@@ -2380,11 +2264,13 @@ int speed_main(int argc, char **argv)
|
||||
count = run_benchmark(async_jobs, EVP_Digest_MDC2_loop, loopargs);
|
||||
d = Time_F(STOP);
|
||||
print_result(D_MDC2, testnum, count, d);
|
||||
if (count < 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_MD4
|
||||
#if !defined(OPENSSL_NO_MD4) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
if (doit[D_MD4]) {
|
||||
for (testnum = 0; testnum < size_num; testnum++) {
|
||||
print_message(names[D_MD4], c[D_MD4][testnum], lengths[testnum],
|
||||
@@ -2393,6 +2279,8 @@ int speed_main(int argc, char **argv)
|
||||
count = run_benchmark(async_jobs, EVP_Digest_MD4_loop, loopargs);
|
||||
d = Time_F(STOP);
|
||||
print_result(D_MD4, testnum, count, d);
|
||||
if (count < 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -2430,9 +2318,8 @@ int speed_main(int argc, char **argv)
|
||||
d = Time_F(STOP);
|
||||
print_result(D_HMAC, testnum, count, d);
|
||||
}
|
||||
for (i = 0; i < loopargs_len; i++) {
|
||||
for (i = 0; i < loopargs_len; i++)
|
||||
HMAC_CTX_free(loopargs[i].hctx);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (doit[D_SHA1]) {
|
||||
@@ -2465,7 +2352,7 @@ int speed_main(int argc, char **argv)
|
||||
print_result(D_SHA512, testnum, count, d);
|
||||
}
|
||||
}
|
||||
#ifndef OPENSSL_NO_WHIRLPOOL
|
||||
#if !defined(OPENSSL_NO_WHIRLPOOL) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
if (doit[D_WHIRLPOOL]) {
|
||||
for (testnum = 0; testnum < size_num; testnum++) {
|
||||
print_message(names[D_WHIRLPOOL], c[D_WHIRLPOOL][testnum],
|
||||
@@ -2478,7 +2365,7 @@ int speed_main(int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_RMD160
|
||||
#if !defined(OPENSSL_NO_RMD160) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
if (doit[D_RMD160]) {
|
||||
for (testnum = 0; testnum < size_num; testnum++) {
|
||||
print_message(names[D_RMD160], c[D_RMD160][testnum],
|
||||
@@ -2487,10 +2374,12 @@ int speed_main(int argc, char **argv)
|
||||
count = run_benchmark(async_jobs, EVP_Digest_RMD160_loop, loopargs);
|
||||
d = Time_F(STOP);
|
||||
print_result(D_RMD160, testnum, count, d);
|
||||
if (count < 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC4
|
||||
#if !defined(OPENSSL_NO_RC4) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
if (doit[D_RC4]) {
|
||||
for (testnum = 0; testnum < size_num; testnum++) {
|
||||
print_message(names[D_RC4], c[D_RC4][testnum], lengths[testnum],
|
||||
@@ -2527,6 +2416,7 @@ int speed_main(int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||
if (doit[D_CBC_128_AES]) {
|
||||
for (testnum = 0; testnum < size_num; testnum++) {
|
||||
print_message(names[D_CBC_128_AES], c[D_CBC_128_AES][testnum],
|
||||
@@ -2561,7 +2451,7 @@ int speed_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
#if !OPENSSL_API_3
|
||||
|
||||
if (doit[D_IGE_128_AES]) {
|
||||
for (testnum = 0; testnum < size_num; testnum++) {
|
||||
print_message(names[D_IGE_128_AES], c[D_IGE_128_AES][testnum],
|
||||
@@ -2595,7 +2485,6 @@ int speed_main(int argc, char **argv)
|
||||
print_result(D_IGE_256_AES, testnum, count, d);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (doit[D_GHASH]) {
|
||||
for (i = 0; i < loopargs_len; i++) {
|
||||
loopargs[i].gcm_ctx =
|
||||
@@ -2615,7 +2504,8 @@ int speed_main(int argc, char **argv)
|
||||
for (i = 0; i < loopargs_len; i++)
|
||||
CRYPTO_gcm128_release(loopargs[i].gcm_ctx);
|
||||
}
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
#endif /* OPENSSL_NO_DEPRECATED_3_0 */
|
||||
#if !defined(OPENSSL_NO_CAMELLIA) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
if (doit[D_CBC_128_CML]) {
|
||||
if (async_jobs > 0) {
|
||||
BIO_printf(bio_err, "Async mode is not supported with %s\n",
|
||||
@@ -2626,9 +2516,9 @@ int speed_main(int argc, char **argv)
|
||||
print_message(names[D_CBC_128_CML], c[D_CBC_128_CML][testnum],
|
||||
lengths[testnum], seconds.sym);
|
||||
Time_F(START);
|
||||
for (count = 0, run = 1; COND(c[D_CBC_128_CML][testnum]); count++)
|
||||
for (count = 0; COND(c[D_CBC_128_CML][testnum]); count++)
|
||||
Camellia_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
|
||||
(size_t)lengths[testnum], &camellia_ks1,
|
||||
(size_t)lengths[testnum], &camellia_ks[0],
|
||||
iv, CAMELLIA_ENCRYPT);
|
||||
d = Time_F(STOP);
|
||||
print_result(D_CBC_128_CML, testnum, count, d);
|
||||
@@ -2648,9 +2538,9 @@ int speed_main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
Time_F(START);
|
||||
for (count = 0, run = 1; COND(c[D_CBC_192_CML][testnum]); count++)
|
||||
for (count = 0; COND(c[D_CBC_192_CML][testnum]); count++)
|
||||
Camellia_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
|
||||
(size_t)lengths[testnum], &camellia_ks2,
|
||||
(size_t)lengths[testnum], &camellia_ks[1],
|
||||
iv, CAMELLIA_ENCRYPT);
|
||||
d = Time_F(STOP);
|
||||
print_result(D_CBC_192_CML, testnum, count, d);
|
||||
@@ -2666,9 +2556,9 @@ int speed_main(int argc, char **argv)
|
||||
print_message(names[D_CBC_256_CML], c[D_CBC_256_CML][testnum],
|
||||
lengths[testnum], seconds.sym);
|
||||
Time_F(START);
|
||||
for (count = 0, run = 1; COND(c[D_CBC_256_CML][testnum]); count++)
|
||||
for (count = 0; COND(c[D_CBC_256_CML][testnum]); count++)
|
||||
Camellia_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
|
||||
(size_t)lengths[testnum], &camellia_ks3,
|
||||
(size_t)lengths[testnum], &camellia_ks[2],
|
||||
iv, CAMELLIA_ENCRYPT);
|
||||
d = Time_F(STOP);
|
||||
print_result(D_CBC_256_CML, testnum, count, d);
|
||||
@@ -2686,7 +2576,7 @@ int speed_main(int argc, char **argv)
|
||||
print_message(names[D_CBC_IDEA], c[D_CBC_IDEA][testnum],
|
||||
lengths[testnum], seconds.sym);
|
||||
Time_F(START);
|
||||
for (count = 0, run = 1; COND(c[D_CBC_IDEA][testnum]); count++)
|
||||
for (count = 0; COND(c[D_CBC_IDEA][testnum]); count++)
|
||||
IDEA_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
|
||||
(size_t)lengths[testnum], &idea_ks,
|
||||
iv, IDEA_ENCRYPT);
|
||||
@@ -2695,7 +2585,7 @@ int speed_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SEED
|
||||
#if !defined(OPENSSL_NO_SEED) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
if (doit[D_CBC_SEED]) {
|
||||
if (async_jobs > 0) {
|
||||
BIO_printf(bio_err, "Async mode is not supported with %s\n",
|
||||
@@ -2706,7 +2596,7 @@ int speed_main(int argc, char **argv)
|
||||
print_message(names[D_CBC_SEED], c[D_CBC_SEED][testnum],
|
||||
lengths[testnum], seconds.sym);
|
||||
Time_F(START);
|
||||
for (count = 0, run = 1; COND(c[D_CBC_SEED][testnum]); count++)
|
||||
for (count = 0; COND(c[D_CBC_SEED][testnum]); count++)
|
||||
SEED_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
|
||||
(size_t)lengths[testnum], &seed_ks, iv, 1);
|
||||
d = Time_F(STOP);
|
||||
@@ -2714,7 +2604,7 @@ int speed_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC2
|
||||
#if !defined(OPENSSL_NO_RC2) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
if (doit[D_CBC_RC2]) {
|
||||
if (async_jobs > 0) {
|
||||
BIO_printf(bio_err, "Async mode is not supported with %s\n",
|
||||
@@ -2729,7 +2619,7 @@ int speed_main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
Time_F(START);
|
||||
for (count = 0, run = 1; COND(c[D_CBC_RC2][testnum]); count++)
|
||||
for (count = 0; COND(c[D_CBC_RC2][testnum]); count++)
|
||||
RC2_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
|
||||
(size_t)lengths[testnum], &rc2_ks,
|
||||
iv, RC2_ENCRYPT);
|
||||
@@ -2738,7 +2628,7 @@ int speed_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC5
|
||||
#if !defined(OPENSSL_NO_RC5) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
if (doit[D_CBC_RC5]) {
|
||||
if (async_jobs > 0) {
|
||||
BIO_printf(bio_err, "Async mode is not supported with %s\n",
|
||||
@@ -2753,7 +2643,7 @@ int speed_main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
Time_F(START);
|
||||
for (count = 0, run = 1; COND(c[D_CBC_RC5][testnum]); count++)
|
||||
for (count = 0; COND(c[D_CBC_RC5][testnum]); count++)
|
||||
RC5_32_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
|
||||
(size_t)lengths[testnum], &rc5_ks,
|
||||
iv, RC5_ENCRYPT);
|
||||
@@ -2762,7 +2652,7 @@ int speed_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_BF
|
||||
#if !defined(OPENSSL_NO_BF) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
if (doit[D_CBC_BF]) {
|
||||
if (async_jobs > 0) {
|
||||
BIO_printf(bio_err, "Async mode is not supported with %s\n",
|
||||
@@ -2773,7 +2663,7 @@ int speed_main(int argc, char **argv)
|
||||
print_message(names[D_CBC_BF], c[D_CBC_BF][testnum],
|
||||
lengths[testnum], seconds.sym);
|
||||
Time_F(START);
|
||||
for (count = 0, run = 1; COND(c[D_CBC_BF][testnum]); count++)
|
||||
for (count = 0; COND(c[D_CBC_BF][testnum]); count++)
|
||||
BF_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
|
||||
(size_t)lengths[testnum], &bf_ks,
|
||||
iv, BF_ENCRYPT);
|
||||
@@ -2782,7 +2672,7 @@ int speed_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAST
|
||||
#if !defined(OPENSSL_NO_CAST) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
if (doit[D_CBC_CAST]) {
|
||||
if (async_jobs > 0) {
|
||||
BIO_printf(bio_err, "Async mode is not supported with %s\n",
|
||||
@@ -2793,7 +2683,7 @@ int speed_main(int argc, char **argv)
|
||||
print_message(names[D_CBC_CAST], c[D_CBC_CAST][testnum],
|
||||
lengths[testnum], seconds.sym);
|
||||
Time_F(START);
|
||||
for (count = 0, run = 1; COND(c[D_CBC_CAST][testnum]); count++)
|
||||
for (count = 0; COND(c[D_CBC_CAST][testnum]); count++)
|
||||
CAST_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
|
||||
(size_t)lengths[testnum], &cast_ks,
|
||||
iv, CAST_ENCRYPT);
|
||||
@@ -2815,7 +2705,7 @@ int speed_main(int argc, char **argv)
|
||||
|
||||
if (doit[D_EVP]) {
|
||||
if (evp_cipher != NULL) {
|
||||
int (*loopfunc)(void *args) = EVP_Update_loop;
|
||||
int (*loopfunc) (void *) = EVP_Update_loop;
|
||||
|
||||
if (multiblock && (EVP_CIPHER_flags(evp_cipher) &
|
||||
EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK)) {
|
||||
@@ -2838,7 +2728,7 @@ int speed_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
for (testnum = 0; testnum < size_num; testnum++) {
|
||||
print_message(names[D_EVP], save_count, lengths[testnum],
|
||||
print_message(names[D_EVP], c[D_EVP][testnum], lengths[testnum],
|
||||
seconds.sym);
|
||||
|
||||
for (k = 0; k < loopargs_len; k++) {
|
||||
@@ -2884,7 +2774,7 @@ int speed_main(int argc, char **argv)
|
||||
names[D_EVP] = OBJ_nid2ln(EVP_MD_type(evp_md));
|
||||
|
||||
for (testnum = 0; testnum < size_num; testnum++) {
|
||||
print_message(names[D_EVP], save_count, lengths[testnum],
|
||||
print_message(names[D_EVP], c[D_EVP][testnum], lengths[testnum],
|
||||
seconds.sym);
|
||||
Time_F(START);
|
||||
count = run_benchmark(async_jobs, EVP_Digest_loop, loopargs);
|
||||
@@ -2894,52 +2784,50 @@ int speed_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (doit[D_EVP_HMAC]) {
|
||||
if (evp_hmac_md != NULL) {
|
||||
const char *md_name = OBJ_nid2ln(EVP_MD_type(evp_hmac_md));
|
||||
evp_hmac_name = app_malloc(sizeof("HMAC()") + strlen(md_name),
|
||||
"HMAC name");
|
||||
sprintf(evp_hmac_name, "HMAC(%s)", md_name);
|
||||
names[D_EVP_HMAC] = evp_hmac_name;
|
||||
if (doit[D_EVP_HMAC] && evp_hmac_md != NULL) {
|
||||
const char *md_name = OBJ_nid2ln(EVP_MD_type(evp_hmac_md));
|
||||
|
||||
for (testnum = 0; testnum < size_num; testnum++) {
|
||||
print_message(names[D_EVP_HMAC], save_count, lengths[testnum],
|
||||
seconds.sym);
|
||||
Time_F(START);
|
||||
count = run_benchmark(async_jobs, EVP_HMAC_loop, loopargs);
|
||||
d = Time_F(STOP);
|
||||
print_result(D_EVP_HMAC, testnum, count, d);
|
||||
}
|
||||
evp_hmac_name = app_malloc(sizeof("HMAC()") + strlen(md_name),
|
||||
"HMAC name");
|
||||
sprintf(evp_hmac_name, "HMAC(%s)", md_name);
|
||||
names[D_EVP_HMAC] = evp_hmac_name;
|
||||
|
||||
for (testnum = 0; testnum < size_num; testnum++) {
|
||||
print_message(names[D_EVP_HMAC], c[D_EVP_HMAC][testnum], lengths[testnum],
|
||||
seconds.sym);
|
||||
Time_F(START);
|
||||
count = run_benchmark(async_jobs, EVP_HMAC_loop, loopargs);
|
||||
d = Time_F(STOP);
|
||||
print_result(D_EVP_HMAC, testnum, count, d);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_CMAC
|
||||
if (doit[D_EVP_CMAC]) {
|
||||
if (evp_cmac_cipher != NULL) {
|
||||
const char *cipher_name = OBJ_nid2ln(EVP_CIPHER_type(evp_cmac_cipher));
|
||||
evp_cmac_name = app_malloc(sizeof("CMAC()") + strlen(cipher_name),
|
||||
"CMAC name");
|
||||
sprintf(evp_cmac_name, "CMAC(%s)", cipher_name);
|
||||
names[D_EVP_CMAC] = evp_cmac_name;
|
||||
if (doit[D_EVP_CMAC] && evp_cmac_cipher != NULL) {
|
||||
const char *cipher_name = OBJ_nid2ln(EVP_CIPHER_type(evp_cmac_cipher));
|
||||
|
||||
for (i = 0; i < loopargs_len; i++) {
|
||||
loopargs[i].cmac_ctx = CMAC_CTX_new();
|
||||
if (loopargs[i].cmac_ctx == NULL) {
|
||||
BIO_printf(bio_err, "CMAC malloc failure, exiting...");
|
||||
exit(1);
|
||||
}
|
||||
evp_cmac_name = app_malloc(sizeof("CMAC()") + strlen(cipher_name),
|
||||
"CMAC name");
|
||||
sprintf(evp_cmac_name, "CMAC(%s)", cipher_name);
|
||||
names[D_EVP_CMAC] = evp_cmac_name;
|
||||
|
||||
for (i = 0; i < loopargs_len; i++) {
|
||||
loopargs[i].cmac_ctx = CMAC_CTX_new();
|
||||
if (loopargs[i].cmac_ctx == NULL) {
|
||||
BIO_printf(bio_err, "CMAC malloc failure, exiting...");
|
||||
exit(1);
|
||||
}
|
||||
for (testnum = 0; testnum < size_num; testnum++) {
|
||||
print_message(names[D_EVP_CMAC], save_count, lengths[testnum],
|
||||
seconds.sym);
|
||||
Time_F(START);
|
||||
count = run_benchmark(async_jobs, EVP_CMAC_loop, loopargs);
|
||||
d = Time_F(STOP);
|
||||
print_result(D_EVP_CMAC, testnum, count, d);
|
||||
}
|
||||
for (i = 0; i < loopargs_len; i++)
|
||||
CMAC_CTX_free(loopargs[i].cmac_ctx);
|
||||
}
|
||||
for (testnum = 0; testnum < size_num; testnum++) {
|
||||
print_message(names[D_EVP_CMAC], c[D_EVP_CMAC][testnum], lengths[testnum],
|
||||
seconds.sym);
|
||||
Time_F(START);
|
||||
count = run_benchmark(async_jobs, EVP_CMAC_loop, loopargs);
|
||||
d = Time_F(STOP);
|
||||
print_result(D_EVP_CMAC, testnum, count, d);
|
||||
}
|
||||
for (i = 0; i < loopargs_len; i++)
|
||||
CMAC_CTX_free(loopargs[i].cmac_ctx);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2953,7 +2841,7 @@ int speed_main(int argc, char **argv)
|
||||
if (!rsa_doit[testnum])
|
||||
continue;
|
||||
for (i = 0; i < loopargs_len; i++) {
|
||||
if (primes > 2) {
|
||||
if (primes > RSA_DEFAULT_PRIME_NUM) {
|
||||
/* we haven't set keys yet, generate multi-prime RSA keys */
|
||||
BIGNUM *bn = BN_new();
|
||||
|
||||
@@ -2974,7 +2862,7 @@ int speed_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (!RSA_generate_multi_prime_key(loopargs[i].rsa_key[testnum],
|
||||
rsa_bits[testnum],
|
||||
rsa_keys[testnum].bits,
|
||||
primes, bn, NULL)) {
|
||||
BN_free(bn);
|
||||
goto end;
|
||||
@@ -2993,7 +2881,7 @@ int speed_main(int argc, char **argv)
|
||||
rsa_count = 1;
|
||||
} else {
|
||||
pkey_print_message("private", "rsa",
|
||||
rsa_c[testnum][0], rsa_bits[testnum],
|
||||
rsa_c[testnum][0], rsa_keys[testnum].bits,
|
||||
seconds.rsa);
|
||||
/* RSA_blinding_on(rsa_key[testnum],NULL); */
|
||||
Time_F(START);
|
||||
@@ -3002,7 +2890,7 @@ int speed_main(int argc, char **argv)
|
||||
BIO_printf(bio_err,
|
||||
mr ? "+R1:%ld:%d:%.2f\n"
|
||||
: "%ld %u bits private RSA's in %.2fs\n",
|
||||
count, rsa_bits[testnum], d);
|
||||
count, rsa_keys[testnum].bits, d);
|
||||
rsa_results[testnum][0] = (double)count / d;
|
||||
rsa_count = count;
|
||||
}
|
||||
@@ -3020,7 +2908,7 @@ int speed_main(int argc, char **argv)
|
||||
rsa_doit[testnum] = 0;
|
||||
} else {
|
||||
pkey_print_message("public", "rsa",
|
||||
rsa_c[testnum][1], rsa_bits[testnum],
|
||||
rsa_c[testnum][1], rsa_keys[testnum].bits,
|
||||
seconds.rsa);
|
||||
Time_F(START);
|
||||
count = run_benchmark(async_jobs, RSA_verify_loop, loopargs);
|
||||
@@ -3028,14 +2916,13 @@ int speed_main(int argc, char **argv)
|
||||
BIO_printf(bio_err,
|
||||
mr ? "+R2:%ld:%d:%.2f\n"
|
||||
: "%ld %u bits public RSA's in %.2fs\n",
|
||||
count, rsa_bits[testnum], d);
|
||||
count, rsa_keys[testnum].bits, d);
|
||||
rsa_results[testnum][1] = (double)count / d;
|
||||
}
|
||||
|
||||
if (rsa_count <= 1) {
|
||||
/* if longer than 10s, don't do any more */
|
||||
for (testnum++; testnum < RSA_NUM; testnum++)
|
||||
rsa_doit[testnum] = 0;
|
||||
stop_it(rsa_doit, testnum);
|
||||
}
|
||||
}
|
||||
#endif /* OPENSSL_NO_RSA */
|
||||
@@ -3105,8 +2992,7 @@ int speed_main(int argc, char **argv)
|
||||
|
||||
if (rsa_count <= 1) {
|
||||
/* if longer than 10s, don't do any more */
|
||||
for (testnum++; testnum < DSA_NUM; testnum++)
|
||||
dsa_doit[testnum] = 0;
|
||||
stop_it(dsa_doit, testnum);
|
||||
}
|
||||
}
|
||||
#endif /* OPENSSL_NO_DSA */
|
||||
@@ -3119,7 +3005,7 @@ int speed_main(int argc, char **argv)
|
||||
continue; /* Ignore Curve */
|
||||
for (i = 0; i < loopargs_len; i++) {
|
||||
loopargs[i].ecdsa[testnum] =
|
||||
EC_KEY_new_by_curve_name(test_curves[testnum].nid);
|
||||
EC_KEY_new_by_curve_name(ec_curves[testnum].nid);
|
||||
if (loopargs[i].ecdsa[testnum] == NULL) {
|
||||
st = 0;
|
||||
break;
|
||||
@@ -3148,7 +3034,7 @@ int speed_main(int argc, char **argv)
|
||||
} else {
|
||||
pkey_print_message("sign", "ecdsa",
|
||||
ecdsa_c[testnum][0],
|
||||
test_curves[testnum].bits, seconds.ecdsa);
|
||||
ec_curves[testnum].bits, seconds.ecdsa);
|
||||
Time_F(START);
|
||||
count = run_benchmark(async_jobs, ECDSA_sign_loop, loopargs);
|
||||
d = Time_F(STOP);
|
||||
@@ -3156,7 +3042,7 @@ int speed_main(int argc, char **argv)
|
||||
BIO_printf(bio_err,
|
||||
mr ? "+R5:%ld:%u:%.2f\n" :
|
||||
"%ld %u bits ECDSA signs in %.2fs \n",
|
||||
count, test_curves[testnum].bits, d);
|
||||
count, ec_curves[testnum].bits, d);
|
||||
ecdsa_results[testnum][0] = (double)count / d;
|
||||
rsa_count = count;
|
||||
}
|
||||
@@ -3177,21 +3063,20 @@ int speed_main(int argc, char **argv)
|
||||
} else {
|
||||
pkey_print_message("verify", "ecdsa",
|
||||
ecdsa_c[testnum][1],
|
||||
test_curves[testnum].bits, seconds.ecdsa);
|
||||
ec_curves[testnum].bits, seconds.ecdsa);
|
||||
Time_F(START);
|
||||
count = run_benchmark(async_jobs, ECDSA_verify_loop, loopargs);
|
||||
d = Time_F(STOP);
|
||||
BIO_printf(bio_err,
|
||||
mr ? "+R6:%ld:%u:%.2f\n"
|
||||
: "%ld %u bits ECDSA verify in %.2fs\n",
|
||||
count, test_curves[testnum].bits, d);
|
||||
count, ec_curves[testnum].bits, d);
|
||||
ecdsa_results[testnum][1] = (double)count / d;
|
||||
}
|
||||
|
||||
if (rsa_count <= 1) {
|
||||
/* if longer than 10s, don't do any more */
|
||||
for (testnum++; testnum < ECDSA_NUM; testnum++)
|
||||
ecdsa_doit[testnum] = 0;
|
||||
stop_it(ecdsa_doit, testnum);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3224,7 +3109,7 @@ int speed_main(int argc, char **argv)
|
||||
* If this fails we try creating a EVP_PKEY_EC generic param ctx,
|
||||
* then we set the curve by NID before deriving the actual keygen
|
||||
* ctx for that specific curve. */
|
||||
kctx = EVP_PKEY_CTX_new_id(test_curves[testnum].nid, NULL); /* keygen ctx from NID */
|
||||
kctx = EVP_PKEY_CTX_new_id(ec_curves[testnum].nid, NULL); /* keygen ctx from NID */
|
||||
if (!kctx) {
|
||||
EVP_PKEY_CTX *pctx = NULL;
|
||||
EVP_PKEY *params = NULL;
|
||||
@@ -3247,13 +3132,13 @@ int speed_main(int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
|
||||
if ( /* Create the context for parameter generation */
|
||||
!(pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL)) ||
|
||||
/* Create the context for parameter generation */
|
||||
if (!(pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL)) ||
|
||||
/* Initialise the parameter generation */
|
||||
!EVP_PKEY_paramgen_init(pctx) ||
|
||||
/* Set the curve by NID */
|
||||
!EVP_PKEY_CTX_set_ec_paramgen_curve_nid(pctx,
|
||||
test_curves
|
||||
ec_curves
|
||||
[testnum].nid) ||
|
||||
/* Create the parameter object params */
|
||||
!EVP_PKEY_paramgen(pctx, ¶ms)) {
|
||||
@@ -3336,7 +3221,7 @@ int speed_main(int argc, char **argv)
|
||||
if (ecdh_checks != 0) {
|
||||
pkey_print_message("", "ecdh",
|
||||
ecdh_c[testnum][0],
|
||||
test_curves[testnum].bits, seconds.ecdh);
|
||||
ec_curves[testnum].bits, seconds.ecdh);
|
||||
Time_F(START);
|
||||
count =
|
||||
run_benchmark(async_jobs, ECDH_EVP_derive_key_loop, loopargs);
|
||||
@@ -3344,15 +3229,14 @@ int speed_main(int argc, char **argv)
|
||||
BIO_printf(bio_err,
|
||||
mr ? "+R7:%ld:%d:%.2f\n" :
|
||||
"%ld %u-bits ECDH ops in %.2fs\n", count,
|
||||
test_curves[testnum].bits, d);
|
||||
ec_curves[testnum].bits, d);
|
||||
ecdh_results[testnum][0] = (double)count / d;
|
||||
rsa_count = count;
|
||||
}
|
||||
|
||||
if (rsa_count <= 1) {
|
||||
/* if longer than 10s, don't do any more */
|
||||
for (testnum++; testnum < OSSL_NELEM(ecdh_doit); testnum++)
|
||||
ecdh_doit[testnum] = 0;
|
||||
stop_it(ecdh_doit, testnum);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3370,7 +3254,7 @@ int speed_main(int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
|
||||
if ((ed_pctx = EVP_PKEY_CTX_new_id(test_ed_curves[testnum].nid, NULL))
|
||||
if ((ed_pctx = EVP_PKEY_CTX_new_id(ed_curves[testnum].nid, NULL))
|
||||
== NULL
|
||||
|| EVP_PKEY_keygen_init(ed_pctx) <= 0
|
||||
|| EVP_PKEY_keygen(ed_pctx, &ed_pkey) <= 0) {
|
||||
@@ -3395,7 +3279,7 @@ int speed_main(int argc, char **argv)
|
||||
} else {
|
||||
for (i = 0; i < loopargs_len; i++) {
|
||||
/* Perform EdDSA signature test */
|
||||
loopargs[i].sigsize = test_ed_curves[testnum].sigsize;
|
||||
loopargs[i].sigsize = ed_curves[testnum].sigsize;
|
||||
st = EVP_DigestSign(loopargs[i].eddsa_ctx[testnum],
|
||||
loopargs[i].buf2, &loopargs[i].sigsize,
|
||||
loopargs[i].buf, 20);
|
||||
@@ -3408,9 +3292,9 @@ int speed_main(int argc, char **argv)
|
||||
ERR_print_errors(bio_err);
|
||||
rsa_count = 1;
|
||||
} else {
|
||||
pkey_print_message("sign", test_ed_curves[testnum].name,
|
||||
pkey_print_message("sign", ed_curves[testnum].name,
|
||||
eddsa_c[testnum][0],
|
||||
test_ed_curves[testnum].bits, seconds.eddsa);
|
||||
ed_curves[testnum].bits, seconds.eddsa);
|
||||
Time_F(START);
|
||||
count = run_benchmark(async_jobs, EdDSA_sign_loop, loopargs);
|
||||
d = Time_F(STOP);
|
||||
@@ -3418,8 +3302,8 @@ int speed_main(int argc, char **argv)
|
||||
BIO_printf(bio_err,
|
||||
mr ? "+R8:%ld:%u:%s:%.2f\n" :
|
||||
"%ld %u bits %s signs in %.2fs \n",
|
||||
count, test_ed_curves[testnum].bits,
|
||||
test_ed_curves[testnum].name, d);
|
||||
count, ed_curves[testnum].bits,
|
||||
ed_curves[testnum].name, d);
|
||||
eddsa_results[testnum][0] = (double)count / d;
|
||||
rsa_count = count;
|
||||
}
|
||||
@@ -3438,24 +3322,23 @@ int speed_main(int argc, char **argv)
|
||||
ERR_print_errors(bio_err);
|
||||
eddsa_doit[testnum] = 0;
|
||||
} else {
|
||||
pkey_print_message("verify", test_ed_curves[testnum].name,
|
||||
pkey_print_message("verify", ed_curves[testnum].name,
|
||||
eddsa_c[testnum][1],
|
||||
test_ed_curves[testnum].bits, seconds.eddsa);
|
||||
ed_curves[testnum].bits, seconds.eddsa);
|
||||
Time_F(START);
|
||||
count = run_benchmark(async_jobs, EdDSA_verify_loop, loopargs);
|
||||
d = Time_F(STOP);
|
||||
BIO_printf(bio_err,
|
||||
mr ? "+R9:%ld:%u:%s:%.2f\n"
|
||||
: "%ld %u bits %s verify in %.2fs\n",
|
||||
count, test_ed_curves[testnum].bits,
|
||||
test_ed_curves[testnum].name, d);
|
||||
count, ed_curves[testnum].bits,
|
||||
ed_curves[testnum].name, d);
|
||||
eddsa_results[testnum][1] = (double)count / d;
|
||||
}
|
||||
|
||||
if (rsa_count <= 1) {
|
||||
/* if longer than 10s, don't do any more */
|
||||
for (testnum++; testnum < EdDSA_NUM; testnum++)
|
||||
eddsa_doit[testnum] = 0;
|
||||
stop_it(eddsa_doit, testnum);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3464,105 +3347,73 @@ int speed_main(int argc, char **argv)
|
||||
for (testnum = 0; testnum < SM2_NUM; testnum++) {
|
||||
int st = 1;
|
||||
EVP_PKEY *sm2_pkey = NULL;
|
||||
EVP_PKEY_CTX *pctx = NULL;
|
||||
EVP_PKEY_CTX *sm2_pctx = NULL;
|
||||
EVP_PKEY_CTX *sm2_vfy_pctx = NULL;
|
||||
size_t sm2_sigsize = 0;
|
||||
|
||||
if (!sm2_doit[testnum])
|
||||
continue; /* Ignore Curve */
|
||||
/* Init signing and verification */
|
||||
for (i = 0; i < loopargs_len; i++) {
|
||||
EVP_PKEY_CTX *sm2_pctx = NULL;
|
||||
EVP_PKEY_CTX *sm2_vfy_pctx = NULL;
|
||||
EVP_PKEY_CTX *pctx = NULL;
|
||||
st = 0;
|
||||
|
||||
loopargs[i].sm2_ctx[testnum] = EVP_MD_CTX_new();
|
||||
if (loopargs[i].sm2_ctx[testnum] == NULL) {
|
||||
st = 0;
|
||||
break;
|
||||
}
|
||||
loopargs[i].sm2_vfy_ctx[testnum] = EVP_MD_CTX_new();
|
||||
if (loopargs[i].sm2_vfy_ctx[testnum] == NULL) {
|
||||
st = 0;
|
||||
if (loopargs[i].sm2_ctx[testnum] == NULL
|
||||
|| loopargs[i].sm2_vfy_ctx[testnum] == NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
/* SM2 keys are generated as normal EC keys with a special curve */
|
||||
if ((pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL)) == NULL
|
||||
st = !((pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL)) == NULL
|
||||
|| EVP_PKEY_keygen_init(pctx) <= 0
|
||||
|| EVP_PKEY_CTX_set_ec_paramgen_curve_nid(pctx,
|
||||
test_sm2_curves[testnum].nid) <= 0
|
||||
|| EVP_PKEY_keygen(pctx, &sm2_pkey) <= 0) {
|
||||
st = 0;
|
||||
EVP_PKEY_CTX_free(pctx);
|
||||
break;
|
||||
}
|
||||
/* free previous one and alloc a new one */
|
||||
sm2_curves[testnum].nid) <= 0
|
||||
|| EVP_PKEY_keygen(pctx, &sm2_pkey) <= 0);
|
||||
EVP_PKEY_CTX_free(pctx);
|
||||
|
||||
loopargs[i].sigsize = sm2_sigsize
|
||||
= ECDSA_size(EVP_PKEY_get0_EC_KEY(sm2_pkey));
|
||||
|
||||
if (!EVP_PKEY_set_alias_type(sm2_pkey, EVP_PKEY_SM2)) {
|
||||
st = 0;
|
||||
EVP_PKEY_free(sm2_pkey);
|
||||
if (st == 0)
|
||||
break;
|
||||
|
||||
st = 0; /* set back to zero */
|
||||
/* attach it sooner to rely on main final cleanup */
|
||||
loopargs[i].sm2_pkey[testnum] = sm2_pkey;
|
||||
loopargs[i].sigsize = ECDSA_size(EVP_PKEY_get0_EC_KEY(sm2_pkey));
|
||||
if (!EVP_PKEY_set_alias_type(sm2_pkey, EVP_PKEY_SM2))
|
||||
break;
|
||||
}
|
||||
|
||||
sm2_pctx = EVP_PKEY_CTX_new(sm2_pkey, NULL);
|
||||
if (sm2_pctx == NULL) {
|
||||
st = 0;
|
||||
EVP_PKEY_free(sm2_pkey);
|
||||
break;
|
||||
}
|
||||
sm2_vfy_pctx = EVP_PKEY_CTX_new(sm2_pkey, NULL);
|
||||
if (sm2_vfy_pctx == NULL) {
|
||||
st = 0;
|
||||
EVP_PKEY_CTX_free(sm2_pctx);
|
||||
EVP_PKEY_free(sm2_pkey);
|
||||
if (sm2_pctx == NULL || sm2_vfy_pctx == NULL) {
|
||||
EVP_PKEY_CTX_free(sm2_vfy_pctx);
|
||||
break;
|
||||
}
|
||||
/* attach them directly to respective ctx */
|
||||
EVP_MD_CTX_set_pkey_ctx(loopargs[i].sm2_ctx[testnum], sm2_pctx);
|
||||
EVP_MD_CTX_set_pkey_ctx(loopargs[i].sm2_vfy_ctx[testnum], sm2_vfy_pctx);
|
||||
|
||||
/*
|
||||
* No need to allow user to set an explicit ID here, just use
|
||||
* the one defined in the 'draft-yang-tls-tl13-sm-suites' I-D.
|
||||
*/
|
||||
if (EVP_PKEY_CTX_set1_id(sm2_pctx, SM2_ID, SM2_ID_LEN) != 1) {
|
||||
st = 0;
|
||||
EVP_PKEY_CTX_free(sm2_pctx);
|
||||
EVP_PKEY_CTX_free(sm2_vfy_pctx);
|
||||
EVP_PKEY_free(sm2_pkey);
|
||||
if (EVP_PKEY_CTX_set1_id(sm2_pctx, SM2_ID, SM2_ID_LEN) != 1
|
||||
|| EVP_PKEY_CTX_set1_id(sm2_vfy_pctx, SM2_ID, SM2_ID_LEN) != 1)
|
||||
break;
|
||||
}
|
||||
|
||||
if (EVP_PKEY_CTX_set1_id(sm2_vfy_pctx, SM2_ID, SM2_ID_LEN) != 1) {
|
||||
st = 0;
|
||||
EVP_PKEY_CTX_free(sm2_pctx);
|
||||
EVP_PKEY_CTX_free(sm2_vfy_pctx);
|
||||
EVP_PKEY_free(sm2_pkey);
|
||||
break;
|
||||
}
|
||||
|
||||
EVP_MD_CTX_set_pkey_ctx(loopargs[i].sm2_ctx[testnum], sm2_pctx);
|
||||
EVP_MD_CTX_set_pkey_ctx(loopargs[i].sm2_vfy_ctx[testnum], sm2_vfy_pctx);
|
||||
|
||||
if (!EVP_DigestSignInit(loopargs[i].sm2_ctx[testnum], NULL,
|
||||
EVP_sm3(), NULL, sm2_pkey)) {
|
||||
st = 0;
|
||||
EVP_PKEY_free(sm2_pkey);
|
||||
EVP_sm3(), NULL, sm2_pkey))
|
||||
break;
|
||||
}
|
||||
if (!EVP_DigestVerifyInit(loopargs[i].sm2_vfy_ctx[testnum], NULL,
|
||||
EVP_sm3(), NULL, sm2_pkey)) {
|
||||
st = 0;
|
||||
EVP_PKEY_free(sm2_pkey);
|
||||
EVP_sm3(), NULL, sm2_pkey))
|
||||
break;
|
||||
}
|
||||
loopargs[i].sm2_pkey[testnum] = sm2_pkey;
|
||||
st = 1; /* mark loop as succeeded */
|
||||
}
|
||||
if (st == 0) {
|
||||
BIO_printf(bio_err, "SM2 failure.\n");
|
||||
BIO_printf(bio_err, "SM2 init failure.\n");
|
||||
ERR_print_errors(bio_err);
|
||||
rsa_count = 1;
|
||||
} else {
|
||||
for (i = 0; i < loopargs_len; i++) {
|
||||
sm2_sigsize = loopargs[i].sigsize;
|
||||
size_t sm2_sigsize = loopargs[i].sigsize;
|
||||
|
||||
/* Perform SM2 signature test */
|
||||
st = EVP_DigestSign(loopargs[i].sm2_ctx[testnum],
|
||||
loopargs[i].buf2, &sm2_sigsize,
|
||||
@@ -3576,9 +3427,9 @@ int speed_main(int argc, char **argv)
|
||||
ERR_print_errors(bio_err);
|
||||
rsa_count = 1;
|
||||
} else {
|
||||
pkey_print_message("sign", test_sm2_curves[testnum].name,
|
||||
pkey_print_message("sign", sm2_curves[testnum].name,
|
||||
sm2_c[testnum][0],
|
||||
test_sm2_curves[testnum].bits, seconds.sm2);
|
||||
sm2_curves[testnum].bits, seconds.sm2);
|
||||
Time_F(START);
|
||||
count = run_benchmark(async_jobs, SM2_sign_loop, loopargs);
|
||||
d = Time_F(STOP);
|
||||
@@ -3586,8 +3437,8 @@ int speed_main(int argc, char **argv)
|
||||
BIO_printf(bio_err,
|
||||
mr ? "+R8:%ld:%u:%s:%.2f\n" :
|
||||
"%ld %u bits %s signs in %.2fs \n",
|
||||
count, test_sm2_curves[testnum].bits,
|
||||
test_sm2_curves[testnum].name, d);
|
||||
count, sm2_curves[testnum].bits,
|
||||
sm2_curves[testnum].name, d);
|
||||
sm2_results[testnum][0] = (double)count / d;
|
||||
rsa_count = count;
|
||||
}
|
||||
@@ -3606,17 +3457,17 @@ int speed_main(int argc, char **argv)
|
||||
ERR_print_errors(bio_err);
|
||||
sm2_doit[testnum] = 0;
|
||||
} else {
|
||||
pkey_print_message("verify", test_sm2_curves[testnum].name,
|
||||
pkey_print_message("verify", sm2_curves[testnum].name,
|
||||
sm2_c[testnum][1],
|
||||
test_sm2_curves[testnum].bits, seconds.sm2);
|
||||
sm2_curves[testnum].bits, seconds.sm2);
|
||||
Time_F(START);
|
||||
count = run_benchmark(async_jobs, SM2_verify_loop, loopargs);
|
||||
d = Time_F(STOP);
|
||||
BIO_printf(bio_err,
|
||||
mr ? "+R9:%ld:%u:%s:%.2f\n"
|
||||
: "%ld %u bits %s verify in %.2fs\n",
|
||||
count, test_sm2_curves[testnum].bits,
|
||||
test_sm2_curves[testnum].name, d);
|
||||
count, sm2_curves[testnum].bits,
|
||||
sm2_curves[testnum].name, d);
|
||||
sm2_results[testnum][1] = (double)count / d;
|
||||
}
|
||||
|
||||
@@ -3638,20 +3489,22 @@ int speed_main(int argc, char **argv)
|
||||
printf("built on: %s\n", OpenSSL_version(OPENSSL_BUILT_ON));
|
||||
printf("options:");
|
||||
printf("%s ", BN_options());
|
||||
#ifndef OPENSSL_NO_MD2
|
||||
#if !defined(OPENSSL_NO_MD2) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
printf("%s ", MD2_options());
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC4
|
||||
#if !defined(OPENSSL_NO_RC4) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
printf("%s ", RC4_options());
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DES
|
||||
printf("%s ", DES_options());
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||
printf("%s ", AES_options());
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_IDEA
|
||||
printf("%s ", IDEA_options());
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_BF
|
||||
#if !defined(OPENSSL_NO_BF) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
printf("%s ", BF_options());
|
||||
#endif
|
||||
printf("\n%s\n", OpenSSL_version(OPENSSL_CFLAGS));
|
||||
@@ -3697,10 +3550,10 @@ int speed_main(int argc, char **argv)
|
||||
}
|
||||
if (mr)
|
||||
printf("+F2:%u:%u:%f:%f\n",
|
||||
k, rsa_bits[k], rsa_results[k][0], rsa_results[k][1]);
|
||||
k, rsa_keys[k].bits, rsa_results[k][0], rsa_results[k][1]);
|
||||
else
|
||||
printf("rsa %4u bits %8.6fs %8.6fs %8.1f %8.1f\n",
|
||||
rsa_bits[k], 1.0 / rsa_results[k][0], 1.0 / rsa_results[k][1],
|
||||
rsa_keys[k].bits, 1.0 / rsa_results[k][0], 1.0 / rsa_results[k][1],
|
||||
rsa_results[k][0], rsa_results[k][1]);
|
||||
}
|
||||
#endif
|
||||
@@ -3734,11 +3587,11 @@ int speed_main(int argc, char **argv)
|
||||
|
||||
if (mr)
|
||||
printf("+F4:%u:%u:%f:%f\n",
|
||||
k, test_curves[k].bits,
|
||||
k, ec_curves[k].bits,
|
||||
ecdsa_results[k][0], ecdsa_results[k][1]);
|
||||
else
|
||||
printf("%4u bits ecdsa (%s) %8.4fs %8.4fs %8.1f %8.1f\n",
|
||||
test_curves[k].bits, test_curves[k].name,
|
||||
ec_curves[k].bits, ec_curves[k].name,
|
||||
1.0 / ecdsa_results[k][0], 1.0 / ecdsa_results[k][1],
|
||||
ecdsa_results[k][0], ecdsa_results[k][1]);
|
||||
}
|
||||
@@ -3753,12 +3606,12 @@ int speed_main(int argc, char **argv)
|
||||
}
|
||||
if (mr)
|
||||
printf("+F5:%u:%u:%f:%f\n",
|
||||
k, test_curves[k].bits,
|
||||
k, ec_curves[k].bits,
|
||||
ecdh_results[k][0], 1.0 / ecdh_results[k][0]);
|
||||
|
||||
else
|
||||
printf("%4u bits ecdh (%s) %8.4fs %8.1f\n",
|
||||
test_curves[k].bits, test_curves[k].name,
|
||||
ec_curves[k].bits, ec_curves[k].name,
|
||||
1.0 / ecdh_results[k][0], ecdh_results[k][0]);
|
||||
}
|
||||
|
||||
@@ -3773,11 +3626,11 @@ int speed_main(int argc, char **argv)
|
||||
|
||||
if (mr)
|
||||
printf("+F6:%u:%u:%s:%f:%f\n",
|
||||
k, test_ed_curves[k].bits, test_ed_curves[k].name,
|
||||
k, ed_curves[k].bits, ed_curves[k].name,
|
||||
eddsa_results[k][0], eddsa_results[k][1]);
|
||||
else
|
||||
printf("%4u bits EdDSA (%s) %8.4fs %8.4fs %8.1f %8.1f\n",
|
||||
test_ed_curves[k].bits, test_ed_curves[k].name,
|
||||
ed_curves[k].bits, ed_curves[k].name,
|
||||
1.0 / eddsa_results[k][0], 1.0 / eddsa_results[k][1],
|
||||
eddsa_results[k][0], eddsa_results[k][1]);
|
||||
}
|
||||
@@ -3794,16 +3647,16 @@ int speed_main(int argc, char **argv)
|
||||
|
||||
if (mr)
|
||||
printf("+F6:%u:%u:%s:%f:%f\n",
|
||||
k, test_sm2_curves[k].bits, test_sm2_curves[k].name,
|
||||
k, sm2_curves[k].bits, sm2_curves[k].name,
|
||||
sm2_results[k][0], sm2_results[k][1]);
|
||||
else
|
||||
printf("%4u bits SM2 (%s) %8.4fs %8.4fs %8.1f %8.1f\n",
|
||||
test_sm2_curves[k].bits, test_sm2_curves[k].name,
|
||||
sm2_curves[k].bits, sm2_curves[k].name,
|
||||
1.0 / sm2_results[k][0], 1.0 / sm2_results[k][1],
|
||||
sm2_results[k][0], sm2_results[k][1]);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
#endif /* OPENSSL_NO_EC */
|
||||
|
||||
ret = 0;
|
||||
|
||||
@@ -3875,6 +3728,7 @@ static void print_message(const char *s, long num, int length, int tm)
|
||||
mr ? "+DT:%s:%d:%d\n"
|
||||
: "Doing %s for %ds on %d size blocks: ", s, tm, length);
|
||||
(void)BIO_flush(bio_err);
|
||||
run = 1;
|
||||
alarm(tm);
|
||||
#else
|
||||
BIO_printf(bio_err,
|
||||
@@ -3892,6 +3746,7 @@ static void pkey_print_message(const char *str, const char *str2, long num,
|
||||
mr ? "+DTP:%d:%s:%s:%d\n"
|
||||
: "Doing %u bits %s %s's for %ds: ", bits, str, str2, tm);
|
||||
(void)BIO_flush(bio_err);
|
||||
run = 1;
|
||||
alarm(tm);
|
||||
#else
|
||||
BIO_printf(bio_err,
|
||||
@@ -3904,8 +3759,10 @@ static void pkey_print_message(const char *str, const char *str2, long num,
|
||||
static void print_result(int alg, int run_no, int count, double time_used)
|
||||
{
|
||||
if (count == -1) {
|
||||
BIO_puts(bio_err, "EVP error!\n");
|
||||
exit(1);
|
||||
BIO_printf(bio_err, "%s error!\n", names[alg]);
|
||||
ERR_print_errors(bio_err);
|
||||
/* exit(1); disable exit until default provider enabled */
|
||||
return;
|
||||
}
|
||||
BIO_printf(bio_err,
|
||||
mr ? "+R:%d:%s:%f\n"
|
||||
@@ -4064,6 +3921,7 @@ static int do_multi(int multi, int size_num)
|
||||
p = buf + 4;
|
||||
k = atoi(sstrsep(&p, sep));
|
||||
sstrsep(&p, sep);
|
||||
sstrsep(&p, sep);
|
||||
|
||||
d = atof(sstrsep(&p, sep));
|
||||
eddsa_results[k][0] += d;
|
||||
@@ -4137,7 +3995,7 @@ static void multiblock_speed(const EVP_CIPHER *evp_cipher, int lengths_single,
|
||||
for (j = 0; j < num; j++) {
|
||||
print_message(alg_name, 0, mblengths[j], seconds->sym);
|
||||
Time_F(START);
|
||||
for (count = 0, run = 1; run && count < 0x7fffffff; count++) {
|
||||
for (count = 0; run && count < 0x7fffffff; count++) {
|
||||
unsigned char aad[EVP_AEAD_TLS1_AAD_LEN];
|
||||
EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM mb_param;
|
||||
size_t len = mblengths[j];
|
||||
|
||||
+15
-10
@@ -28,22 +28,27 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS spkac_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"key", OPT_KEY, '<', "Create SPKAC using private key"},
|
||||
{"keyform", OPT_KEYFORM, 'f', "Private key file format - default PEM (PEM, DER, or ENGINE)"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"challenge", OPT_CHALLENGE, 's', "Challenge string"},
|
||||
{"spkac", OPT_SPKAC, 's', "Alternative SPKAC name"},
|
||||
{"noout", OPT_NOOUT, '-', "Don't print SPKAC"},
|
||||
{"pubkey", OPT_PUBKEY, '-', "Output public key"},
|
||||
{"verify", OPT_VERIFY, '-', "Verify SPKAC signature"},
|
||||
{"spksect", OPT_SPKSECT, 's',
|
||||
"Specify the name of an SPKAC-dedicated section of configuration"},
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
|
||||
OPT_SECTION("Input"),
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
{"key", OPT_KEY, '<', "Create SPKAC using private key"},
|
||||
{"keyform", OPT_KEYFORM, 'f', "Private key file format - default PEM (PEM, DER, or ENGINE)"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"challenge", OPT_CHALLENGE, 's', "Challenge string"},
|
||||
{"spkac", OPT_SPKAC, 's', "Alternative SPKAC name"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"noout", OPT_NOOUT, '-', "Don't print SPKAC"},
|
||||
{"pubkey", OPT_PUBKEY, '-', "Output public key"},
|
||||
{"verify", OPT_VERIFY, '-', "Verify SPKAC signature"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+16
-6
@@ -197,24 +197,34 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS srp_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] [user...]\n"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"verbose", OPT_VERBOSE, '-', "Talk a lot while doing things"},
|
||||
{"config", OPT_CONFIG, '<', "A config file"},
|
||||
{"name", OPT_NAME, 's', "The particular srp definition to use"},
|
||||
{"srpvfile", OPT_SRPVFILE, '<', "The srp verifier file name"},
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
# endif
|
||||
|
||||
OPT_SECTION("Action"),
|
||||
{"add", OPT_ADD, '-', "Add a user and srp verifier"},
|
||||
{"modify", OPT_MODIFY, '-',
|
||||
"Modify the srp verifier of an existing user"},
|
||||
{"modify", OPT_MODIFY, '-', "Modify the srp verifier of an existing user"},
|
||||
{"delete", OPT_DELETE, '-', "Delete user from verifier file"},
|
||||
{"list", OPT_LIST, '-', "List users"},
|
||||
|
||||
OPT_SECTION("Configuration"),
|
||||
{"srpvfile", OPT_SRPVFILE, '<', "The srp verifier file name"},
|
||||
{"gn", OPT_GN, 's', "Set g and N values to be used for new verifier"},
|
||||
{"userinfo", OPT_USERINFO, 's', "Additional info to be set for user"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
|
||||
|
||||
OPT_R_OPTIONS,
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
# endif
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"user", 0, 0, "Username(s) to process (optional)"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
+20
-9
@@ -31,12 +31,16 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS storeutl_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] uri\nValid options are:\n"},
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] uri\n"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"out", OPT_OUT, '>', "Output file - default stdout"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"text", OPT_TEXT, '-', "Print a text form of the objects"},
|
||||
{"noout", OPT_NOOUT, '-', "No PEM output, just status"},
|
||||
{"", OPT_MD, '-', "Any supported digest"},
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
|
||||
OPT_SECTION("Search"),
|
||||
{"certs", OPT_SEARCHFOR_CERTS, '-', "Search for certificates only"},
|
||||
{"keys", OPT_SEARCHFOR_KEYS, '-', "Search for keys only"},
|
||||
{"crls", OPT_SEARCHFOR_CRLS, '-', "Search for CRLs only"},
|
||||
@@ -45,11 +49,18 @@ const OPTIONS storeutl_options[] = {
|
||||
{"serial", OPT_CRITERION_SERIAL, 's', "Search by issuer and serial, serial number"},
|
||||
{"fingerprint", OPT_CRITERION_FINGERPRINT, 's', "Search by public key fingerprint, given in hex"},
|
||||
{"alias", OPT_CRITERION_ALIAS, 's', "Search by alias"},
|
||||
{"", OPT_MD, '-', "Any supported digest"},
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
{"r", OPT_RECURSIVE, '-', "Recurse through names"},
|
||||
|
||||
OPT_SECTION("Input"),
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"out", OPT_OUT, '>', "Output file - default stdout"},
|
||||
{"text", OPT_TEXT, '-', "Print a text form of the objects"},
|
||||
{"noout", OPT_NOOUT, '-', "No PEM output, just status"},
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"uri", 0, 0, "URI of the store object"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
||||
@@ -66,15 +66,17 @@ static int save_ts_serial(const char *serialfile, ASN1_INTEGER *serial);
|
||||
/* Verify related functions. */
|
||||
static int verify_command(const char *data, const char *digest, const char *queryfile,
|
||||
const char *in, int token_in,
|
||||
const char *CApath, const char *CAfile, const char *untrusted,
|
||||
X509_VERIFY_PARAM *vpm);
|
||||
const char *CApath, const char *CAfile,
|
||||
const char *CAstore,
|
||||
const char *untrusted, X509_VERIFY_PARAM *vpm);
|
||||
static TS_VERIFY_CTX *create_verify_ctx(const char *data, const char *digest,
|
||||
const char *queryfile,
|
||||
const char *CApath, const char *CAfile,
|
||||
const char *CAstore,
|
||||
const char *untrusted,
|
||||
X509_VERIFY_PARAM *vpm);
|
||||
static X509_STORE *create_cert_store(const char *CApath, const char *CAfile,
|
||||
X509_VERIFY_PARAM *vpm);
|
||||
const char *CAstore, X509_VERIFY_PARAM *vpm);
|
||||
static int verify_cb(int ok, X509_STORE_CTX *ctx);
|
||||
|
||||
typedef enum OPTION_choice {
|
||||
@@ -83,43 +85,48 @@ typedef enum OPTION_choice {
|
||||
OPT_DIGEST, OPT_TSPOLICY, OPT_NO_NONCE, OPT_CERT,
|
||||
OPT_IN, OPT_TOKEN_IN, OPT_OUT, OPT_TOKEN_OUT, OPT_TEXT,
|
||||
OPT_REPLY, OPT_QUERYFILE, OPT_PASSIN, OPT_INKEY, OPT_SIGNER,
|
||||
OPT_CHAIN, OPT_VERIFY, OPT_CAPATH, OPT_CAFILE, OPT_UNTRUSTED,
|
||||
OPT_CHAIN, OPT_VERIFY, OPT_CAPATH, OPT_CAFILE, OPT_CASTORE, OPT_UNTRUSTED,
|
||||
OPT_MD, OPT_V_ENUM, OPT_R_ENUM
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS ts_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"config", OPT_CONFIG, '<', "Configuration file"},
|
||||
{"section", OPT_SECTION, 's', "Section to use within config file"},
|
||||
{"query", OPT_QUERY, '-', "Generate a TS query"},
|
||||
{"data", OPT_DATA, '<', "File to hash"},
|
||||
{"digest", OPT_DIGEST, 's', "Digest (as a hex string)"},
|
||||
OPT_R_OPTIONS,
|
||||
{"tspolicy", OPT_TSPOLICY, 's', "Policy OID to use"},
|
||||
{"no_nonce", OPT_NO_NONCE, '-', "Do not include a nonce"},
|
||||
{"cert", OPT_CERT, '-', "Put cert request into query"},
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
{"token_in", OPT_TOKEN_IN, '-', "Input is a PKCS#7 file"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"token_out", OPT_TOKEN_OUT, '-', "Output is a PKCS#7 file"},
|
||||
{"text", OPT_TEXT, '-', "Output text (not DER)"},
|
||||
{"reply", OPT_REPLY, '-', "Generate a TS reply"},
|
||||
{"queryfile", OPT_QUERYFILE, '<', "File containing a TS query"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"inkey", OPT_INKEY, 's', "File with private key for reply"},
|
||||
{"signer", OPT_SIGNER, 's', "Signer certificate file"},
|
||||
{"chain", OPT_CHAIN, '<', "File with signer CA chain"},
|
||||
{"verify", OPT_VERIFY, '-', "Verify a TS response"},
|
||||
{"CApath", OPT_CAPATH, '/', "Path to trusted CA files"},
|
||||
{"CAfile", OPT_CAFILE, '<', "File with trusted CA certs"},
|
||||
{"untrusted", OPT_UNTRUSTED, '<', "File with untrusted certs"},
|
||||
{"", OPT_MD, '-', "Any supported digest"},
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
# endif
|
||||
{OPT_HELP_STR, 1, '-', "\nOptions specific to 'ts -verify': \n"},
|
||||
{"inkey", OPT_INKEY, 's', "File with private key for reply"},
|
||||
{"signer", OPT_SIGNER, 's', "Signer certificate file"},
|
||||
{"chain", OPT_CHAIN, '<', "File with signer CA chain"},
|
||||
{"CApath", OPT_CAPATH, '/', "Path to trusted CA files"},
|
||||
{"CAfile", OPT_CAFILE, '<', "File with trusted CA certs"},
|
||||
{"CAstore", OPT_CASTORE, ':', "URI to trusted CA store"},
|
||||
{"untrusted", OPT_UNTRUSTED, '<', "File with untrusted certs"},
|
||||
{"token_in", OPT_TOKEN_IN, '-', "Input is a PKCS#7 file"},
|
||||
{"token_out", OPT_TOKEN_OUT, '-', "Output is a PKCS#7 file"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"", OPT_MD, '-', "Any supported digest"},
|
||||
|
||||
OPT_SECTION("Query"),
|
||||
{"query", OPT_QUERY, '-', "Generate a TS query"},
|
||||
{"data", OPT_DATA, '<', "File to hash"},
|
||||
{"digest", OPT_DIGEST, 's', "Digest (as a hex string)"},
|
||||
{"queryfile", OPT_QUERYFILE, '<', "File containing a TS query"},
|
||||
{"cert", OPT_CERT, '-', "Put cert request into query"},
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
|
||||
OPT_SECTION("Verify"),
|
||||
{"verify", OPT_VERIFY, '-', "Verify a TS response"},
|
||||
{"reply", OPT_REPLY, '-', "Generate a TS reply"},
|
||||
{"tspolicy", OPT_TSPOLICY, 's', "Policy OID to use"},
|
||||
{"no_nonce", OPT_NO_NONCE, '-', "Do not include a nonce"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"text", OPT_TEXT, '-', "Output text (not DER)"},
|
||||
|
||||
OPT_R_OPTIONS,
|
||||
OPT_V_OPTIONS,
|
||||
{OPT_HELP_STR, 1, '-', "\n"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
@@ -127,26 +134,26 @@ const OPTIONS ts_options[] = {
|
||||
* This command is so complex, special help is needed.
|
||||
*/
|
||||
static char* opt_helplist[] = {
|
||||
"",
|
||||
"Typical uses:",
|
||||
"ts -query [-rand file...] [-config file] [-data file]",
|
||||
" [-digest hexstring] [-tspolicy oid] [-no_nonce] [-cert]",
|
||||
" [-in file] [-out file] [-text]",
|
||||
" or",
|
||||
"ts -reply [-config file] [-section tsa_section]",
|
||||
" [-queryfile file] [-passin password]",
|
||||
" [-signer tsa_cert.pem] [-inkey private_key.pem]",
|
||||
" [-chain certs_file.pem] [-tspolicy oid]",
|
||||
" [-in file] [-token_in] [-out file] [-token_out]",
|
||||
" openssl ts -query [-rand file...] [-config file] [-data file]",
|
||||
" [-digest hexstring] [-tspolicy oid] [-no_nonce] [-cert]",
|
||||
" [-in file] [-out file] [-text]",
|
||||
"",
|
||||
" openssl ts -reply [-config file] [-section tsa_section]",
|
||||
" [-queryfile file] [-passin password]",
|
||||
" [-signer tsa_cert.pem] [-inkey private_key.pem]",
|
||||
" [-chain certs_file.pem] [-tspolicy oid]",
|
||||
" [-in file] [-token_in] [-out file] [-token_out]",
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
" [-text] [-engine id]",
|
||||
" [-text] [-engine id]",
|
||||
# else
|
||||
" [-text]",
|
||||
" [-text]",
|
||||
# endif
|
||||
" or",
|
||||
"ts -verify -CApath dir -CAfile file.pem -untrusted file.pem",
|
||||
" [-data file] [-digest hexstring]",
|
||||
" [-queryfile file] -in file [-token_in]",
|
||||
" [[options specific to 'ts -verify']]",
|
||||
"",
|
||||
" openssl ts -verify -CApath dir -CAfile file.pem -CAstore uri",
|
||||
" -untrusted file.pem [-data file] [-digest hexstring]",
|
||||
" [-queryfile file] -in file [-token_in] ...",
|
||||
NULL,
|
||||
};
|
||||
|
||||
@@ -161,6 +168,7 @@ int ts_main(int argc, char **argv)
|
||||
char *data = NULL, *digest = NULL, *policy = NULL;
|
||||
char *in = NULL, *out = NULL, *queryfile = NULL, *passin = NULL;
|
||||
char *inkey = NULL, *signer = NULL, *chain = NULL, *CApath = NULL;
|
||||
char *CAstore = NULL;
|
||||
const EVP_MD *md = NULL;
|
||||
OPTION_CHOICE o, mode = OPT_ERR;
|
||||
int ret = 1, no_nonce = 0, cert = 0, text = 0;
|
||||
@@ -256,6 +264,9 @@ int ts_main(int argc, char **argv)
|
||||
case OPT_CAFILE:
|
||||
CAfile = opt_arg();
|
||||
break;
|
||||
case OPT_CASTORE:
|
||||
CAstore = opt_arg();
|
||||
break;
|
||||
case OPT_UNTRUSTED:
|
||||
untrusted = opt_arg();
|
||||
break;
|
||||
@@ -282,7 +293,8 @@ int ts_main(int argc, char **argv)
|
||||
goto end;
|
||||
}
|
||||
|
||||
conf = load_config_file(configfile);
|
||||
if ((conf = load_config_file(configfile)) == NULL)
|
||||
goto end;
|
||||
if (configfile != default_config_file && !app_load_modules(conf))
|
||||
goto end;
|
||||
|
||||
@@ -311,7 +323,7 @@ int ts_main(int argc, char **argv)
|
||||
if ((in == NULL) || !EXACTLY_ONE(queryfile, data, digest))
|
||||
goto opthelp;
|
||||
ret = !verify_command(data, digest, queryfile, in, token_in,
|
||||
CApath, CAfile, untrusted,
|
||||
CApath, CAfile, CAstore, untrusted,
|
||||
vpmtouched ? vpm : NULL);
|
||||
} else {
|
||||
goto opthelp;
|
||||
@@ -820,7 +832,8 @@ static int save_ts_serial(const char *serialfile, ASN1_INTEGER *serial)
|
||||
|
||||
static int verify_command(const char *data, const char *digest, const char *queryfile,
|
||||
const char *in, int token_in,
|
||||
const char *CApath, const char *CAfile, const char *untrusted,
|
||||
const char *CApath, const char *CAfile,
|
||||
const char *CAstore, const char *untrusted,
|
||||
X509_VERIFY_PARAM *vpm)
|
||||
{
|
||||
BIO *in_bio = NULL;
|
||||
@@ -840,7 +853,7 @@ static int verify_command(const char *data, const char *digest, const char *quer
|
||||
}
|
||||
|
||||
if ((verify_ctx = create_verify_ctx(data, digest, queryfile,
|
||||
CApath, CAfile, untrusted,
|
||||
CApath, CAfile, CAstore, untrusted,
|
||||
vpm)) == NULL)
|
||||
goto end;
|
||||
|
||||
@@ -867,6 +880,7 @@ static int verify_command(const char *data, const char *digest, const char *quer
|
||||
static TS_VERIFY_CTX *create_verify_ctx(const char *data, const char *digest,
|
||||
const char *queryfile,
|
||||
const char *CApath, const char *CAfile,
|
||||
const char *CAstore,
|
||||
const char *untrusted,
|
||||
X509_VERIFY_PARAM *vpm)
|
||||
{
|
||||
@@ -915,7 +929,8 @@ static TS_VERIFY_CTX *create_verify_ctx(const char *data, const char *digest,
|
||||
TS_VERIFY_CTX_add_flags(ctx, f | TS_VFY_SIGNATURE);
|
||||
|
||||
/* Initialising the X509_STORE object. */
|
||||
if (TS_VERIFY_CTX_set_store(ctx, create_cert_store(CApath, CAfile, vpm))
|
||||
if (TS_VERIFY_CTX_set_store(ctx,
|
||||
create_cert_store(CApath, CAfile, CAstore, vpm))
|
||||
== NULL)
|
||||
goto err;
|
||||
|
||||
@@ -936,11 +951,10 @@ static TS_VERIFY_CTX *create_verify_ctx(const char *data, const char *digest,
|
||||
}
|
||||
|
||||
static X509_STORE *create_cert_store(const char *CApath, const char *CAfile,
|
||||
X509_VERIFY_PARAM *vpm)
|
||||
const char *CAstore, X509_VERIFY_PARAM *vpm)
|
||||
{
|
||||
X509_STORE *cert_ctx = NULL;
|
||||
X509_LOOKUP *lookup = NULL;
|
||||
int i;
|
||||
|
||||
cert_ctx = X509_STORE_new();
|
||||
X509_STORE_set_verify_cb(cert_ctx, verify_cb);
|
||||
@@ -950,8 +964,7 @@ static X509_STORE *create_cert_store(const char *CApath, const char *CAfile,
|
||||
BIO_printf(bio_err, "memory allocation failure\n");
|
||||
goto err;
|
||||
}
|
||||
i = X509_LOOKUP_add_dir(lookup, CApath, X509_FILETYPE_PEM);
|
||||
if (!i) {
|
||||
if (!X509_LOOKUP_add_dir(lookup, CApath, X509_FILETYPE_PEM)) {
|
||||
BIO_printf(bio_err, "Error loading directory %s\n", CApath);
|
||||
goto err;
|
||||
}
|
||||
@@ -963,13 +976,24 @@ static X509_STORE *create_cert_store(const char *CApath, const char *CAfile,
|
||||
BIO_printf(bio_err, "memory allocation failure\n");
|
||||
goto err;
|
||||
}
|
||||
i = X509_LOOKUP_load_file(lookup, CAfile, X509_FILETYPE_PEM);
|
||||
if (!i) {
|
||||
if (!X509_LOOKUP_load_file(lookup, CAfile, X509_FILETYPE_PEM)) {
|
||||
BIO_printf(bio_err, "Error loading file %s\n", CAfile);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
if (CAstore != NULL) {
|
||||
lookup = X509_STORE_add_lookup(cert_ctx, X509_LOOKUP_store());
|
||||
if (lookup == NULL) {
|
||||
BIO_printf(bio_err, "memory allocation failure\n");
|
||||
goto err;
|
||||
}
|
||||
if (!X509_LOOKUP_load_store(lookup, CAstore)) {
|
||||
BIO_printf(bio_err, "Error loading store URI %s\n", CAstore);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
if (vpm != NULL)
|
||||
X509_STORE_set1_param(cert_ctx, vpm);
|
||||
|
||||
|
||||
+40
-20
@@ -27,24 +27,35 @@ static int v_verbose = 0, vflags = 0;
|
||||
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_ENGINE, OPT_CAPATH, OPT_CAFILE, OPT_NOCAPATH, OPT_NOCAFILE,
|
||||
OPT_ENGINE, OPT_CAPATH, OPT_CAFILE, OPT_CASTORE,
|
||||
OPT_NOCAPATH, OPT_NOCAFILE, OPT_NOCASTORE,
|
||||
OPT_UNTRUSTED, OPT_TRUSTED, OPT_CRLFILE, OPT_CRL_DOWNLOAD, OPT_SHOW_CHAIN,
|
||||
OPT_V_ENUM, OPT_NAMEOPT,
|
||||
OPT_VERBOSE, OPT_SM2ID, OPT_SM2HEXID
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS verify_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] cert.pem...\n"},
|
||||
{OPT_HELP_STR, 1, '-', "Valid options are:\n"},
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] [cert...]\n"},
|
||||
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
{"verbose", OPT_VERBOSE, '-',
|
||||
"Print extra information about the operations being performed."},
|
||||
{"nameopt", OPT_NAMEOPT, 's', "Various certificate name options"},
|
||||
|
||||
OPT_SECTION("Certificate chain"),
|
||||
{"CApath", OPT_CAPATH, '/', "A directory of trusted certificates"},
|
||||
{"CAfile", OPT_CAFILE, '<', "A file of trusted certificates"},
|
||||
{"CAstore", OPT_CASTORE, ':', "URI to a store of trusted certificates"},
|
||||
{"no-CAfile", OPT_NOCAFILE, '-',
|
||||
"Do not load the default certificates file"},
|
||||
{"no-CApath", OPT_NOCAPATH, '-',
|
||||
"Do not load certificates from the default certificates directory"},
|
||||
{"no-CAstore", OPT_NOCAPATH, '-',
|
||||
"Do not load certificates from the default certificates store"},
|
||||
{"untrusted", OPT_UNTRUSTED, '<', "A file of untrusted certificates"},
|
||||
{"trusted", OPT_TRUSTED, '<', "A file of trusted certificates"},
|
||||
{"CRLfile", OPT_CRLFILE, '<',
|
||||
@@ -53,17 +64,17 @@ const OPTIONS verify_options[] = {
|
||||
"Attempt to download CRL information for this certificate"},
|
||||
{"show_chain", OPT_SHOW_CHAIN, '-',
|
||||
"Display information about the certificate chain"},
|
||||
{"nameopt", OPT_NAMEOPT, 's', "Various certificate name options"},
|
||||
|
||||
OPT_V_OPTIONS,
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SM2
|
||||
{"sm2-id", OPT_SM2ID, 's',
|
||||
"Specify an ID string to verify an SM2 certificate"},
|
||||
{"sm2-hex-id", OPT_SM2HEXID, 's',
|
||||
"Specify a hex ID string to verify an SM2 certificate"},
|
||||
#endif
|
||||
|
||||
OPT_PARAMETERS(),
|
||||
{"cert", 0, 0, "Certificate(s) to verify (optional; stdin used otherwise)"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
@@ -74,8 +85,8 @@ int verify_main(int argc, char **argv)
|
||||
STACK_OF(X509_CRL) *crls = NULL;
|
||||
X509_STORE *store = NULL;
|
||||
X509_VERIFY_PARAM *vpm = NULL;
|
||||
const char *prog, *CApath = NULL, *CAfile = NULL;
|
||||
int noCApath = 0, noCAfile = 0;
|
||||
const char *prog, *CApath = NULL, *CAfile = NULL, *CAstore = NULL;
|
||||
int noCApath = 0, noCAfile = 0, noCAstore = 0;
|
||||
int vpmtouched = 0, crl_download = 0, show_chain = 0, i = 0, ret = 1;
|
||||
OPTION_CHOICE o;
|
||||
unsigned char *sm2_id = NULL;
|
||||
@@ -94,20 +105,20 @@ int verify_main(int argc, char **argv)
|
||||
goto end;
|
||||
case OPT_HELP:
|
||||
opt_help(verify_options);
|
||||
BIO_printf(bio_err, "Recognized usages:\n");
|
||||
BIO_printf(bio_err, "\nRecognized certificate chain purposes:\n");
|
||||
for (i = 0; i < X509_PURPOSE_get_count(); i++) {
|
||||
X509_PURPOSE *ptmp;
|
||||
ptmp = X509_PURPOSE_get0(i);
|
||||
BIO_printf(bio_err, "\t%-10s\t%s\n",
|
||||
X509_PURPOSE *ptmp = X509_PURPOSE_get0(i);
|
||||
|
||||
BIO_printf(bio_err, " %-15s %s\n",
|
||||
X509_PURPOSE_get0_sname(ptmp),
|
||||
X509_PURPOSE_get0_name(ptmp));
|
||||
}
|
||||
|
||||
BIO_printf(bio_err, "Recognized verify names:\n");
|
||||
BIO_printf(bio_err, "Recognized certificate policy names:\n");
|
||||
for (i = 0; i < X509_VERIFY_PARAM_get_count(); i++) {
|
||||
const X509_VERIFY_PARAM *vptmp;
|
||||
vptmp = X509_VERIFY_PARAM_get0(i);
|
||||
BIO_printf(bio_err, "\t%-10s\n",
|
||||
const X509_VERIFY_PARAM *vptmp = X509_VERIFY_PARAM_get0(i);
|
||||
|
||||
BIO_printf(bio_err, " %s\n",
|
||||
X509_VERIFY_PARAM_get0_name(vptmp));
|
||||
}
|
||||
ret = 0;
|
||||
@@ -123,12 +134,18 @@ int verify_main(int argc, char **argv)
|
||||
case OPT_CAFILE:
|
||||
CAfile = opt_arg();
|
||||
break;
|
||||
case OPT_CASTORE:
|
||||
CAstore = opt_arg();
|
||||
break;
|
||||
case OPT_NOCAPATH:
|
||||
noCApath = 1;
|
||||
break;
|
||||
case OPT_NOCAFILE:
|
||||
noCAfile = 1;
|
||||
break;
|
||||
case OPT_NOCASTORE:
|
||||
noCAstore = 1;
|
||||
break;
|
||||
case OPT_UNTRUSTED:
|
||||
/* Zero or more times */
|
||||
if (!load_certs(opt_arg(), &untrusted, FORMAT_PEM, NULL,
|
||||
@@ -139,6 +156,7 @@ int verify_main(int argc, char **argv)
|
||||
/* Zero or more times */
|
||||
noCAfile = 1;
|
||||
noCApath = 1;
|
||||
noCAstore = 1;
|
||||
if (!load_certs(opt_arg(), &trusted, FORMAT_PEM, NULL,
|
||||
"trusted certificates"))
|
||||
goto end;
|
||||
@@ -195,14 +213,16 @@ int verify_main(int argc, char **argv)
|
||||
}
|
||||
argc = opt_num_rest();
|
||||
argv = opt_rest();
|
||||
if (trusted != NULL && (CAfile || CApath)) {
|
||||
if (trusted != NULL
|
||||
&& (CAfile != NULL || CApath != NULL || CAstore != NULL)) {
|
||||
BIO_printf(bio_err,
|
||||
"%s: Cannot use -trusted with -CAfile or -CApath\n",
|
||||
"%s: Cannot use -trusted with -CAfile, -CApath or -CAstore\n",
|
||||
prog);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if ((store = setup_verify(CAfile, CApath, noCAfile, noCApath)) == NULL)
|
||||
if ((store = setup_verify(CAfile, noCAfile, CApath, noCApath,
|
||||
CAstore, noCAstore)) == NULL)
|
||||
goto end;
|
||||
X509_STORE_set_verify_cb(store, cb);
|
||||
|
||||
|
||||
+3
-12
@@ -18,9 +18,6 @@
|
||||
#ifndef OPENSSL_NO_MD2
|
||||
# include <openssl/md2.h>
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC4
|
||||
# include <openssl/rc4.h>
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DES
|
||||
# include <openssl/des.h>
|
||||
#endif
|
||||
@@ -37,7 +34,10 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS version_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"a", OPT_A, '-', "Show all data"},
|
||||
{"b", OPT_B, '-', "Show build date"},
|
||||
{"d", OPT_D, '-', "Show configuration directory"},
|
||||
@@ -126,20 +126,11 @@ opthelp:
|
||||
if (options) {
|
||||
printf("options: ");
|
||||
printf(" %s", BN_options());
|
||||
#ifndef OPENSSL_NO_MD2
|
||||
printf(" %s", MD2_options());
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC4
|
||||
printf(" %s", RC4_options());
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DES
|
||||
printf(" %s", DES_options());
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_IDEA
|
||||
printf(" %s", IDEA_options());
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_BF
|
||||
printf(" %s", BF_options());
|
||||
#endif
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
+45
-38
@@ -65,15 +65,23 @@ typedef enum OPTION_choice {
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS x509_options[] = {
|
||||
OPT_SECTION("General"),
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
|
||||
{"inform", OPT_INFORM, 'f',
|
||||
"Input format - default PEM (one of DER or PEM)"},
|
||||
{"in", OPT_IN, '<', "Input file - default stdin"},
|
||||
{"passin", OPT_PASSIN, 's', "Private key password/pass-phrase source"},
|
||||
{"outform", OPT_OUTFORM, 'f',
|
||||
"Output format - default PEM (one of DER or PEM)"},
|
||||
{"out", OPT_OUT, '>', "Output file - default stdout"},
|
||||
{"keyform", OPT_KEYFORM, 'F', "Private key format - default PEM"},
|
||||
{"passin", OPT_PASSIN, 's', "Private key password/pass-phrase source"},
|
||||
{"keyform", OPT_KEYFORM, 'E', "Private key format - default PEM"},
|
||||
{"req", OPT_REQ, '-', "Input is a certificate request, sign and output"},
|
||||
|
||||
OPT_SECTION("Output"),
|
||||
{"serial", OPT_SERIAL, '-', "Print serial number value"},
|
||||
{"subject_hash", OPT_HASH, '-', "Print subject hash value"},
|
||||
{"issuer_hash", OPT_ISSUER_HASH, '-', "Print issuer hash value"},
|
||||
@@ -81,21 +89,37 @@ const OPTIONS x509_options[] = {
|
||||
{"subject", OPT_SUBJECT, '-', "Print subject DN"},
|
||||
{"issuer", OPT_ISSUER, '-', "Print issuer DN"},
|
||||
{"email", OPT_EMAIL, '-', "Print email address(es)"},
|
||||
{"startdate", OPT_STARTDATE, '-', "Set notBefore field"},
|
||||
{"enddate", OPT_ENDDATE, '-', "Set notAfter field"},
|
||||
{"purpose", OPT_PURPOSE, '-', "Print out certificate purposes"},
|
||||
{"dates", OPT_DATES, '-', "Both Before and After dates"},
|
||||
{"modulus", OPT_MODULUS, '-', "Print the RSA key modulus"},
|
||||
{"pubkey", OPT_PUBKEY, '-', "Output the public key"},
|
||||
{"fingerprint", OPT_FINGERPRINT, '-',
|
||||
"Print the certificate fingerprint"},
|
||||
{"fingerprint", OPT_FINGERPRINT, '-', "Print the certificate fingerprint"},
|
||||
{"alias", OPT_ALIAS, '-', "Output certificate alias"},
|
||||
{"noout", OPT_NOOUT, '-', "No output, just status"},
|
||||
{"nocert", OPT_NOCERT, '-', "No certificate output"},
|
||||
{"ocspid", OPT_OCSPID, '-',
|
||||
"Print OCSP hash values for the subject name and public key"},
|
||||
{"ocsp_uri", OPT_OCSP_URI, '-', "Print OCSP Responder URL(s)"},
|
||||
{"nocert", OPT_NOCERT, '-', "No certificate output"},
|
||||
{"trustout", OPT_TRUSTOUT, '-', "Output a trusted certificate"},
|
||||
{"x509toreq", OPT_X509TOREQ, '-',
|
||||
"Output a certification request object"},
|
||||
{"checkend", OPT_CHECKEND, 'M',
|
||||
"Check whether the cert expires in the next arg seconds"},
|
||||
{OPT_MORE_STR, 1, 1, "Exit 1 if so, 0 if not"},
|
||||
{"text", OPT_TEXT, '-', "Print the certificate in text form"},
|
||||
{"ext", OPT_EXT, 's', "Print various X509V3 extensions"},
|
||||
{"C", OPT_C, '-', "Print out C code forms"},
|
||||
#ifndef OPENSSL_NO_MD5
|
||||
{"subject_hash_old", OPT_SUBJECT_HASH_OLD, '-',
|
||||
"Print old-style (MD5) issuer hash value"},
|
||||
{"issuer_hash_old", OPT_ISSUER_HASH_OLD, '-',
|
||||
"Print old-style (MD5) subject hash value"},
|
||||
#endif
|
||||
{"nameopt", OPT_NAMEOPT, 's', "Various certificate name options"},
|
||||
|
||||
OPT_SECTION("Certificate"),
|
||||
{"startdate", OPT_STARTDATE, '-', "Set notBefore field"},
|
||||
{"enddate", OPT_ENDDATE, '-', "Set notAfter field"},
|
||||
{"dates", OPT_DATES, '-', "Both Before and After dates"},
|
||||
{"clrtrust", OPT_CLRTRUST, '-', "Clear all trusted purposes"},
|
||||
{"clrext", OPT_CLREXT, '-', "Clear all certificate extensions"},
|
||||
{"addtrust", OPT_ADDTRUST, 's', "Trust certificate for a given purpose"},
|
||||
@@ -104,51 +128,34 @@ const OPTIONS x509_options[] = {
|
||||
{"setalias", OPT_SETALIAS, 's', "Set certificate alias"},
|
||||
{"days", OPT_DAYS, 'n',
|
||||
"How long till expiry of a signed certificate - def 30 days"},
|
||||
{"checkend", OPT_CHECKEND, 'M',
|
||||
"Check whether the cert expires in the next arg seconds"},
|
||||
{OPT_MORE_STR, 1, 1, "Exit 1 if so, 0 if not"},
|
||||
{"signkey", OPT_SIGNKEY, '<', "Self sign cert with arg"},
|
||||
{"x509toreq", OPT_X509TOREQ, '-',
|
||||
"Output a certification request object"},
|
||||
{"req", OPT_REQ, '-', "Input is a certificate request, sign and output"},
|
||||
{"CA", OPT_CA, '<', "Set the CA certificate, must be PEM format"},
|
||||
{"CAkey", OPT_CAKEY, 's',
|
||||
"The CA key, must be PEM format; if not in CAfile"},
|
||||
{"CAcreateserial", OPT_CACREATESERIAL, '-',
|
||||
"Create serial number file if it does not exist"},
|
||||
{"CAserial", OPT_CASERIAL, 's', "Serial file"},
|
||||
{"set_serial", OPT_SET_SERIAL, 's', "Serial number to use"},
|
||||
{"text", OPT_TEXT, '-', "Print the certificate in text form"},
|
||||
{"ext", OPT_EXT, 's', "Print various X509V3 extensions"},
|
||||
{"C", OPT_C, '-', "Print out C code forms"},
|
||||
{"extfile", OPT_EXTFILE, '<', "File with X509V3 extensions to add"},
|
||||
OPT_R_OPTIONS,
|
||||
{"extensions", OPT_EXTENSIONS, 's', "Section from config file to use"},
|
||||
{"nameopt", OPT_NAMEOPT, 's', "Various certificate name options"},
|
||||
{"certopt", OPT_CERTOPT, 's', "Various certificate text options"},
|
||||
{"checkhost", OPT_CHECKHOST, 's', "Check certificate matches host"},
|
||||
{"checkemail", OPT_CHECKEMAIL, 's', "Check certificate matches email"},
|
||||
{"checkip", OPT_CHECKIP, 's', "Check certificate matches ipaddr"},
|
||||
{"force_pubkey", OPT_FORCE_PUBKEY, '<', "Force the key to put inside certificate"},
|
||||
{"subj", OPT_SUBJ, 's', "Set or override certificate subject (and issuer)"},
|
||||
|
||||
OPT_SECTION("CA"),
|
||||
{"CA", OPT_CA, '<', "Set the CA certificate, must be PEM format"},
|
||||
{"CAkey", OPT_CAKEY, 's',
|
||||
"The CA key, must be PEM format; if not in CAfile"},
|
||||
{"extfile", OPT_EXTFILE, '<', "File with X509V3 extensions to add"},
|
||||
OPT_R_OPTIONS,
|
||||
{"CAform", OPT_CAFORM, 'F', "CA format - default PEM"},
|
||||
{"CAkeyform", OPT_CAKEYFORM, 'f', "CA key format - default PEM"},
|
||||
{"sigopt", OPT_SIGOPT, 's', "Signature parameter in n:v form"},
|
||||
{"CAcreateserial", OPT_CACREATESERIAL, '-',
|
||||
"Create serial number file if it does not exist"},
|
||||
{"CAserial", OPT_CASERIAL, 's', "Serial file"},
|
||||
{"new", OPT_NEW, '-', "Generate a certificate from scratch"},
|
||||
{"force_pubkey", OPT_FORCE_PUBKEY, '<', "Force the key to put inside certificate"},
|
||||
{"subj", OPT_SUBJ, 's', "Set or override certificate subject (and issuer)"},
|
||||
{"next_serial", OPT_NEXT_SERIAL, '-', "Increment current certificate serial number"},
|
||||
{"clrreject", OPT_CLRREJECT, '-',
|
||||
"Clears all the prohibited or rejected uses of the certificate"},
|
||||
{"badsig", OPT_BADSIG, '-', "Corrupt last byte of certificate signature (for test)"},
|
||||
{"", OPT_MD, '-', "Any supported digest"},
|
||||
#ifndef OPENSSL_NO_MD5
|
||||
{"subject_hash_old", OPT_SUBJECT_HASH_OLD, '-',
|
||||
"Print old-style (MD5) issuer hash value"},
|
||||
{"issuer_hash_old", OPT_ISSUER_HASH_OLD, '-',
|
||||
"Print old-style (MD5) subject hash value"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
{"preserve_dates", OPT_PRESERVE_DATES, '-', "preserve existing dates when signing"},
|
||||
{NULL}
|
||||
};
|
||||
@@ -224,7 +231,7 @@ int x509_main(int argc, char **argv)
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_KEYFORM:
|
||||
if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &keyformat))
|
||||
if (!opt_format(opt_arg(), OPT_FMT_PDE, &keyformat))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_CAFORM:
|
||||
|
||||
Reference in New Issue
Block a user