2015-01-22 03:40:55 +00:00
|
|
|
/*
|
2018-02-13 12:51:29 +00:00
|
|
|
* Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved.
|
2006-04-07 19:33:28 +00:00
|
|
|
*
|
2018-12-06 12:00:26 +00:00
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-05-17 18:18:30 +00:00
|
|
|
* 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
|
2006-04-07 19:33:28 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "apps.h"
|
2018-01-31 10:13:10 +00:00
|
|
|
#include "progs.h"
|
2006-04-07 19:33:28 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <openssl/err.h>
|
|
|
|
#include <openssl/pem.h>
|
|
|
|
#include <openssl/evp.h>
|
2019-03-16 11:07:35 +00:00
|
|
|
#include <sys/stat.h>
|
2006-04-07 19:33:28 +00:00
|
|
|
|
2016-03-01 16:29:47 +00:00
|
|
|
#define KEY_NONE 0
|
2015-01-22 03:40:55 +00:00
|
|
|
#define KEY_PRIVKEY 1
|
|
|
|
#define KEY_PUBKEY 2
|
|
|
|
#define KEY_CERT 3
|
2006-04-07 19:33:28 +00:00
|
|
|
|
2016-03-01 16:29:47 +00:00
|
|
|
static EVP_PKEY_CTX *init_ctx(const char *kdfalg, int *pkeysize,
|
2016-02-02 05:37:41 +00:00
|
|
|
const char *keyfile, int keyform, int key_type,
|
2016-01-14 04:03:31 +00:00
|
|
|
char *passinarg, int pkey_op, ENGINE *e,
|
2019-03-07 10:37:34 +00:00
|
|
|
const int impl, int rawin, EVP_PKEY **ppkey);
|
2006-04-13 20:16:56 +00:00
|
|
|
|
2016-02-02 05:37:41 +00:00
|
|
|
static int setup_peer(EVP_PKEY_CTX *ctx, int peerform, const char *file,
|
|
|
|
ENGINE *e);
|
2006-04-07 19:33:28 +00:00
|
|
|
|
2006-04-15 18:50:56 +00:00
|
|
|
static int do_keyop(EVP_PKEY_CTX *ctx, int pkey_op,
|
2015-01-22 03:40:55 +00:00
|
|
|
unsigned char *out, size_t *poutlen,
|
2016-08-04 21:52:22 +00:00
|
|
|
const unsigned char *in, size_t inlen);
|
2006-04-15 18:50:56 +00:00
|
|
|
|
2019-01-16 08:16:28 +00:00
|
|
|
static int do_raw_keyop(int pkey_op, EVP_PKEY_CTX *ctx,
|
|
|
|
const EVP_MD *md, EVP_PKEY *pkey, BIO *in,
|
2019-03-07 10:37:34 +00:00
|
|
|
int filesize, unsigned char *sig, int siglen,
|
2019-01-16 08:16:28 +00:00
|
|
|
unsigned char **out, size_t *poutlen);
|
|
|
|
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
typedef enum OPTION_choice {
|
|
|
|
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
2016-01-14 04:03:31 +00:00
|
|
|
OPT_ENGINE, OPT_ENGINE_IMPL, OPT_IN, OPT_OUT,
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
OPT_PUBIN, OPT_CERTIN, OPT_ASN1PARSE, OPT_HEXDUMP, OPT_SIGN,
|
|
|
|
OPT_VERIFY, OPT_VERIFYRECOVER, OPT_REV, OPT_ENCRYPT, OPT_DECRYPT,
|
|
|
|
OPT_DERIVE, OPT_SIGFILE, OPT_INKEY, OPT_PEERKEY, OPT_PASSIN,
|
2017-08-01 17:38:32 +00:00
|
|
|
OPT_PEERFORM, OPT_KEYFORM, OPT_PKEYOPT, OPT_PKEYOPT_PASSIN, OPT_KDF,
|
2019-01-16 08:16:28 +00:00
|
|
|
OPT_KDFLEN, OPT_R_ENUM,
|
|
|
|
OPT_RAWIN, OPT_DIGEST
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
} OPTION_CHOICE;
|
|
|
|
|
2016-03-13 13:07:50 +00:00
|
|
|
const OPTIONS pkeyutl_options[] = {
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
{"help", OPT_HELP, '-', "Display this summary"},
|
2016-02-08 04:14:12 +00:00
|
|
|
{"in", OPT_IN, '<', "Input file - default stdin"},
|
2019-01-16 08:16:28 +00:00
|
|
|
{"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"},
|
2016-02-08 04:14:12 +00:00
|
|
|
{"out", OPT_OUT, '>', "Output file - default stdout"},
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
{"pubin", OPT_PUBIN, '-', "Input is a public key"},
|
|
|
|
{"certin", OPT_CERTIN, '-', "Input is a cert with a public key"},
|
2016-02-02 05:37:41 +00:00
|
|
|
{"asn1parse", OPT_ASN1PARSE, '-', "asn1parse the output data"},
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
{"hexdump", OPT_HEXDUMP, '-', "Hex dump output"},
|
2016-02-08 04:14:12 +00:00
|
|
|
{"sign", OPT_SIGN, '-', "Sign input data with private key"},
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
{"verify", OPT_VERIFY, '-', "Verify with public key"},
|
|
|
|
{"verifyrecover", OPT_VERIFYRECOVER, '-',
|
|
|
|
"Verify with public key, recover original data"},
|
2016-02-08 04:14:12 +00:00
|
|
|
{"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"},
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
{"derive", OPT_DERIVE, '-', "Derive shared secret"},
|
2016-03-01 16:29:47 +00:00
|
|
|
{"kdf", OPT_KDF, 's', "Use KDF algorithm"},
|
|
|
|
{"kdflen", OPT_KDFLEN, 'p', "KDF algorithm output length"},
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
{"sigfile", OPT_SIGFILE, '<', "Signature file (verify operation only)"},
|
2016-02-08 04:14:12 +00:00
|
|
|
{"inkey", OPT_INKEY, 's', "Input private key file"},
|
2016-02-02 05:37:41 +00:00
|
|
|
{"peerkey", OPT_PEERKEY, 's', "Peer key file used in key derivation"},
|
2016-03-20 20:14:10 +00:00
|
|
|
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
2016-02-02 05:37:41 +00:00
|
|
|
{"peerform", OPT_PEERFORM, 'E', "Peer key format - default PEM"},
|
|
|
|
{"keyform", OPT_KEYFORM, 'E', "Private key format - default PEM"},
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
{"pkeyopt", OPT_PKEYOPT, 's', "Public key options as opt:value"},
|
2017-08-01 17:38:32 +00:00
|
|
|
{"pkeyopt_passin", OPT_PKEYOPT_PASSIN, 's',
|
|
|
|
"Public key option that is read as a passphrase argument opt:passphrase"},
|
2017-07-05 14:58:48 +00:00
|
|
|
OPT_R_OPTIONS,
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
#ifndef OPENSSL_NO_ENGINE
|
|
|
|
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
2016-02-08 04:14:12 +00:00
|
|
|
{"engine_impl", OPT_ENGINE_IMPL, '-',
|
|
|
|
"Also use engine given by -engine for crypto operations"},
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
#endif
|
|
|
|
{NULL}
|
|
|
|
};
|
2006-04-07 19:33:28 +00:00
|
|
|
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
int pkeyutl_main(int argc, char **argv)
|
2006-04-07 19:33:28 +00:00
|
|
|
{
|
2015-01-22 03:40:55 +00:00
|
|
|
BIO *in = NULL, *out = NULL;
|
|
|
|
ENGINE *e = NULL;
|
|
|
|
EVP_PKEY_CTX *ctx = NULL;
|
2019-01-16 08:16:28 +00:00
|
|
|
EVP_PKEY *pkey = NULL;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
char *infile = NULL, *outfile = NULL, *sigfile = NULL, *passinarg = NULL;
|
|
|
|
char hexdump = 0, asn1parse = 0, rev = 0, *prog;
|
2015-01-22 03:40:55 +00:00
|
|
|
unsigned char *buf_in = NULL, *buf_out = NULL, *sig = NULL;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
OPTION_CHOICE o;
|
2017-07-21 20:19:35 +00:00
|
|
|
int buf_inlen = 0, siglen = -1, keyform = FORMAT_PEM, peerform = FORMAT_PEM;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
int keysize = -1, pkey_op = EVP_PKEY_OP_SIGN, key_type = KEY_PRIVKEY;
|
2016-01-14 04:03:31 +00:00
|
|
|
int engine_impl = 0;
|
2015-01-22 03:40:55 +00:00
|
|
|
int ret = 1, rv = -1;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
size_t buf_outlen;
|
2016-02-02 05:37:41 +00:00
|
|
|
const char *inkey = NULL;
|
|
|
|
const char *peerkey = NULL;
|
2016-03-01 16:29:47 +00:00
|
|
|
const char *kdfalg = NULL;
|
|
|
|
int kdflen = 0;
|
2016-02-02 05:37:41 +00:00
|
|
|
STACK_OF(OPENSSL_STRING) *pkeyopts = NULL;
|
2017-08-01 17:38:32 +00:00
|
|
|
STACK_OF(OPENSSL_STRING) *pkeyopts_passin = NULL;
|
2019-01-16 08:16:28 +00:00
|
|
|
int rawin = 0;
|
|
|
|
const EVP_MD *md = NULL;
|
2019-03-07 10:37:34 +00:00
|
|
|
int filesize = -1;
|
2015-01-22 03:40:55 +00:00
|
|
|
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
prog = opt_init(argc, argv, pkeyutl_options);
|
|
|
|
while ((o = opt_next()) != OPT_EOF) {
|
|
|
|
switch (o) {
|
|
|
|
case OPT_EOF:
|
|
|
|
case OPT_ERR:
|
|
|
|
opthelp:
|
|
|
|
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
|
|
|
goto end;
|
|
|
|
case OPT_HELP:
|
|
|
|
opt_help(pkeyutl_options);
|
|
|
|
ret = 0;
|
|
|
|
goto end;
|
|
|
|
case OPT_IN:
|
|
|
|
infile = opt_arg();
|
|
|
|
break;
|
|
|
|
case OPT_OUT:
|
|
|
|
outfile = opt_arg();
|
|
|
|
break;
|
|
|
|
case OPT_SIGFILE:
|
|
|
|
sigfile = opt_arg();
|
|
|
|
break;
|
2016-01-14 04:03:31 +00:00
|
|
|
case OPT_ENGINE_IMPL:
|
|
|
|
engine_impl = 1;
|
|
|
|
break;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
case OPT_INKEY:
|
2016-02-02 05:37:41 +00:00
|
|
|
inkey = opt_arg();
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
break;
|
|
|
|
case OPT_PEERKEY:
|
2016-02-02 05:37:41 +00:00
|
|
|
peerkey = opt_arg();
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
break;
|
|
|
|
case OPT_PASSIN:
|
|
|
|
passinarg = opt_arg();
|
|
|
|
break;
|
|
|
|
case OPT_PEERFORM:
|
2016-02-02 05:37:41 +00:00
|
|
|
if (!opt_format(opt_arg(), OPT_FMT_PDE, &peerform))
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
goto opthelp;
|
|
|
|
break;
|
|
|
|
case OPT_KEYFORM:
|
2016-02-02 05:37:41 +00:00
|
|
|
if (!opt_format(opt_arg(), OPT_FMT_PDE, &keyform))
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
goto opthelp;
|
|
|
|
break;
|
2017-07-05 14:58:48 +00:00
|
|
|
case OPT_R_CASES:
|
|
|
|
if (!opt_rand(o))
|
|
|
|
goto end;
|
|
|
|
break;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
case OPT_ENGINE:
|
|
|
|
e = setup_engine(opt_arg(), 0);
|
|
|
|
break;
|
|
|
|
case OPT_PUBIN:
|
2015-01-22 03:40:55 +00:00
|
|
|
key_type = KEY_PUBKEY;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
break;
|
|
|
|
case OPT_CERTIN:
|
2015-01-22 03:40:55 +00:00
|
|
|
key_type = KEY_CERT;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
break;
|
|
|
|
case OPT_ASN1PARSE:
|
2015-01-22 03:40:55 +00:00
|
|
|
asn1parse = 1;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
break;
|
|
|
|
case OPT_HEXDUMP:
|
2015-01-22 03:40:55 +00:00
|
|
|
hexdump = 1;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
break;
|
|
|
|
case OPT_SIGN:
|
2015-01-22 03:40:55 +00:00
|
|
|
pkey_op = EVP_PKEY_OP_SIGN;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
break;
|
|
|
|
case OPT_VERIFY:
|
2015-01-22 03:40:55 +00:00
|
|
|
pkey_op = EVP_PKEY_OP_VERIFY;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
break;
|
|
|
|
case OPT_VERIFYRECOVER:
|
2015-01-22 03:40:55 +00:00
|
|
|
pkey_op = EVP_PKEY_OP_VERIFYRECOVER;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
break;
|
|
|
|
case OPT_ENCRYPT:
|
2015-01-22 03:40:55 +00:00
|
|
|
pkey_op = EVP_PKEY_OP_ENCRYPT;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
break;
|
|
|
|
case OPT_DECRYPT:
|
2015-01-22 03:40:55 +00:00
|
|
|
pkey_op = EVP_PKEY_OP_DECRYPT;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
break;
|
|
|
|
case OPT_DERIVE:
|
2015-01-22 03:40:55 +00:00
|
|
|
pkey_op = EVP_PKEY_OP_DERIVE;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
break;
|
2016-03-01 16:29:47 +00:00
|
|
|
case OPT_KDF:
|
|
|
|
pkey_op = EVP_PKEY_OP_DERIVE;
|
|
|
|
key_type = KEY_NONE;
|
|
|
|
kdfalg = opt_arg();
|
|
|
|
break;
|
|
|
|
case OPT_KDFLEN:
|
|
|
|
kdflen = atoi(opt_arg());
|
|
|
|
break;
|
2016-02-02 05:37:41 +00:00
|
|
|
case OPT_REV:
|
|
|
|
rev = 1;
|
|
|
|
break;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
case OPT_PKEYOPT:
|
2016-02-02 05:37:41 +00:00
|
|
|
if ((pkeyopts == NULL &&
|
|
|
|
(pkeyopts = sk_OPENSSL_STRING_new_null()) == NULL) ||
|
2016-03-01 17:22:51 +00:00
|
|
|
sk_OPENSSL_STRING_push(pkeyopts, opt_arg()) == 0) {
|
2016-02-02 05:37:41 +00:00
|
|
|
BIO_puts(bio_err, "out of memory\n");
|
2015-01-22 03:40:55 +00:00
|
|
|
goto end;
|
|
|
|
}
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
break;
|
2017-08-01 17:38:32 +00:00
|
|
|
case OPT_PKEYOPT_PASSIN:
|
|
|
|
if ((pkeyopts_passin == NULL &&
|
|
|
|
(pkeyopts_passin = sk_OPENSSL_STRING_new_null()) == NULL) ||
|
|
|
|
sk_OPENSSL_STRING_push(pkeyopts_passin, opt_arg()) == 0) {
|
|
|
|
BIO_puts(bio_err, "out of memory\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
break;
|
2019-01-16 08:16:28 +00:00
|
|
|
case OPT_RAWIN:
|
|
|
|
rawin = 1;
|
|
|
|
break;
|
|
|
|
case OPT_DIGEST:
|
|
|
|
if (!opt_md(opt_arg(), &md))
|
|
|
|
goto end;
|
|
|
|
break;
|
2015-01-22 03:40:55 +00:00
|
|
|
}
|
|
|
|
}
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
argc = opt_num_rest();
|
2016-02-14 19:45:02 +00:00
|
|
|
if (argc != 0)
|
|
|
|
goto opthelp;
|
2015-01-22 03:40:55 +00:00
|
|
|
|
2019-01-16 08:16:28 +00:00
|
|
|
if (rawin && pkey_op != EVP_PKEY_OP_SIGN && pkey_op != EVP_PKEY_OP_VERIFY) {
|
|
|
|
BIO_printf(bio_err,
|
|
|
|
"%s: -rawin can only be used with -sign or -verify\n",
|
|
|
|
prog);
|
|
|
|
goto opthelp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (md != NULL && !rawin) {
|
|
|
|
BIO_printf(bio_err,
|
|
|
|
"%s: -digest can only be used with -rawin\n",
|
|
|
|
prog);
|
|
|
|
goto opthelp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rawin && rev) {
|
|
|
|
BIO_printf(bio_err, "%s: -rev cannot be used with raw input\n",
|
|
|
|
prog);
|
|
|
|
goto opthelp;
|
|
|
|
}
|
|
|
|
|
2016-03-01 16:29:47 +00:00
|
|
|
if (kdfalg != NULL) {
|
2017-07-21 20:19:35 +00:00
|
|
|
if (kdflen == 0) {
|
|
|
|
BIO_printf(bio_err,
|
|
|
|
"%s: no KDF length given (-kdflen parameter).\n", prog);
|
2016-03-01 16:29:47 +00:00
|
|
|
goto opthelp;
|
2017-07-21 20:19:35 +00:00
|
|
|
}
|
|
|
|
} else if (inkey == NULL) {
|
|
|
|
BIO_printf(bio_err,
|
|
|
|
"%s: no private key given (-inkey parameter).\n", prog);
|
|
|
|
goto opthelp;
|
|
|
|
} else if (peerkey != NULL && pkey_op != EVP_PKEY_OP_DERIVE) {
|
|
|
|
BIO_printf(bio_err,
|
|
|
|
"%s: no peer key given (-peerkey parameter).\n", prog);
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
goto opthelp;
|
2016-03-01 16:29:47 +00:00
|
|
|
}
|
|
|
|
ctx = init_ctx(kdfalg, &keysize, inkey, keyform, key_type,
|
2019-03-07 10:37:34 +00:00
|
|
|
passinarg, pkey_op, e, engine_impl, rawin, &pkey);
|
2016-02-02 05:37:41 +00:00
|
|
|
if (ctx == NULL) {
|
|
|
|
BIO_printf(bio_err, "%s: Error initializing context\n", prog);
|
|
|
|
ERR_print_errors(bio_err);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
if (peerkey != NULL && !setup_peer(ctx, peerform, peerkey, e)) {
|
|
|
|
BIO_printf(bio_err, "%s: Error setting up peer key\n", prog);
|
|
|
|
ERR_print_errors(bio_err);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
if (pkeyopts != NULL) {
|
|
|
|
int num = sk_OPENSSL_STRING_num(pkeyopts);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < num; ++i) {
|
|
|
|
const char *opt = sk_OPENSSL_STRING_value(pkeyopts, i);
|
|
|
|
|
|
|
|
if (pkey_ctrl_string(ctx, opt) <= 0) {
|
2017-07-21 20:19:35 +00:00
|
|
|
BIO_printf(bio_err, "%s: Can't set parameter \"%s\":\n",
|
|
|
|
prog, opt);
|
2016-02-02 05:37:41 +00:00
|
|
|
ERR_print_errors(bio_err);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-08-01 17:38:32 +00:00
|
|
|
if (pkeyopts_passin != NULL) {
|
|
|
|
int num = sk_OPENSSL_STRING_num(pkeyopts_passin);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < num; i++) {
|
|
|
|
char *opt = sk_OPENSSL_STRING_value(pkeyopts_passin, i);
|
|
|
|
char *passin = strchr(opt, ':');
|
|
|
|
char *passwd;
|
|
|
|
|
|
|
|
if (passin == NULL) {
|
|
|
|
/* Get password interactively */
|
|
|
|
char passwd_buf[4096];
|
|
|
|
BIO_snprintf(passwd_buf, sizeof(passwd_buf), "Enter %s: ", opt);
|
|
|
|
EVP_read_pw_string(passwd_buf, sizeof(passwd_buf) - 1,
|
|
|
|
passwd_buf, 0);
|
|
|
|
passwd = OPENSSL_strdup(passwd_buf);
|
|
|
|
if (passwd == NULL) {
|
|
|
|
BIO_puts(bio_err, "out of memory\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Get password as a passin argument: First split option name
|
|
|
|
* and passphrase argument into two strings */
|
|
|
|
*passin = 0;
|
|
|
|
passin++;
|
|
|
|
if (app_passwd(passin, NULL, &passwd, NULL) == 0) {
|
|
|
|
BIO_printf(bio_err, "failed to get '%s'\n", opt);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (EVP_PKEY_CTX_ctrl_str(ctx, opt, passwd) <= 0) {
|
|
|
|
BIO_printf(bio_err, "%s: Can't set parameter \"%s\":\n",
|
|
|
|
prog, opt);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
OPENSSL_free(passwd);
|
|
|
|
}
|
|
|
|
}
|
2016-02-02 05:37:41 +00:00
|
|
|
|
2017-06-12 17:24:02 +00:00
|
|
|
if (sigfile != NULL && (pkey_op != EVP_PKEY_OP_VERIFY)) {
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
BIO_printf(bio_err,
|
|
|
|
"%s: Signature file specified for non verify\n", prog);
|
2015-01-22 03:40:55 +00:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2017-06-12 17:24:02 +00:00
|
|
|
if (sigfile == NULL && (pkey_op == EVP_PKEY_OP_VERIFY)) {
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
BIO_printf(bio_err,
|
|
|
|
"%s: No signature file specified for verify\n", prog);
|
2015-01-22 03:40:55 +00:00
|
|
|
goto end;
|
|
|
|
}
|
2006-04-08 22:25:47 +00:00
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
if (pkey_op != EVP_PKEY_OP_DERIVE) {
|
2015-09-04 10:49:06 +00:00
|
|
|
in = bio_open_default(infile, 'r', FORMAT_BINARY);
|
2019-03-16 11:07:35 +00:00
|
|
|
if (infile != NULL) {
|
2019-03-07 10:37:34 +00:00
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
if (stat(infile, &st) == 0 && st.st_size <= INT_MAX)
|
|
|
|
filesize = (int)st.st_size;
|
|
|
|
}
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
if (in == NULL)
|
2015-01-22 03:40:55 +00:00
|
|
|
goto end;
|
|
|
|
}
|
2015-09-04 10:49:06 +00:00
|
|
|
out = bio_open_default(outfile, 'w', FORMAT_BINARY);
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
if (out == NULL)
|
|
|
|
goto end;
|
2015-01-22 03:40:55 +00:00
|
|
|
|
2017-06-12 17:24:02 +00:00
|
|
|
if (sigfile != NULL) {
|
2015-01-22 03:40:55 +00:00
|
|
|
BIO *sigbio = BIO_new_file(sigfile, "rb");
|
2017-06-12 17:24:02 +00:00
|
|
|
|
|
|
|
if (sigbio == NULL) {
|
2015-01-22 03:40:55 +00:00
|
|
|
BIO_printf(bio_err, "Can't open signature file %s\n", sigfile);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
siglen = bio_to_mem(&sig, keysize * 10, sigbio);
|
|
|
|
BIO_free(sigbio);
|
2016-02-02 05:37:41 +00:00
|
|
|
if (siglen < 0) {
|
2015-01-22 03:40:55 +00:00
|
|
|
BIO_printf(bio_err, "Error reading signature data\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-16 08:16:28 +00:00
|
|
|
/* Raw input data is handled elsewhere */
|
|
|
|
if (in != NULL && !rawin) {
|
2015-01-22 03:40:55 +00:00
|
|
|
/* Read the input data */
|
|
|
|
buf_inlen = bio_to_mem(&buf_in, keysize * 10, in);
|
2016-02-02 05:37:41 +00:00
|
|
|
if (buf_inlen < 0) {
|
2015-01-22 03:40:55 +00:00
|
|
|
BIO_printf(bio_err, "Error reading input Data\n");
|
2018-05-17 11:53:07 +00:00
|
|
|
goto end;
|
2015-01-22 03:40:55 +00:00
|
|
|
}
|
|
|
|
if (rev) {
|
|
|
|
size_t i;
|
|
|
|
unsigned char ctmp;
|
|
|
|
size_t l = (size_t)buf_inlen;
|
|
|
|
for (i = 0; i < l / 2; i++) {
|
|
|
|
ctmp = buf_in[i];
|
|
|
|
buf_in[i] = buf_in[l - 1 - i];
|
|
|
|
buf_in[l - 1 - i] = ctmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-16 08:16:28 +00:00
|
|
|
/* Sanity check the input if the input is not raw */
|
|
|
|
if (!rawin
|
|
|
|
&& buf_inlen > EVP_MAX_MD_SIZE
|
2018-05-17 11:53:07 +00:00
|
|
|
&& (pkey_op == EVP_PKEY_OP_SIGN
|
|
|
|
|| pkey_op == EVP_PKEY_OP_VERIFY
|
|
|
|
|| pkey_op == EVP_PKEY_OP_VERIFYRECOVER)) {
|
|
|
|
BIO_printf(bio_err,
|
|
|
|
"Error: The input data looks too long to be a hash\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
if (pkey_op == EVP_PKEY_OP_VERIFY) {
|
2019-01-16 08:16:28 +00:00
|
|
|
if (rawin) {
|
2019-03-07 10:37:34 +00:00
|
|
|
rv = do_raw_keyop(pkey_op, ctx, md, pkey, in, filesize, sig, siglen,
|
2019-01-16 08:16:28 +00:00
|
|
|
NULL, 0);
|
|
|
|
} else {
|
|
|
|
rv = EVP_PKEY_verify(ctx, sig, (size_t)siglen,
|
|
|
|
buf_in, (size_t)buf_inlen);
|
|
|
|
}
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
if (rv == 1) {
|
2015-01-22 03:40:55 +00:00
|
|
|
BIO_puts(out, "Signature Verified Successfully\n");
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
ret = 0;
|
2017-06-12 17:24:02 +00:00
|
|
|
} else {
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
BIO_puts(out, "Signature Verification Failure\n");
|
2017-06-12 17:24:02 +00:00
|
|
|
}
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
goto end;
|
|
|
|
}
|
2016-03-01 16:29:47 +00:00
|
|
|
if (kdflen != 0) {
|
|
|
|
buf_outlen = kdflen;
|
|
|
|
rv = 1;
|
|
|
|
} else {
|
2019-01-16 08:16:28 +00:00
|
|
|
if (rawin) {
|
|
|
|
/* rawin allocates the buffer in do_raw_keyop() */
|
2019-03-07 10:37:34 +00:00
|
|
|
rv = do_raw_keyop(pkey_op, ctx, md, pkey, in, filesize, NULL, 0,
|
2019-01-16 08:16:28 +00:00
|
|
|
&buf_out, (size_t *)&buf_outlen);
|
|
|
|
} else {
|
|
|
|
rv = do_keyop(ctx, pkey_op, NULL, (size_t *)&buf_outlen,
|
|
|
|
buf_in, (size_t)buf_inlen);
|
|
|
|
if (rv > 0 && buf_outlen != 0) {
|
|
|
|
buf_out = app_malloc(buf_outlen, "buffer output");
|
|
|
|
rv = do_keyop(ctx, pkey_op,
|
|
|
|
buf_out, (size_t *)&buf_outlen,
|
|
|
|
buf_in, (size_t)buf_inlen);
|
|
|
|
}
|
|
|
|
}
|
2015-01-22 03:40:55 +00:00
|
|
|
}
|
2016-03-01 17:22:51 +00:00
|
|
|
if (rv <= 0) {
|
2017-07-21 20:19:35 +00:00
|
|
|
if (pkey_op != EVP_PKEY_OP_DERIVE) {
|
|
|
|
BIO_puts(bio_err, "Public Key operation error\n");
|
|
|
|
} else {
|
|
|
|
BIO_puts(bio_err, "Key derivation failed\n");
|
|
|
|
}
|
2015-01-22 03:40:55 +00:00
|
|
|
ERR_print_errors(bio_err);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
ret = 0;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
if (asn1parse) {
|
|
|
|
if (!ASN1_parse_dump(out, buf_out, buf_outlen, 1, -1))
|
|
|
|
ERR_print_errors(bio_err);
|
2017-06-12 17:24:02 +00:00
|
|
|
} else if (hexdump) {
|
2015-01-22 03:40:55 +00:00
|
|
|
BIO_dump(out, (char *)buf_out, buf_outlen);
|
2017-06-12 17:24:02 +00:00
|
|
|
} else {
|
2015-01-22 03:40:55 +00:00
|
|
|
BIO_write(out, buf_out, buf_outlen);
|
2017-06-12 17:24:02 +00:00
|
|
|
}
|
2015-01-22 03:40:55 +00:00
|
|
|
|
|
|
|
end:
|
2015-03-28 14:54:15 +00:00
|
|
|
EVP_PKEY_CTX_free(ctx);
|
2016-09-28 21:39:18 +00:00
|
|
|
release_engine(e);
|
2015-01-22 03:40:55 +00:00
|
|
|
BIO_free(in);
|
|
|
|
BIO_free_all(out);
|
2015-05-01 14:02:07 +00:00
|
|
|
OPENSSL_free(buf_in);
|
|
|
|
OPENSSL_free(buf_out);
|
|
|
|
OPENSSL_free(sig);
|
2016-02-02 05:37:41 +00:00
|
|
|
sk_OPENSSL_STRING_free(pkeyopts);
|
2017-08-01 17:38:32 +00:00
|
|
|
sk_OPENSSL_STRING_free(pkeyopts_passin);
|
2015-01-22 03:40:55 +00:00
|
|
|
return ret;
|
2006-04-07 19:33:28 +00:00
|
|
|
}
|
|
|
|
|
2016-03-01 16:29:47 +00:00
|
|
|
static EVP_PKEY_CTX *init_ctx(const char *kdfalg, int *pkeysize,
|
2016-02-02 05:37:41 +00:00
|
|
|
const char *keyfile, int keyform, int key_type,
|
2016-01-14 04:03:31 +00:00
|
|
|
char *passinarg, int pkey_op, ENGINE *e,
|
2019-03-07 10:37:34 +00:00
|
|
|
const int engine_impl, int rawin,
|
|
|
|
EVP_PKEY **ppkey)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
|
|
|
EVP_PKEY *pkey = NULL;
|
|
|
|
EVP_PKEY_CTX *ctx = NULL;
|
2016-01-14 04:03:31 +00:00
|
|
|
ENGINE *impl = NULL;
|
2015-01-22 03:40:55 +00:00
|
|
|
char *passin = NULL;
|
|
|
|
int rv = -1;
|
|
|
|
X509 *x;
|
|
|
|
if (((pkey_op == EVP_PKEY_OP_SIGN) || (pkey_op == EVP_PKEY_OP_DECRYPT)
|
|
|
|
|| (pkey_op == EVP_PKEY_OP_DERIVE))
|
2016-03-01 16:29:47 +00:00
|
|
|
&& (key_type != KEY_PRIVKEY && kdfalg == NULL)) {
|
2015-01-22 03:40:55 +00:00
|
|
|
BIO_printf(bio_err, "A private key is needed for this operation\n");
|
|
|
|
goto end;
|
|
|
|
}
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
if (!app_passwd(passinarg, NULL, &passin, NULL)) {
|
2015-01-22 03:40:55 +00:00
|
|
|
BIO_printf(bio_err, "Error getting password\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
switch (key_type) {
|
|
|
|
case KEY_PRIVKEY:
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
pkey = load_key(keyfile, keyform, 0, passin, e, "Private Key");
|
2015-01-22 03:40:55 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_PUBKEY:
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
pkey = load_pubkey(keyfile, keyform, 0, NULL, e, "Public Key");
|
2015-01-22 03:40:55 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_CERT:
|
2016-02-14 03:33:56 +00:00
|
|
|
x = load_cert(keyfile, keyform, "Certificate");
|
2015-01-22 03:40:55 +00:00
|
|
|
if (x) {
|
|
|
|
pkey = X509_get_pubkey(x);
|
|
|
|
X509_free(x);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2016-03-01 16:29:47 +00:00
|
|
|
case KEY_NONE:
|
|
|
|
break;
|
2015-01-22 03:40:55 +00:00
|
|
|
|
2016-03-01 16:29:47 +00:00
|
|
|
}
|
2015-01-22 03:40:55 +00:00
|
|
|
|
2016-01-14 04:03:31 +00:00
|
|
|
#ifndef OPENSSL_NO_ENGINE
|
|
|
|
if (engine_impl)
|
|
|
|
impl = e;
|
|
|
|
#endif
|
2015-01-22 03:40:55 +00:00
|
|
|
|
2017-06-12 17:24:02 +00:00
|
|
|
if (kdfalg != NULL) {
|
2016-03-01 16:29:47 +00:00
|
|
|
int kdfnid = OBJ_sn2nid(kdfalg);
|
2017-08-02 23:45:49 +00:00
|
|
|
|
|
|
|
if (kdfnid == NID_undef) {
|
|
|
|
kdfnid = OBJ_ln2nid(kdfalg);
|
2017-07-21 20:19:35 +00:00
|
|
|
if (kdfnid == NID_undef) {
|
|
|
|
BIO_printf(bio_err, "The given KDF \"%s\" is unknown.\n",
|
|
|
|
kdfalg);
|
2017-08-02 23:45:49 +00:00
|
|
|
goto end;
|
2017-07-21 20:19:35 +00:00
|
|
|
}
|
2017-08-02 23:45:49 +00:00
|
|
|
}
|
2016-03-01 16:29:47 +00:00
|
|
|
ctx = EVP_PKEY_CTX_new_id(kdfnid, impl);
|
|
|
|
} else {
|
|
|
|
if (pkey == NULL)
|
|
|
|
goto end;
|
2019-02-28 13:47:26 +00:00
|
|
|
|
|
|
|
#ifndef OPENSSL_NO_EC
|
2019-01-16 08:16:28 +00:00
|
|
|
/* SM2 needs a special treatment */
|
|
|
|
if (EVP_PKEY_id(pkey) == EVP_PKEY_EC) {
|
2019-02-28 13:47:26 +00:00
|
|
|
EC_KEY *eckey = NULL;
|
|
|
|
const EC_GROUP *group = NULL;
|
|
|
|
int nid;
|
|
|
|
|
2019-01-16 08:16:28 +00:00
|
|
|
if ((eckey = EVP_PKEY_get0_EC_KEY(pkey)) == NULL
|
|
|
|
|| (group = EC_KEY_get0_group(eckey)) == NULL
|
|
|
|
|| (nid = EC_GROUP_get_curve_name(group)) == 0)
|
|
|
|
goto end;
|
|
|
|
if (nid == NID_sm2)
|
|
|
|
EVP_PKEY_set_alias_type(pkey, EVP_PKEY_SM2);
|
|
|
|
}
|
2019-02-28 13:47:26 +00:00
|
|
|
#endif
|
2016-03-01 16:29:47 +00:00
|
|
|
*pkeysize = EVP_PKEY_size(pkey);
|
|
|
|
ctx = EVP_PKEY_CTX_new(pkey, impl);
|
2019-01-16 08:16:28 +00:00
|
|
|
if (ppkey != NULL)
|
|
|
|
*ppkey = pkey;
|
2016-03-01 16:29:47 +00:00
|
|
|
EVP_PKEY_free(pkey);
|
|
|
|
}
|
2015-01-22 03:40:55 +00:00
|
|
|
|
2015-10-30 11:18:04 +00:00
|
|
|
if (ctx == NULL)
|
2015-01-22 03:40:55 +00:00
|
|
|
goto end;
|
|
|
|
|
2019-03-07 10:37:34 +00:00
|
|
|
/*
|
|
|
|
* If rawin then we don't need to actually initialise the EVP_PKEY_CTX
|
|
|
|
* itself. That will get initialised during EVP_DigestSignInit or
|
|
|
|
* EVP_DigestVerifyInit.
|
|
|
|
*/
|
|
|
|
if (rawin) {
|
|
|
|
rv = 1;
|
|
|
|
} else {
|
|
|
|
switch (pkey_op) {
|
|
|
|
case EVP_PKEY_OP_SIGN:
|
|
|
|
rv = EVP_PKEY_sign_init(ctx);
|
|
|
|
break;
|
2015-01-22 03:40:55 +00:00
|
|
|
|
2019-03-07 10:37:34 +00:00
|
|
|
case EVP_PKEY_OP_VERIFY:
|
|
|
|
rv = EVP_PKEY_verify_init(ctx);
|
|
|
|
break;
|
2015-01-22 03:40:55 +00:00
|
|
|
|
2019-03-07 10:37:34 +00:00
|
|
|
case EVP_PKEY_OP_VERIFYRECOVER:
|
|
|
|
rv = EVP_PKEY_verify_recover_init(ctx);
|
|
|
|
break;
|
2015-01-22 03:40:55 +00:00
|
|
|
|
2019-03-07 10:37:34 +00:00
|
|
|
case EVP_PKEY_OP_ENCRYPT:
|
|
|
|
rv = EVP_PKEY_encrypt_init(ctx);
|
|
|
|
break;
|
2015-01-22 03:40:55 +00:00
|
|
|
|
2019-03-07 10:37:34 +00:00
|
|
|
case EVP_PKEY_OP_DECRYPT:
|
|
|
|
rv = EVP_PKEY_decrypt_init(ctx);
|
|
|
|
break;
|
2015-01-22 03:40:55 +00:00
|
|
|
|
2019-03-07 10:37:34 +00:00
|
|
|
case EVP_PKEY_OP_DERIVE:
|
|
|
|
rv = EVP_PKEY_derive_init(ctx);
|
|
|
|
break;
|
|
|
|
}
|
2015-01-22 03:40:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rv <= 0) {
|
|
|
|
EVP_PKEY_CTX_free(ctx);
|
|
|
|
ctx = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
2015-05-01 14:02:07 +00:00
|
|
|
OPENSSL_free(passin);
|
2015-01-22 03:40:55 +00:00
|
|
|
return ctx;
|
|
|
|
|
|
|
|
}
|
2006-04-07 19:33:28 +00:00
|
|
|
|
2016-02-02 05:37:41 +00:00
|
|
|
static int setup_peer(EVP_PKEY_CTX *ctx, int peerform, const char *file,
|
2017-07-21 20:19:35 +00:00
|
|
|
ENGINE *e)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
|
|
|
EVP_PKEY *peer = NULL;
|
2017-07-21 20:19:35 +00:00
|
|
|
ENGINE *engine = NULL;
|
2015-01-22 03:40:55 +00:00
|
|
|
int ret;
|
|
|
|
|
2016-02-02 05:37:41 +00:00
|
|
|
if (peerform == FORMAT_ENGINE)
|
|
|
|
engine = e;
|
|
|
|
peer = load_pubkey(file, peerform, 0, NULL, engine, "Peer Key");
|
2017-06-12 17:24:02 +00:00
|
|
|
if (peer == NULL) {
|
2015-01-22 03:40:55 +00:00
|
|
|
BIO_printf(bio_err, "Error reading peer key %s\n", file);
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
ERR_print_errors(bio_err);
|
2015-01-22 03:40:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = EVP_PKEY_derive_set_peer(ctx, peer);
|
|
|
|
|
|
|
|
EVP_PKEY_free(peer);
|
|
|
|
if (ret <= 0)
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-24 19:26:15 +00:00
|
|
|
ERR_print_errors(bio_err);
|
2015-01-22 03:40:55 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2006-04-15 18:50:56 +00:00
|
|
|
|
|
|
|
static int do_keyop(EVP_PKEY_CTX *ctx, int pkey_op,
|
2015-01-22 03:40:55 +00:00
|
|
|
unsigned char *out, size_t *poutlen,
|
2016-08-04 21:52:22 +00:00
|
|
|
const unsigned char *in, size_t inlen)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
|
|
|
int rv = 0;
|
|
|
|
switch (pkey_op) {
|
|
|
|
case EVP_PKEY_OP_VERIFYRECOVER:
|
|
|
|
rv = EVP_PKEY_verify_recover(ctx, out, poutlen, in, inlen);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EVP_PKEY_OP_SIGN:
|
|
|
|
rv = EVP_PKEY_sign(ctx, out, poutlen, in, inlen);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EVP_PKEY_OP_ENCRYPT:
|
|
|
|
rv = EVP_PKEY_encrypt(ctx, out, poutlen, in, inlen);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EVP_PKEY_OP_DECRYPT:
|
|
|
|
rv = EVP_PKEY_decrypt(ctx, out, poutlen, in, inlen);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EVP_PKEY_OP_DERIVE:
|
|
|
|
rv = EVP_PKEY_derive(ctx, out, poutlen);
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
2019-01-16 08:16:28 +00:00
|
|
|
|
|
|
|
#define TBUF_MAXSIZE 2048
|
|
|
|
|
|
|
|
static int do_raw_keyop(int pkey_op, EVP_PKEY_CTX *ctx,
|
|
|
|
const EVP_MD *md, EVP_PKEY *pkey, BIO *in,
|
2019-03-07 10:37:34 +00:00
|
|
|
int filesize, unsigned char *sig, int siglen,
|
2019-01-16 08:16:28 +00:00
|
|
|
unsigned char **out, size_t *poutlen)
|
|
|
|
{
|
|
|
|
int rv = 0;
|
|
|
|
EVP_MD_CTX *mctx = NULL;
|
|
|
|
unsigned char tbuf[TBUF_MAXSIZE];
|
2019-03-07 10:37:34 +00:00
|
|
|
unsigned char *mbuf = NULL;
|
|
|
|
int buf_len = 0;
|
2019-01-16 08:16:28 +00:00
|
|
|
|
|
|
|
if ((mctx = EVP_MD_CTX_new()) == NULL) {
|
|
|
|
BIO_printf(bio_err, "Error: out of memory\n");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
EVP_MD_CTX_set_pkey_ctx(mctx, ctx);
|
|
|
|
|
2019-03-07 10:37:34 +00:00
|
|
|
/* Some algorithms only support oneshot digests */
|
|
|
|
if (EVP_PKEY_id(pkey) == EVP_PKEY_ED25519
|
|
|
|
|| EVP_PKEY_id(pkey) == EVP_PKEY_ED448) {
|
|
|
|
if (filesize < 0) {
|
|
|
|
BIO_printf(bio_err,
|
|
|
|
"Error: unable to determine file size for oneshot operation\n");
|
2019-04-07 01:45:36 +00:00
|
|
|
goto end;
|
2019-03-07 10:37:34 +00:00
|
|
|
}
|
|
|
|
mbuf = app_malloc(filesize, "oneshot sign/verify buffer");
|
|
|
|
switch(pkey_op) {
|
|
|
|
case EVP_PKEY_OP_VERIFY:
|
|
|
|
if (EVP_DigestVerifyInit(mctx, NULL, md, NULL, pkey) != 1)
|
|
|
|
goto end;
|
|
|
|
buf_len = BIO_read(in, mbuf, filesize);
|
|
|
|
if (buf_len != filesize) {
|
|
|
|
BIO_printf(bio_err, "Error reading raw input data\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
rv = EVP_DigestVerify(mctx, sig, (size_t)siglen, mbuf, buf_len);
|
|
|
|
break;
|
|
|
|
case EVP_PKEY_OP_SIGN:
|
|
|
|
if (EVP_DigestSignInit(mctx, NULL, md, NULL, pkey) != 1)
|
|
|
|
goto end;
|
|
|
|
buf_len = BIO_read(in, mbuf, filesize);
|
|
|
|
if (buf_len != filesize) {
|
|
|
|
BIO_printf(bio_err, "Error reading raw input data\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
rv = EVP_DigestSign(mctx, NULL, poutlen, mbuf, buf_len);
|
|
|
|
if (rv == 1 && out != NULL) {
|
|
|
|
*out = app_malloc(*poutlen, "buffer output");
|
|
|
|
rv = EVP_DigestSign(mctx, *out, poutlen, mbuf, buf_len);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2019-01-16 08:16:28 +00:00
|
|
|
switch(pkey_op) {
|
|
|
|
case EVP_PKEY_OP_VERIFY:
|
|
|
|
if (EVP_DigestVerifyInit(mctx, NULL, md, NULL, pkey) != 1)
|
|
|
|
goto end;
|
|
|
|
for (;;) {
|
2019-03-07 10:37:34 +00:00
|
|
|
buf_len = BIO_read(in, tbuf, TBUF_MAXSIZE);
|
|
|
|
if (buf_len == 0)
|
2019-01-16 08:16:28 +00:00
|
|
|
break;
|
2019-03-07 10:37:34 +00:00
|
|
|
if (buf_len < 0) {
|
2019-01-16 08:16:28 +00:00
|
|
|
BIO_printf(bio_err, "Error reading raw input data\n");
|
|
|
|
goto end;
|
|
|
|
}
|
2019-03-07 10:37:34 +00:00
|
|
|
rv = EVP_DigestVerifyUpdate(mctx, tbuf, (size_t)buf_len);
|
2019-01-16 08:16:28 +00:00
|
|
|
if (rv != 1) {
|
|
|
|
BIO_printf(bio_err, "Error verifying raw input data\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rv = EVP_DigestVerifyFinal(mctx, sig, (size_t)siglen);
|
|
|
|
break;
|
|
|
|
case EVP_PKEY_OP_SIGN:
|
|
|
|
if (EVP_DigestSignInit(mctx, NULL, md, NULL, pkey) != 1)
|
|
|
|
goto end;
|
|
|
|
for (;;) {
|
2019-03-07 10:37:34 +00:00
|
|
|
buf_len = BIO_read(in, tbuf, TBUF_MAXSIZE);
|
|
|
|
if (buf_len == 0)
|
2019-01-16 08:16:28 +00:00
|
|
|
break;
|
2019-03-07 10:37:34 +00:00
|
|
|
if (buf_len < 0) {
|
2019-01-16 08:16:28 +00:00
|
|
|
BIO_printf(bio_err, "Error reading raw input data\n");
|
|
|
|
goto end;
|
|
|
|
}
|
2019-03-07 10:37:34 +00:00
|
|
|
rv = EVP_DigestSignUpdate(mctx, tbuf, (size_t)buf_len);
|
2019-01-16 08:16:28 +00:00
|
|
|
if (rv != 1) {
|
|
|
|
BIO_printf(bio_err, "Error signing raw input data\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rv = EVP_DigestSignFinal(mctx, NULL, poutlen);
|
|
|
|
if (rv == 1 && out != NULL) {
|
|
|
|
*out = app_malloc(*poutlen, "buffer output");
|
|
|
|
rv = EVP_DigestSignFinal(mctx, *out, poutlen);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
2019-04-07 01:45:36 +00:00
|
|
|
OPENSSL_free(mbuf);
|
2019-01-16 08:16:28 +00:00
|
|
|
EVP_MD_CTX_free(mctx);
|
|
|
|
return rv;
|
|
|
|
}
|