| 
									
										
										
										
											2008-11-06 02:39:08 +08:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2023-09-07 16:59:15 +08:00
										 |  |  |  * Copyright 2006-2023 The OpenSSL Project Authors. All Rights Reserved. | 
					
						
							| 
									
										
										
										
											2006-03-28 20:34:45 +08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-12-06 20:00:26 +08:00
										 |  |  |  * Licensed under the Apache License 2.0 (the "License").  You may not use | 
					
						
							| 
									
										
										
										
											2016-05-18 02:18:30 +08: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-03-28 20:34:45 +08:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2016-05-18 02:18:30 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-28 20:34:45 +08:00
										 |  |  | #include <stdio.h>
 | 
					
						
							|  |  |  | #include <string.h>
 | 
					
						
							|  |  |  | #include "apps.h"
 | 
					
						
							| 
									
										
										
										
											2018-01-31 18:13:10 +08:00
										 |  |  | #include "progs.h"
 | 
					
						
							| 
									
										
										
										
											2020-10-15 11:41:59 +08:00
										 |  |  | #include "ec_common.h"
 | 
					
						
							| 
									
										
										
										
											2006-03-28 20:34:45 +08:00
										 |  |  | #include <openssl/pem.h>
 | 
					
						
							|  |  |  | #include <openssl/err.h>
 | 
					
						
							|  |  |  | #include <openssl/evp.h>
 | 
					
						
							| 
									
										
										
										
											2020-10-15 11:41:59 +08:00
										 |  |  | #include <openssl/core_names.h>
 | 
					
						
							| 
									
										
										
										
											2020-02-18 09:36:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  | typedef enum OPTION_choice { | 
					
						
							| 
									
										
										
										
											2021-05-01 21:29:00 +08:00
										 |  |  |     OPT_COMMON, | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     OPT_INFORM, OPT_OUTFORM, OPT_PASSIN, OPT_PASSOUT, OPT_ENGINE, | 
					
						
							|  |  |  |     OPT_IN, OPT_OUT, OPT_PUBIN, OPT_PUBOUT, OPT_TEXT_PUB, | 
					
						
							| 
									
										
										
										
											2020-12-22 15:37:03 +08:00
										 |  |  |     OPT_TEXT, OPT_NOOUT, OPT_CIPHER, OPT_TRADITIONAL, OPT_CHECK, OPT_PUB_CHECK, | 
					
						
							| 
									
										
										
										
											2020-02-25 12:29:30 +08:00
										 |  |  |     OPT_EC_PARAM_ENC, OPT_EC_CONV_FORM, | 
					
						
							|  |  |  |     OPT_PROV_ENUM | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  | } OPTION_CHOICE; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-13 21:07:50 +08:00
										 |  |  | const OPTIONS pkey_options[] = { | 
					
						
							| 
									
										
										
										
											2019-11-08 04:08:30 +08:00
										 |  |  |     OPT_SECTION("General"), | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     {"help", OPT_HELP, '-', "Display this summary"}, | 
					
						
							| 
									
										
										
										
											2019-11-08 04:08:30 +08:00
										 |  |  | #ifndef OPENSSL_NO_ENGINE
 | 
					
						
							|  |  |  |     {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2020-12-22 15:37:03 +08:00
										 |  |  |     OPT_PROV_OPTIONS, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-08 04:08:30 +08:00
										 |  |  |     {"check", OPT_CHECK, '-', "Check key consistency"}, | 
					
						
							|  |  |  |     {"pubcheck", OPT_PUB_CHECK, '-', "Check public key consistency"}, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     OPT_SECTION("Input"), | 
					
						
							|  |  |  |     {"in", OPT_IN, 's', "Input key"}, | 
					
						
							| 
									
										
										
										
											2020-12-22 15:37:03 +08:00
										 |  |  |     {"inform", OPT_INFORM, 'f', | 
					
						
							|  |  |  |      "Key input format (ENGINE, other values ignored)"}, | 
					
						
							|  |  |  |     {"passin", OPT_PASSIN, 's', "Key input pass phrase source"}, | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     {"pubin", OPT_PUBIN, '-', | 
					
						
							| 
									
										
										
										
											2020-12-22 17:28:03 +08:00
										 |  |  |      "Read only public components from key input"}, | 
					
						
							| 
									
										
										
										
											2019-11-08 04:08:30 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     OPT_SECTION("Output"), | 
					
						
							| 
									
										
										
										
											2020-12-22 17:28:03 +08:00
										 |  |  |     {"out", OPT_OUT, '>', "Output file for encoded and/or text output"}, | 
					
						
							|  |  |  |     {"outform", OPT_OUTFORM, 'F', "Output encoding format (DER or PEM)"}, | 
					
						
							| 
									
										
										
										
											2020-12-22 15:37:03 +08:00
										 |  |  |     {"", OPT_CIPHER, '-', "Any supported cipher to be used for encryption"}, | 
					
						
							| 
									
										
										
										
											2020-12-15 21:30:38 +08:00
										 |  |  |     {"passout", OPT_PASSOUT, 's', "Output PEM file pass phrase source"}, | 
					
						
							| 
									
										
										
										
											2020-12-22 15:37:03 +08:00
										 |  |  |     {"traditional", OPT_TRADITIONAL, '-', | 
					
						
							|  |  |  |      "Use traditional format for private key PEM output"}, | 
					
						
							| 
									
										
										
										
											2020-12-22 17:28:03 +08:00
										 |  |  |     {"pubout", OPT_PUBOUT, '-', "Restrict encoded output to public components"}, | 
					
						
							|  |  |  |     {"noout", OPT_NOOUT, '-', "Do not output the key in encoded form"}, | 
					
						
							|  |  |  |     {"text", OPT_TEXT, '-', "Output key components in plaintext"}, | 
					
						
							| 
									
										
										
										
											2020-12-22 15:37:03 +08:00
										 |  |  |     {"text_pub", OPT_TEXT_PUB, '-', | 
					
						
							| 
									
										
										
										
											2020-12-22 17:28:03 +08:00
										 |  |  |      "Output only public key components in text form"}, | 
					
						
							| 
									
										
										
										
											2020-12-22 15:37:03 +08:00
										 |  |  |     {"ec_conv_form", OPT_EC_CONV_FORM, 's', | 
					
						
							| 
									
										
										
										
											2020-12-22 17:28:03 +08:00
										 |  |  |      "Specifies the EC point conversion form in the encoding"}, | 
					
						
							| 
									
										
										
										
											2020-12-22 15:37:03 +08:00
										 |  |  |     {"ec_param_enc", OPT_EC_PARAM_ENC, 's', | 
					
						
							| 
									
										
										
										
											2020-12-22 17:28:03 +08:00
										 |  |  |      "Specifies the way the EC parameters are encoded"}, | 
					
						
							| 
									
										
										
										
											2019-11-08 04:08:30 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     {NULL} | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2006-03-28 20:34:45 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  | int pkey_main(int argc, char **argv) | 
					
						
							| 
									
										
										
										
											2006-03-28 20:34:45 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2021-05-18 23:20:49 +08:00
										 |  |  |     BIO *out = NULL; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     ENGINE *e = NULL; | 
					
						
							| 
									
										
										
										
											2006-03-28 20:34:45 +08:00
										 |  |  |     EVP_PKEY *pkey = NULL; | 
					
						
							| 
									
										
										
										
											2020-11-10 04:35:28 +08:00
										 |  |  |     EVP_PKEY_CTX *ctx = NULL; | 
					
						
							| 
									
										
										
										
											2021-02-18 05:15:27 +08:00
										 |  |  |     EVP_CIPHER *cipher = NULL; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     char *infile = NULL, *outfile = NULL, *passin = NULL, *passout = NULL; | 
					
						
							| 
									
										
										
										
											2021-02-09 03:20:01 +08:00
										 |  |  |     char *passinarg = NULL, *passoutarg = NULL, *ciphername = NULL, *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-25 03:26:15 +08:00
										 |  |  |     OPTION_CHOICE o; | 
					
						
							| 
									
										
										
										
											2021-04-30 22:57:53 +08:00
										 |  |  |     int informat = FORMAT_UNDEF, outformat = FORMAT_PEM; | 
					
						
							| 
									
										
										
										
											2020-12-22 17:28:03 +08:00
										 |  |  |     int pubin = 0, pubout = 0, text_pub = 0, text = 0, noout = 0, ret = 1; | 
					
						
							| 
									
										
										
										
											2017-11-01 00:45:24 +08:00
										 |  |  |     int private = 0, traditional = 0, check = 0, pub_check = 0; | 
					
						
							| 
									
										
										
										
											2020-02-18 09:36:08 +08:00
										 |  |  | #ifndef OPENSSL_NO_EC
 | 
					
						
							| 
									
										
										
										
											2020-10-15 11:41:59 +08:00
										 |  |  |     char *asn1_encoding = NULL; | 
					
						
							|  |  |  |     char *point_format = NULL; | 
					
						
							| 
									
										
										
										
											2020-02-18 09:36:08 +08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-24 18:03:12 +08:00
										 |  |  |     opt_set_unknown_name("cipher"); | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     prog = opt_init(argc, argv, pkey_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(pkey_options); | 
					
						
							|  |  |  |             ret = 0; | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |         case OPT_INFORM: | 
					
						
							| 
									
										
										
										
											2016-02-08 23:06:48 +08:00
										 |  |  |             if (!opt_format(opt_arg(), OPT_FMT_ANY, &informat)) | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |                 goto opthelp; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_OUTFORM: | 
					
						
							|  |  |  |             if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &outformat)) | 
					
						
							|  |  |  |                 goto opthelp; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_PASSIN: | 
					
						
							|  |  |  |             passinarg = opt_arg(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_PASSOUT: | 
					
						
							|  |  |  |             passoutarg = opt_arg(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_ENGINE: | 
					
						
							| 
									
										
										
										
											2015-04-26 03:41:29 +08:00
										 |  |  |             e = setup_engine(opt_arg(), 0); | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_IN: | 
					
						
							|  |  |  |             infile = opt_arg(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_OUT: | 
					
						
							|  |  |  |             outfile = opt_arg(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case OPT_PUBIN: | 
					
						
							| 
									
										
										
										
											2020-12-22 17:28:03 +08:00
										 |  |  |             pubin = pubout = 1; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_PUBOUT: | 
					
						
							| 
									
										
										
										
											2006-03-28 20:34:45 +08:00
										 |  |  |             pubout = 1; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_TEXT_PUB: | 
					
						
							| 
									
										
										
										
											2020-12-22 17:28:03 +08:00
										 |  |  |             text_pub = 1; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_TEXT: | 
					
						
							| 
									
										
										
										
											2006-03-28 20:34:45 +08:00
										 |  |  |             text = 1; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_NOOUT: | 
					
						
							| 
									
										
										
										
											2006-03-28 20:34:45 +08:00
										 |  |  |             noout = 1; | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |             break; | 
					
						
							| 
									
										
										
										
											2016-05-17 21:15:20 +08:00
										 |  |  |         case OPT_TRADITIONAL: | 
					
						
							|  |  |  |             traditional = 1; | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2017-09-04 22:02:59 +08:00
										 |  |  |         case OPT_CHECK: | 
					
						
							|  |  |  |             check = 1; | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2017-11-01 00:45:24 +08:00
										 |  |  |         case OPT_PUB_CHECK: | 
					
						
							|  |  |  |             pub_check = 1; | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2020-12-22 15:37:03 +08:00
										 |  |  |         case OPT_CIPHER: | 
					
						
							| 
									
										
										
										
											2021-02-09 03:20:01 +08:00
										 |  |  |             ciphername = opt_unknown(); | 
					
						
							| 
									
										
										
										
											2020-02-18 09:36:08 +08:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case OPT_EC_CONV_FORM: | 
					
						
							|  |  |  | #ifdef OPENSSL_NO_EC
 | 
					
						
							|  |  |  |             goto opthelp; | 
					
						
							|  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2020-10-15 11:41:59 +08:00
										 |  |  |             point_format = opt_arg(); | 
					
						
							|  |  |  |             if (!opt_string(point_format, point_format_options)) | 
					
						
							| 
									
										
										
										
											2020-02-18 09:36:08 +08:00
										 |  |  |                 goto opthelp; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  |         case OPT_EC_PARAM_ENC: | 
					
						
							|  |  |  | #ifdef OPENSSL_NO_EC
 | 
					
						
							|  |  |  |             goto opthelp; | 
					
						
							|  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2020-10-15 11:41:59 +08:00
										 |  |  |             asn1_encoding = opt_arg(); | 
					
						
							|  |  |  |             if (!opt_string(asn1_encoding, asn1_encoding_options)) | 
					
						
							| 
									
										
										
										
											2020-02-18 09:36:08 +08:00
										 |  |  |                 goto opthelp; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2020-02-25 12:29:30 +08:00
										 |  |  |         case OPT_PROV_CASES: | 
					
						
							|  |  |  |             if (!opt_provider(o)) | 
					
						
							|  |  |  |                 goto end; | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2006-03-28 20:34:45 +08:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-11-29 05:12:58 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /* No extra arguments. */ | 
					
						
							| 
									
										
										
										
											2021-08-27 21:33:18 +08:00
										 |  |  |     if (!opt_check_rest_arg(NULL)) | 
					
						
							| 
									
										
										
										
											2016-02-15 03:45:02 +08:00
										 |  |  |         goto opthelp; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-22 17:28:03 +08:00
										 |  |  |     if (text && text_pub) | 
					
						
							|  |  |  |         BIO_printf(bio_err, | 
					
						
							|  |  |  |                    "Warning: The -text option is ignored with -text_pub\n"); | 
					
						
							|  |  |  |     if (traditional && (noout || outformat != FORMAT_PEM)) | 
					
						
							|  |  |  |         BIO_printf(bio_err, | 
					
						
							|  |  |  |                    "Warning: The -traditional is ignored since there is no PEM output\n"); | 
					
						
							| 
									
										
										
										
											2021-06-08 18:22:31 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /* -pubout and -text is the same as -text_pub */ | 
					
						
							|  |  |  |     if (!text_pub && pubout && text) { | 
					
						
							|  |  |  |         text = 0; | 
					
						
							|  |  |  |         text_pub = 1; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-22 17:28:03 +08:00
										 |  |  |     private = (!noout && !pubout) || (text && !text_pub); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-27 21:33:18 +08:00
										 |  |  |     if (!opt_cipher(ciphername, &cipher)) | 
					
						
							|  |  |  |         goto opthelp; | 
					
						
							| 
									
										
										
										
											2020-12-22 17:28:03 +08:00
										 |  |  |     if (cipher == NULL) { | 
					
						
							|  |  |  |         if (passoutarg != NULL) | 
					
						
							|  |  |  |             BIO_printf(bio_err, | 
					
						
							|  |  |  |                        "Warning: The -passout option is ignored without a cipher option\n"); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         if (noout || outformat != FORMAT_PEM) { | 
					
						
							|  |  |  |             BIO_printf(bio_err, | 
					
						
							|  |  |  |                        "Error: Cipher options are supported only for PEM output\n"); | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-12-15 21:30:38 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |     if (!app_passwd(passinarg, passoutarg, &passin, &passout)) { | 
					
						
							| 
									
										
										
										
											2006-03-28 20:34:45 +08:00
										 |  |  |         BIO_printf(bio_err, "Error getting passwords\n"); | 
					
						
							| 
									
										
										
										
											2006-03-28 22:35:32 +08:00
										 |  |  |         goto end; | 
					
						
							| 
									
										
										
										
											2006-03-28 20:34:45 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-28 20:34:45 +08:00
										 |  |  |     if (pubin) | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |         pkey = load_pubkey(infile, informat, 1, passin, e, "Public Key"); | 
					
						
							| 
									
										
										
										
											2006-03-28 20:34:45 +08:00
										 |  |  |     else | 
					
						
							| 
									
										
											  
											
												Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master.  The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt.  Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that.  There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
        For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
        RT3515: Use 3DES in pkcs12 if built with no-rc2
        RT1766: s_client -reconnect and -starttls broke
        RT2932: Catch write errors
        RT2604: port should be 'unsigned short'
        RT2983: total_bytes undeclared #ifdef RENEG
        RT1523: Add -nocert to fix output in x509 app
        RT3508: Remove unused variable introduced by b09eb24
        RT3511: doc fix; req default serial is random
        RT1325,2973: Add more extensions to c_rehash
        RT2119,3407: Updated to dgst.pod
        RT2379: Additional typo fix
        RT2693: Extra include of string.h
        RT2880: HFS is case-insensitive filenames
        RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
        Add SCSV support
        Add -misalign to speed command
        Make dhparam, dsaparam, ecparam, x509 output C in proper style
        Make some internal ocsp.c functions void
        Only display cert usages with -help in verify
        Use global bio_err, remove "BIO*err" parameter from functions
        For filenames, - always means stdin (or stdout as appropriate)
        Add aliases for -des/aes "wrap" ciphers.
        *Remove support for IISSGC (server gated crypto)
        *The undocumented OCSP -header flag is now "-header name=value"
        *Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
											
										 
											2015-04-25 03:26:15 +08:00
										 |  |  |         pkey = load_key(infile, informat, 1, passin, e, "key"); | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |     if (pkey == NULL) | 
					
						
							| 
									
										
										
										
											2006-03-28 22:35:32 +08:00
										 |  |  |         goto end; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-27 01:25:43 +08:00
										 |  |  |     out = bio_open_owner(outfile, outformat, private); | 
					
						
							|  |  |  |     if (out == NULL) | 
					
						
							|  |  |  |         goto end; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-18 09:36:08 +08:00
										 |  |  | #ifndef OPENSSL_NO_EC
 | 
					
						
							| 
									
										
										
										
											2020-10-15 11:41:59 +08:00
										 |  |  |     if (asn1_encoding != NULL || point_format != NULL) { | 
					
						
							|  |  |  |         OSSL_PARAM params[3], *p = params; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (!EVP_PKEY_is_a(pkey, "EC")) | 
					
						
							| 
									
										
										
										
											2020-02-18 09:36:08 +08:00
										 |  |  |             goto end; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-15 11:41:59 +08:00
										 |  |  |         if (asn1_encoding != NULL) | 
					
						
							|  |  |  |             *p++ = OSSL_PARAM_construct_utf8_string(OSSL_PKEY_PARAM_EC_ENCODING, | 
					
						
							|  |  |  |                                                     asn1_encoding, 0); | 
					
						
							|  |  |  |         if (point_format != NULL) | 
					
						
							|  |  |  |             *p++ = OSSL_PARAM_construct_utf8_string( | 
					
						
							|  |  |  |                        OSSL_PKEY_PARAM_EC_POINT_CONVERSION_FORMAT, | 
					
						
							|  |  |  |                        point_format, 0); | 
					
						
							|  |  |  |         *p = OSSL_PARAM_construct_end(); | 
					
						
							|  |  |  |         if (EVP_PKEY_set_params(pkey, params) <= 0) | 
					
						
							|  |  |  |             goto end; | 
					
						
							| 
									
										
										
										
											2020-02-18 09:36:08 +08:00
										 |  |  |     } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-01 00:45:24 +08:00
										 |  |  |     if (check || pub_check) { | 
					
						
							| 
									
										
										
										
											2017-09-04 22:02:59 +08:00
										 |  |  |         int r; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ctx = EVP_PKEY_CTX_new(pkey, e); | 
					
						
							|  |  |  |         if (ctx == NULL) { | 
					
						
							|  |  |  |             ERR_print_errors(bio_err); | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-13 21:48:52 +08:00
										 |  |  |         if (check && !pubin) | 
					
						
							| 
									
										
										
										
											2017-11-01 00:45:24 +08:00
										 |  |  |             r = EVP_PKEY_check(ctx); | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |             r = EVP_PKEY_public_check(ctx); | 
					
						
							| 
									
										
										
										
											2017-09-04 22:02:59 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if (r == 1) { | 
					
						
							|  |  |  |             BIO_printf(out, "Key is valid\n"); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             /*
 | 
					
						
							|  |  |  |              * Note: at least for RSA keys if this function returns | 
					
						
							|  |  |  |              * -1, there will be no error reasons. | 
					
						
							|  |  |  |              */ | 
					
						
							| 
									
										
										
										
											2021-01-21 19:36:58 +08:00
										 |  |  |             BIO_printf(bio_err, "Key is invalid\n"); | 
					
						
							|  |  |  |             ERR_print_errors(bio_err); | 
					
						
							| 
									
										
										
										
											2020-11-10 04:35:28 +08:00
										 |  |  |             goto end; | 
					
						
							| 
									
										
										
										
											2017-09-04 22:02:59 +08:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-28 20:34:45 +08:00
										 |  |  |     if (!noout) { | 
					
						
							|  |  |  |         if (outformat == FORMAT_PEM) { | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             if (pubout) { | 
					
						
							| 
									
										
										
										
											2018-08-19 00:43:23 +08:00
										 |  |  |                 if (!PEM_write_bio_PUBKEY(out, pkey)) | 
					
						
							|  |  |  |                     goto end; | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2015-12-13 15:51:44 +08:00
										 |  |  |                 assert(private); | 
					
						
							| 
									
										
										
										
											2018-08-19 00:43:23 +08:00
										 |  |  |                 if (traditional) { | 
					
						
							|  |  |  |                     if (!PEM_write_bio_PrivateKey_traditional(out, pkey, cipher, | 
					
						
							|  |  |  |                                                               NULL, 0, NULL, | 
					
						
							|  |  |  |                                                               passout)) | 
					
						
							|  |  |  |                         goto end; | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     if (!PEM_write_bio_PrivateKey(out, pkey, cipher, | 
					
						
							|  |  |  |                                                   NULL, 0, NULL, passout)) | 
					
						
							|  |  |  |                         goto end; | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2015-12-13 15:51:44 +08:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2006-03-28 20:34:45 +08:00
										 |  |  |         } else if (outformat == FORMAT_ASN1) { | 
					
						
							| 
									
										
										
										
											2020-12-22 17:28:03 +08:00
										 |  |  |             if (text || text_pub) { | 
					
						
							|  |  |  |                 BIO_printf(bio_err, | 
					
						
							|  |  |  |                            "Error: Text output cannot be combined with DER output\n"); | 
					
						
							|  |  |  |                 goto end; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             if (pubout) { | 
					
						
							| 
									
										
										
										
											2018-08-19 00:43:23 +08:00
										 |  |  |                 if (!i2d_PUBKEY_bio(out, pkey)) | 
					
						
							|  |  |  |                     goto end; | 
					
						
							| 
									
										
										
										
											2017-06-13 01:24:02 +08:00
										 |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2015-12-13 15:51:44 +08:00
										 |  |  |                 assert(private); | 
					
						
							| 
									
										
										
										
											2018-08-19 00:43:23 +08:00
										 |  |  |                 if (!i2d_PrivateKey_bio(out, pkey)) | 
					
						
							|  |  |  |                     goto end; | 
					
						
							| 
									
										
										
										
											2015-12-13 15:51:44 +08:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2006-03-28 20:34:45 +08:00
										 |  |  |         } else { | 
					
						
							|  |  |  |             BIO_printf(bio_err, "Bad format specified for key\n"); | 
					
						
							| 
									
										
										
										
											2006-03-28 22:35:32 +08:00
										 |  |  |             goto end; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2006-03-28 20:34:45 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-22 17:28:03 +08:00
										 |  |  |     if (text_pub) { | 
					
						
							|  |  |  |         if (EVP_PKEY_print_public(out, pkey, 0, NULL) <= 0) | 
					
						
							|  |  |  |             goto end; | 
					
						
							|  |  |  |     } else if (text) { | 
					
						
							|  |  |  |         assert(private); | 
					
						
							|  |  |  |         if (EVP_PKEY_print_private(out, pkey, 0, NULL) <= 0) | 
					
						
							|  |  |  |             goto end; | 
					
						
							| 
									
										
										
										
											2006-03-28 20:34:45 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-28 22:35:32 +08:00
										 |  |  |     ret = 0; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-28 20:34:45 +08:00
										 |  |  |  end: | 
					
						
							| 
									
										
										
										
											2017-01-04 00:07:52 +08:00
										 |  |  |     if (ret != 0) | 
					
						
							|  |  |  |         ERR_print_errors(bio_err); | 
					
						
							| 
									
										
										
										
											2020-11-10 04:35:28 +08:00
										 |  |  |     EVP_PKEY_CTX_free(ctx); | 
					
						
							| 
									
										
										
										
											2006-03-28 20:34:45 +08:00
										 |  |  |     EVP_PKEY_free(pkey); | 
					
						
							| 
									
										
										
										
											2021-02-18 05:15:27 +08:00
										 |  |  |     EVP_CIPHER_free(cipher); | 
					
						
							| 
									
										
										
										
											2016-09-29 05:39:18 +08:00
										 |  |  |     release_engine(e); | 
					
						
							| 
									
										
										
										
											2006-03-28 20:34:45 +08:00
										 |  |  |     BIO_free_all(out); | 
					
						
							| 
									
										
										
										
											2015-05-01 22:02:07 +08:00
										 |  |  |     OPENSSL_free(passin); | 
					
						
							|  |  |  |     OPENSSL_free(passout); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-28 22:35:32 +08:00
										 |  |  |     return ret; | 
					
						
							| 
									
										
										
										
											2006-03-28 20:34:45 +08:00
										 |  |  | } |