Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80ef640063
|
||
|
|
2015c00c43
|
+93
-18
@@ -24,9 +24,36 @@ OpenSSL 3.0
|
|||||||
|
|
||||||
### Changes between 1.1.1 and 3.0 [xx XXX xxxx] ###
|
### Changes between 1.1.1 and 3.0 [xx XXX xxxx] ###
|
||||||
|
|
||||||
* `ASN1_verify()`, `ASN1_digest()` and `ASN1_sign()` have been deprecated.
|
* Deprecated EC_POINT_set_Jprojective_coordinates_GFp() and
|
||||||
|
EC_POINT_get_Jprojective_coordinates_GFp(). These functions are not widely
|
||||||
|
used and applications should instead use the
|
||||||
|
L<EC_POINT_set_affine_coordinates(3)> and
|
||||||
|
L<EC_POINT_get_affine_coordinates(3)> functions.
|
||||||
|
|
||||||
|
*Billy Bob Brumley*
|
||||||
|
|
||||||
|
* Added OSSL_PARAM_BLD to the public interface. This allows OSSL_PARAM
|
||||||
|
arrays to be more easily constructed via a series of utility functions.
|
||||||
|
Create a parameter builder using OSSL_PARAM_BLD_new(), add parameters using
|
||||||
|
the various push functions and finally convert to a passable OSSL_PARAM
|
||||||
|
array using OSSL_PARAM_BLD_to_param().
|
||||||
|
|
||||||
|
*Paul Dale*
|
||||||
|
|
||||||
|
* EVP_PKEY_get0_RSA(), EVP_PKEY_get0_DSA(), EVP_PKEY_get0_DH(), and
|
||||||
|
EVP_PKEY_get0_EC_KEY() can now handle EVP_PKEYs with provider side
|
||||||
|
internal keys, if they correspond to one of those built in types.
|
||||||
|
|
||||||
|
*Richard Levitte*
|
||||||
|
|
||||||
|
* Added EVP_PKEY_set_type_by_keymgmt(), to initialise an EVP_PKEY to
|
||||||
|
contain a provider side internal key.
|
||||||
|
|
||||||
|
*Richard Levitte*
|
||||||
|
|
||||||
|
* ASN1_verify(), ASN1_digest() and ASN1_sign() have been deprecated.
|
||||||
They are old functions that we don't use, and that you could disable with
|
They are old functions that we don't use, and that you could disable with
|
||||||
the macro `NO_ASN1_OLD`. This goes all the way back to OpenSSL 0.9.7.
|
the macro NO_ASN1_OLD. This goes all the way back to OpenSSL 0.9.7.
|
||||||
|
|
||||||
*Richard Levitte*
|
*Richard Levitte*
|
||||||
|
|
||||||
@@ -60,10 +87,17 @@ OpenSSL 3.0
|
|||||||
|
|
||||||
*Richard Levitte*
|
*Richard Levitte*
|
||||||
|
|
||||||
* The command line utilities ecparam and ec have been deprecated. Instead
|
* Added an implementation of CMP and CRMF (RFC 4210, RFC 4211 RFC 6712).
|
||||||
use the pkeyparam, pkey and genpkey programs.
|
This adds crypto/cmp/, crpyto/crmf/, and test/cmp_*.
|
||||||
|
See L<OSSL_CMP_exec_IR_ses(3)> as starting point.
|
||||||
|
|
||||||
*Paul Dale*
|
*David von Oheimb*
|
||||||
|
|
||||||
|
* Generalized the HTTP client code from crypto/ocsp/ into crpyto/http/.
|
||||||
|
The legacy OCSP-focused and only partly documented API is retained.
|
||||||
|
See L<OSSL_CMP_MSG_http_perform(3)> etc. for details.
|
||||||
|
|
||||||
|
*David von Oheimb*
|
||||||
|
|
||||||
* All of the low level RSA functions have been deprecated including:
|
* All of the low level RSA functions have been deprecated including:
|
||||||
|
|
||||||
@@ -119,25 +153,35 @@ OpenSSL 3.0
|
|||||||
*Kurt Roeckx*
|
*Kurt Roeckx*
|
||||||
|
|
||||||
* The command line utilities dhparam, dsa, gendsa and dsaparam have been
|
* The command line utilities dhparam, dsa, gendsa and dsaparam have been
|
||||||
deprecated. Instead use the pkeyparam, pkey, genpkey and pkeyparam
|
modified to use PKEY APIs. These commands are now in maintenance mode
|
||||||
programs respectively.
|
and no new features will be added to them.
|
||||||
|
|
||||||
|
*Paul Dale*
|
||||||
|
|
||||||
|
* The command line utility rsautl has been deprecated.
|
||||||
|
Instead use the pkeyutl program.
|
||||||
|
|
||||||
|
*Paul Dale*
|
||||||
|
|
||||||
|
* The command line utilities genrsa and rsa have been modified to use PKEY
|
||||||
|
APIs These commands are now in maintenance mode and no new features will
|
||||||
|
be added to them.
|
||||||
|
|
||||||
*Paul Dale*
|
*Paul Dale*
|
||||||
|
|
||||||
* All of the low level DH functions have been deprecated including:
|
* All of the low level DH functions have been deprecated including:
|
||||||
|
|
||||||
DH_OpenSSL, DH_set_default_method, DH_get_default_method, DH_set_method,
|
DH_OpenSSL, DH_set_default_method, DH_get_default_method,
|
||||||
DH_new_method, DH_bits, DH_size, DH_security_bits, DH_get_ex_new_index,
|
DH_set_method, DH_new_method, DH_bits, DH_size, DH_security_bits,
|
||||||
DH_set_ex_data, DH_get_ex_data, DH_generate_parameters_ex,
|
DH_get_ex_new_index, DH_set_ex_data, DH_get_ex_data,
|
||||||
DH_check_params_ex, DH_check_ex, DH_check_pub_key_ex,
|
DH_generate_parameters_ex, DH_check_params_ex, DH_check_ex,
|
||||||
DH_check, DH_check_pub_key, DH_generate_key, DH_compute_key,
|
DH_check_pub_key_ex, DH_check, DH_check_pub_key, DH_generate_key,
|
||||||
DH_compute_key_padded, DHparams_print_fp, DHparams_print, DH_get_nid,
|
DH_compute_key, DH_compute_key_padded, DHparams_print_fp,
|
||||||
DH_KDF_X9_42, DH_get0_engine, DH_get_length, DH_set_length, DH_meth_new,
|
DHparams_print, DH_get_nid, DH_KDF_X9_42, DH_get0_engine, DH_meth_new,
|
||||||
DH_meth_free, DH_meth_dup, DH_meth_get0_name, DH_meth_set1_name,
|
DH_meth_free, DH_meth_dup, DH_meth_get0_name, DH_meth_set1_name,
|
||||||
DH_meth_get_flags, DH_meth_set_flags, DH_meth_get0_app_data,
|
DH_meth_get_flags, DH_meth_set_flags, DH_meth_get0_app_data,
|
||||||
DH_meth_set0_app_data, DH_meth_get_generate_key,
|
DH_meth_set0_app_data, DH_meth_get_generate_key, DH_meth_set_generate_key,
|
||||||
DH_meth_set_generate_key, DH_meth_get_compute_key,
|
DH_meth_get_compute_key, DH_meth_set_compute_key, DH_meth_get_bn_mod_exp,
|
||||||
DH_meth_set_compute_key, DH_meth_get_bn_mod_exp,
|
|
||||||
DH_meth_set_bn_mod_exp, DH_meth_get_init, DH_meth_set_init,
|
DH_meth_set_bn_mod_exp, DH_meth_get_init, DH_meth_set_init,
|
||||||
DH_meth_get_finish, DH_meth_set_finish, DH_meth_get_generate_params
|
DH_meth_get_finish, DH_meth_set_finish, DH_meth_get_generate_params
|
||||||
and DH_meth_set_generate_params.
|
and DH_meth_set_generate_params.
|
||||||
@@ -374,6 +418,11 @@ OpenSSL 3.0
|
|||||||
|
|
||||||
*Rich Salz*
|
*Rich Salz*
|
||||||
|
|
||||||
|
* Added documentation for the STACK API. OpenSSL only defines the STACK
|
||||||
|
functions where they are used.
|
||||||
|
|
||||||
|
*Rich Salz*
|
||||||
|
|
||||||
* Introduced a new method type and API, OSSL_SERIALIZER, to
|
* Introduced a new method type and API, OSSL_SERIALIZER, to
|
||||||
represent generic serializers. An implementation is expected to
|
represent generic serializers. An implementation is expected to
|
||||||
be able to serialize an object associated with a given name (such
|
be able to serialize an object associated with a given name (such
|
||||||
@@ -938,7 +987,33 @@ OpenSSL 3.0
|
|||||||
OpenSSL 1.1.1
|
OpenSSL 1.1.1
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
### Changes between 1.1.1d and 1.1.1e [xx XXX xxxx] ###
|
### Changes between 1.1.1e and 1.1.1f [xx XXX xxxx] ###
|
||||||
|
|
||||||
|
|
||||||
|
### Changes between 1.1.1d and 1.1.1e [17 Mar 2020] ###
|
||||||
|
|
||||||
|
* Properly detect EOF while reading in libssl. Previously if we hit an EOF
|
||||||
|
while reading in libssl then we would report an error back to the
|
||||||
|
application (SSL_ERROR_SYSCALL) but errno would be 0. We now add
|
||||||
|
an error to the stack (which means we instead return SSL_ERROR_SSL) and
|
||||||
|
therefore give a hint as to what went wrong.
|
||||||
|
|
||||||
|
*Matt Caswell*
|
||||||
|
|
||||||
|
* Check that ed25519 and ed448 are allowed by the security level. Previously
|
||||||
|
signature algorithms not using an MD were not being checked that they were
|
||||||
|
allowed by the security level.
|
||||||
|
|
||||||
|
*Kurt Roeckx*
|
||||||
|
|
||||||
|
* Fixed SSL_get_servername() behaviour. The behaviour of SSL_get_servername()
|
||||||
|
was not quite right. The behaviour was not consistent between resumption
|
||||||
|
and normal handshakes, and also not quite consistent with historical
|
||||||
|
behaviour. The behaviour in various scenarios has been clarified and
|
||||||
|
it has been updated to make it match historical behaviour as closely as
|
||||||
|
possible.
|
||||||
|
|
||||||
|
*Matt Caswell*
|
||||||
|
|
||||||
* *[VMS only]* The header files that the VMS compilers include automatically,
|
* *[VMS only]* The header files that the VMS compilers include automatically,
|
||||||
`__DECC_INCLUDE_PROLOGUE.H` and `__DECC_INCLUDE_EPILOGUE.H`, use pragmas
|
`__DECC_INCLUDE_PROLOGUE.H` and `__DECC_INCLUDE_EPILOGUE.H`, use pragmas
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ my %targets=(
|
|||||||
includes => [],
|
includes => [],
|
||||||
lib_cflags => "",
|
lib_cflags => "",
|
||||||
lib_cppflags => "",
|
lib_cppflags => "",
|
||||||
lib_defines => [ 'OPENSSL_BUILDING_OPENSSL' ],
|
lib_defines => [],
|
||||||
thread_scheme => "(unknown)", # Assume we don't know
|
thread_scheme => "(unknown)", # Assume we don't know
|
||||||
thread_defines => [],
|
thread_defines => [],
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ my %targets=(
|
|||||||
|
|
||||||
defines =>
|
defines =>
|
||||||
sub {
|
sub {
|
||||||
my @defs = ();
|
my @defs = ( 'OPENSSL_BUILDING_OPENSSL' );
|
||||||
push @defs, "ZLIB" unless $disabled{zlib};
|
push @defs, "ZLIB" unless $disabled{zlib};
|
||||||
push @defs, "ZLIB_SHARED" unless $disabled{"zlib-dynamic"};
|
push @defs, "ZLIB_SHARED" unless $disabled{"zlib-dynamic"};
|
||||||
return [ @defs ];
|
return [ @defs ];
|
||||||
|
|||||||
@@ -24,17 +24,17 @@
|
|||||||
|
|
||||||
my $ndk_var;
|
my $ndk_var;
|
||||||
my $ndk;
|
my $ndk;
|
||||||
foreach (qw(ANDROID_NDK_HOME ANDROID_NDK)) {
|
foreach (qw(ANDROID_NDK_ROOT ANDROID_NDK)) {
|
||||||
$ndk_var = $_;
|
$ndk_var = $_;
|
||||||
$ndk = $ENV{$ndk_var};
|
$ndk = $ENV{$ndk_var};
|
||||||
last if defined $ndk;
|
last if defined $ndk;
|
||||||
}
|
}
|
||||||
die "\$ANDROID_NDK_HOME is not defined" if (!$ndk);
|
die "\$ANDROID_NDK_ROOT is not defined" if (!$ndk);
|
||||||
if (!-d "$ndk/platforms" && !-f "$ndk/AndroidVersion.txt") {
|
if (!-d "$ndk/platforms" && !-f "$ndk/AndroidVersion.txt") {
|
||||||
# $ndk/platforms is traditional "all-inclusive" NDK, while
|
# $ndk/platforms is traditional "all-inclusive" NDK, while
|
||||||
# $ndk/AndroidVersion.txt is so-called standalone toolchain
|
# $ndk/AndroidVersion.txt is so-called standalone toolchain
|
||||||
# tailored for specific target down to API level.
|
# tailored for specific target down to API level.
|
||||||
die "\$ANDROID_NDK_HOME=$ndk is invalid";
|
die "\$ANDROID_NDK_ROOT=$ndk is invalid";
|
||||||
}
|
}
|
||||||
$ndk = canonpath($ndk);
|
$ndk = canonpath($ndk);
|
||||||
|
|
||||||
@@ -168,7 +168,8 @@ my %targets = (
|
|||||||
cppflags => add(sub { android_ndk()->{cppflags} }),
|
cppflags => add(sub { android_ndk()->{cppflags} }),
|
||||||
cxxflags => add(sub { android_ndk()->{cflags} }),
|
cxxflags => add(sub { android_ndk()->{cflags} }),
|
||||||
bn_ops => sub { android_ndk()->{bn_ops} },
|
bn_ops => sub { android_ndk()->{bn_ops} },
|
||||||
bin_cflags => "-pie",
|
bin_cflags => "-fPIE",
|
||||||
|
bin_lflags => "-pie",
|
||||||
enable => [ ],
|
enable => [ ],
|
||||||
},
|
},
|
||||||
"android-arm" => {
|
"android-arm" => {
|
||||||
|
|||||||
@@ -50,6 +50,10 @@
|
|||||||
grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
|
grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
|
||||||
&& $unified_info{attributes}->{modules}->{$_}->{engine} }
|
&& $unified_info{attributes}->{modules}->{$_}->{engine} }
|
||||||
@{$unified_info{modules}};
|
@{$unified_info{modules}};
|
||||||
|
our @install_modules =
|
||||||
|
grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
|
||||||
|
&& !$unified_info{attributes}->{modules}->{$_}->{engine} }
|
||||||
|
@{$unified_info{modules}};
|
||||||
our @install_programs =
|
our @install_programs =
|
||||||
grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
|
grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
|
||||||
@{$unified_info{programs}};
|
@{$unified_info{programs}};
|
||||||
@@ -132,6 +136,7 @@ GENERATED={- # common0.tmpl provides @generated
|
|||||||
INSTALL_LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @install_libs) -}
|
INSTALL_LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @install_libs) -}
|
||||||
INSTALL_SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @install_shlibs) -}
|
INSTALL_SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @install_shlibs) -}
|
||||||
INSTALL_ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @install_engines) -}
|
INSTALL_ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @install_engines) -}
|
||||||
|
INSTALL_MODULES={- join(", ", map { "-\n\t".$_.".EXE" } @install_modules) -}
|
||||||
INSTALL_PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @install_programs) -}
|
INSTALL_PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @install_programs) -}
|
||||||
BIN_SCRIPTS={- join(", ", @install_bin_scripts) -}
|
BIN_SCRIPTS={- join(", ", @install_bin_scripts) -}
|
||||||
MISC_SCRIPTS={- join(", ", @install_misc_scripts) -}
|
MISC_SCRIPTS={- join(", ", @install_misc_scripts) -}
|
||||||
@@ -521,11 +526,11 @@ descrip.mms : FORCE
|
|||||||
|
|
||||||
# Install helper targets #############################################
|
# Install helper targets #############################################
|
||||||
|
|
||||||
install_sw : install_dev install_engines install_runtime -
|
install_sw : install_dev install_engines install_modules -
|
||||||
install_startup install_ivp
|
install_runtime install_startup install_ivp
|
||||||
|
|
||||||
uninstall_sw : uninstall_dev uninstall_engines uninstall_runtime -
|
uninstall_sw : uninstall_dev uninstall_modules uninstall_engines -
|
||||||
uninstall_startup uninstall_ivp
|
uninstall_runtime uninstall_startup uninstall_ivp
|
||||||
|
|
||||||
install_docs : install_html_docs
|
install_docs : install_html_docs
|
||||||
|
|
||||||
@@ -566,13 +571,22 @@ install_dev : check_INSTALLTOP install_runtime_libs
|
|||||||
|
|
||||||
install_engines : check_INSTALLTOP install_runtime_libs build_modules
|
install_engines : check_INSTALLTOP install_runtime_libs build_modules
|
||||||
@ {- output_off() unless scalar @install_engines; "" -} !
|
@ {- output_off() unless scalar @install_engines; "" -} !
|
||||||
@ WRITE SYS$OUTPUT "*** Installing ENGINE modules"
|
@ WRITE SYS$OUTPUT "*** Installing engines"
|
||||||
- CREATE/DIR ossl_installroot:[ENGINES{- $sover_dirname.$target{pointer_size} -}.'arch']
|
- CREATE/DIR ossl_installroot:[ENGINES{- $sover_dirname.$target{pointer_size} -}.'arch']
|
||||||
{- join("\n ",
|
{- join("\n ",
|
||||||
map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[ENGINES$sover_dirname$target{pointer_size}.'arch']" }
|
map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[ENGINES$sover_dirname$target{pointer_size}.'arch']" }
|
||||||
@install_engines) -}
|
@install_engines) -}
|
||||||
@ {- output_on() unless scalar @install_engines; "" -} !
|
@ {- output_on() unless scalar @install_engines; "" -} !
|
||||||
|
|
||||||
|
install_modules : check_INSTALLTOP install_runtime_libs build_modules
|
||||||
|
@ {- output_off() unless scalar @install_modules; "" -} !
|
||||||
|
@ WRITE SYS$OUTPUT "*** Installing modules"
|
||||||
|
- CREATE/DIR ossl_installroot:[MODULES{- $sover_dirname.$target{pointer_size} -}.'arch']
|
||||||
|
{- join("\n ",
|
||||||
|
map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[MODULES$sover_dirname$target{pointer_size}.'arch']" }
|
||||||
|
@install_modules) -}
|
||||||
|
@ {- output_on() unless scalar @install_modules; "" -} !
|
||||||
|
|
||||||
install_runtime : install_programs
|
install_runtime : install_programs
|
||||||
|
|
||||||
install_runtime_libs : check_INSTALLTOP build_libs
|
install_runtime_libs : check_INSTALLTOP build_libs
|
||||||
|
|||||||
@@ -138,6 +138,14 @@ INSTALL_ENGINES={-
|
|||||||
&& $unified_info{attributes}->{modules}->{$_}->{engine} }
|
&& $unified_info{attributes}->{modules}->{$_}->{engine} }
|
||||||
@{$unified_info{modules}}))
|
@{$unified_info{modules}}))
|
||||||
-}
|
-}
|
||||||
|
INSTALL_MODULES={-
|
||||||
|
join(" \\\n" . ' ' x 16,
|
||||||
|
fill_lines(" ", $COLUMNS - 16,
|
||||||
|
map { platform->dso($_) }
|
||||||
|
grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
|
||||||
|
&& !$unified_info{attributes}->{modules}->{$_}->{engine} }
|
||||||
|
@{$unified_info{modules}}))
|
||||||
|
-}
|
||||||
INSTALL_PROGRAMS={-
|
INSTALL_PROGRAMS={-
|
||||||
join(" \\\n" . ' ' x 16,
|
join(" \\\n" . ' ' x 16,
|
||||||
fill_lines(" ", $COLUMNS - 16, map { platform->bin($_) }
|
fill_lines(" ", $COLUMNS - 16, map { platform->bin($_) }
|
||||||
@@ -532,9 +540,9 @@ depend:
|
|||||||
|
|
||||||
# Install helper targets #############################################
|
# Install helper targets #############################################
|
||||||
|
|
||||||
install_sw: install_dev install_engines install_runtime
|
install_sw: install_dev install_engines install_modules install_runtime
|
||||||
|
|
||||||
uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
|
uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev
|
||||||
|
|
||||||
install_docs: install_man_docs install_html_docs
|
install_docs: install_man_docs install_html_docs
|
||||||
|
|
||||||
@@ -702,10 +710,12 @@ uninstall_dev: uninstall_runtime_libs
|
|||||||
-$(RMDIR) $(DESTDIR)$(libdir)/pkgconfig
|
-$(RMDIR) $(DESTDIR)$(libdir)/pkgconfig
|
||||||
-$(RMDIR) $(DESTDIR)$(libdir)
|
-$(RMDIR) $(DESTDIR)$(libdir)
|
||||||
|
|
||||||
install_engines: install_runtime_libs build_modules
|
_install_modules_deps: install_runtime_libs build_modules
|
||||||
|
|
||||||
|
install_engines: _install_modules_deps
|
||||||
@[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
|
@[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
|
||||||
@$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
|
@$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
|
||||||
@$(ECHO) "*** Installing ENGINE modules"
|
@$(ECHO) "*** Installing engines"
|
||||||
@set -e; for e in dummy $(INSTALL_ENGINES); do \
|
@set -e; for e in dummy $(INSTALL_ENGINES); do \
|
||||||
if [ "$$e" = "dummy" ]; then continue; fi; \
|
if [ "$$e" = "dummy" ]; then continue; fi; \
|
||||||
fn=`basename $$e`; \
|
fn=`basename $$e`; \
|
||||||
@@ -717,7 +727,7 @@ install_engines: install_runtime_libs build_modules
|
|||||||
done
|
done
|
||||||
|
|
||||||
uninstall_engines:
|
uninstall_engines:
|
||||||
@$(ECHO) "*** Uninstalling ENGINE modules"
|
@$(ECHO) "*** Uninstalling engines"
|
||||||
@set -e; for e in dummy $(INSTALL_ENGINES); do \
|
@set -e; for e in dummy $(INSTALL_ENGINES); do \
|
||||||
if [ "$$e" = "dummy" ]; then continue; fi; \
|
if [ "$$e" = "dummy" ]; then continue; fi; \
|
||||||
fn=`basename $$e`; \
|
fn=`basename $$e`; \
|
||||||
@@ -729,6 +739,33 @@ uninstall_engines:
|
|||||||
done
|
done
|
||||||
-$(RMDIR) $(DESTDIR)$(ENGINESDIR)
|
-$(RMDIR) $(DESTDIR)$(ENGINESDIR)
|
||||||
|
|
||||||
|
install_modules: _install_modules_deps
|
||||||
|
@[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
|
||||||
|
@$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MODULESDIR)/
|
||||||
|
@$(ECHO) "*** Installing modules"
|
||||||
|
@set -e; for e in dummy $(INSTALL_MODULES); do \
|
||||||
|
if [ "$$e" = "dummy" ]; then continue; fi; \
|
||||||
|
fn=`basename $$e`; \
|
||||||
|
$(ECHO) "install $$e -> $(DESTDIR)$(MODULESDIR)/$$fn"; \
|
||||||
|
cp $$e $(DESTDIR)$(MODULESDIR)/$$fn.new; \
|
||||||
|
chmod 755 $(DESTDIR)$(MODULESDIR)/$$fn.new; \
|
||||||
|
mv -f $(DESTDIR)$(MODULESDIR)/$$fn.new \
|
||||||
|
$(DESTDIR)$(MODULESDIR)/$$fn; \
|
||||||
|
done
|
||||||
|
|
||||||
|
uninstall_modules:
|
||||||
|
@$(ECHO) "*** Uninstalling modules"
|
||||||
|
@set -e; for e in dummy $(INSTALL_MODULES); do \
|
||||||
|
if [ "$$e" = "dummy" ]; then continue; fi; \
|
||||||
|
fn=`basename $$e`; \
|
||||||
|
if [ "$$fn" = '{- platform->dso("ossltest") -}' ]; then \
|
||||||
|
continue; \
|
||||||
|
fi; \
|
||||||
|
$(ECHO) "$(RM) $(DESTDIR)$(MODULESDIR)/$$fn"; \
|
||||||
|
$(RM) $(DESTDIR)$(MODULESDIR)/$$fn; \
|
||||||
|
done
|
||||||
|
-$(RMDIR) $(DESTDIR)$(MODULESDIR)
|
||||||
|
|
||||||
install_runtime: install_programs
|
install_runtime: install_programs
|
||||||
|
|
||||||
install_runtime_libs: build_libs
|
install_runtime_libs: build_libs
|
||||||
@@ -983,6 +1020,7 @@ generate_crypto_objects:
|
|||||||
crypto/objects/obj_mac.num \
|
crypto/objects/obj_mac.num \
|
||||||
crypto/objects/obj_xref.txt \
|
crypto/objects/obj_xref.txt \
|
||||||
> crypto/objects/obj_xref.h )
|
> crypto/objects/obj_xref.h )
|
||||||
|
( cd $(SRCDIR); cat crypto/objects/obj_compat.h >> include/openssl/obj_mac.h )
|
||||||
|
|
||||||
generate_crypto_conf:
|
generate_crypto_conf:
|
||||||
( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
|
( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
|
||||||
@@ -1025,6 +1063,7 @@ errors:
|
|||||||
qw( include/internal/dso.h
|
qw( include/internal/dso.h
|
||||||
include/internal/o_dir.h
|
include/internal/o_dir.h
|
||||||
include/internal/err.h
|
include/internal/err.h
|
||||||
|
include/internal/evp.h
|
||||||
include/internal/sslconf.h );
|
include/internal/sslconf.h );
|
||||||
our @cryptoskipheaders = ( @sslheaders,
|
our @cryptoskipheaders = ( @sslheaders,
|
||||||
qw( include/openssl/conf_api.h
|
qw( include/openssl/conf_api.h
|
||||||
|
|||||||
@@ -47,19 +47,22 @@ SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
|
|||||||
LIBS={- join(" ", map { ( platform->sharedlib_import($_), platform->staticlib($_) ) } @{$unified_info{libraries}}) -}
|
LIBS={- join(" ", map { ( platform->sharedlib_import($_), platform->staticlib($_) ) } @{$unified_info{libraries}}) -}
|
||||||
SHLIBS={- join(" ", map { platform->sharedlib($_) // () } @{$unified_info{libraries}}) -}
|
SHLIBS={- join(" ", map { platform->sharedlib($_) // () } @{$unified_info{libraries}}) -}
|
||||||
SHLIBPDBS={- join(" ", map { platform->sharedlibpdb($_) // () } @{$unified_info{libraries}}) -}
|
SHLIBPDBS={- join(" ", map { platform->sharedlibpdb($_) // () } @{$unified_info{libraries}}) -}
|
||||||
MODULES={- join(" ", map { platform->dso($_) } @{$unified_info{modules}}) -}
|
MODULES={- our @MODULES = map { platform->dso($_) } @{$unified_info{modules}};
|
||||||
|
join(" ", @MODULES) -}
|
||||||
MODULEPDBS={- join(" ", map { platform->dsopdb($_) } @{$unified_info{modules}}) -}
|
MODULEPDBS={- join(" ", map { platform->dsopdb($_) } @{$unified_info{modules}}) -}
|
||||||
PROGRAMS={- our @PROGRAMS = map { platform->bin($_) } @{$unified_info{programs}}; join(" ", @PROGRAMS) -}
|
PROGRAMS={- our @PROGRAMS = map { platform->bin($_) } @{$unified_info{programs}}; join(" ", @PROGRAMS) -}
|
||||||
PROGRAMPDBS={- join(" ", map { $_.".pdb" } @{$unified_info{programs}}) -}
|
PROGRAMPDBS={- join(" ", map { $_.".pdb" } @{$unified_info{programs}}) -}
|
||||||
SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
|
SCRIPTS={- our @SCRIPTS = @{$unified_info{scripts}}; join(" ", @SCRIPTS) -}
|
||||||
{- output_off() if $disabled{makedepend}; "" -}
|
{- output_off() if $disabled{makedepend}; "" -}
|
||||||
DEPS={- join(" ", map { platform->isobj($_) ? platform->dep($_) : () }
|
DEPS={- join(" ", map { platform->isobj($_) ? platform->dep($_) : () }
|
||||||
grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
|
grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
|
||||||
keys %{$unified_info{sources}}); -}
|
keys %{$unified_info{sources}}); -}
|
||||||
{- output_on() if $disabled{makedepend}; "" -}
|
{- output_on() if $disabled{makedepend}; "" -}
|
||||||
GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -}
|
GENERATED_MANDATORY={- our @GENERATED_MANDATORY = @{$unified_info{depends}->{""}};
|
||||||
|
join(" ", @GENERATED_MANDATORY) -}
|
||||||
GENERATED={- # common0.tmpl provides @generated
|
GENERATED={- # common0.tmpl provides @generated
|
||||||
join(" ", map { platform->convertext($_) } @generated) -}
|
our @GENERATED = map { platform->convertext($_) } @generated;
|
||||||
|
join(" ", @GENERATED) -}
|
||||||
|
|
||||||
INSTALL_LIBS={-
|
INSTALL_LIBS={-
|
||||||
join(" ", map { quotify1(platform->sharedlib_import($_)
|
join(" ", map { quotify1(platform->sharedlib_import($_)
|
||||||
@@ -91,6 +94,20 @@ INSTALL_ENGINEPDBS={-
|
|||||||
&& $unified_info{attributes}->{modules}->{$_}->{engine} }
|
&& $unified_info{attributes}->{modules}->{$_}->{engine} }
|
||||||
@{$unified_info{modules}})
|
@{$unified_info{modules}})
|
||||||
-}
|
-}
|
||||||
|
INSTALL_MODULES={-
|
||||||
|
join(" \\\n" . ' ' x 16,
|
||||||
|
fill_lines(" ", $COLUMNS - 16,
|
||||||
|
map { platform->dso($_) }
|
||||||
|
grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
|
||||||
|
&& !$unified_info{attributes}->{modules}->{$_}->{engine} }
|
||||||
|
@{$unified_info{modules}}))
|
||||||
|
-}
|
||||||
|
INSTALL_MODULEPDBS={-
|
||||||
|
join(" ", map { quotify1(platform->dsopdb($_)) }
|
||||||
|
grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
|
||||||
|
&& !$unified_info{attributes}->{modules}->{$_}->{engine} }
|
||||||
|
@{$unified_info{modules}})
|
||||||
|
-}
|
||||||
INSTALL_PROGRAMS={-
|
INSTALL_PROGRAMS={-
|
||||||
join(" ", map { quotify1(platform->bin($_)) }
|
join(" ", map { quotify1(platform->bin($_)) }
|
||||||
grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
|
grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
|
||||||
@@ -417,10 +434,10 @@ clean: libclean
|
|||||||
-rmdir /Q /S $(HTMLDOCS5_BLDDIRS)
|
-rmdir /Q /S $(HTMLDOCS5_BLDDIRS)
|
||||||
-rmdir /Q /S $(HTMLDOCS7_BLDDIRS)
|
-rmdir /Q /S $(HTMLDOCS7_BLDDIRS)
|
||||||
{- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) -}
|
{- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) -}
|
||||||
-del /Q /F $(MODULES)
|
{- join("\n\t", map { "-del /Q /F $_" } @MODULES) -}
|
||||||
-del /Q /F $(SCRIPTS)
|
{- join("\n\t", map { "-del /Q /F $_" } @SCRIPTS) -}
|
||||||
-del /Q /F $(GENERATED_MANDATORY)
|
{- join("\n\t", map { "-del /Q /F $_" } @GENERATED_MANDATORY) -}
|
||||||
-del /Q /F $(GENERATED)
|
{- join("\n\t", map { "-del /Q /F $_" } @GENERATED) -}
|
||||||
-del /Q /S /F *.d *.obj *.pdb *.ilk *.manifest
|
-del /Q /S /F *.d *.obj *.pdb *.ilk *.manifest
|
||||||
-del /Q /S /F engines\*.lib engines\*.exp
|
-del /Q /S /F engines\*.lib engines\*.exp
|
||||||
-del /Q /S /F apps\*.lib apps\*.rc apps\*.res apps\*.exp
|
-del /Q /S /F apps\*.lib apps\*.rc apps\*.res apps\*.exp
|
||||||
@@ -438,9 +455,9 @@ depend:
|
|||||||
|
|
||||||
# Install helper targets #############################################
|
# Install helper targets #############################################
|
||||||
|
|
||||||
install_sw: install_dev install_engines install_runtime
|
install_sw: install_dev install_engines install_modules install_runtime
|
||||||
|
|
||||||
uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
|
uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev
|
||||||
|
|
||||||
install_docs: install_html_docs
|
install_docs: install_html_docs
|
||||||
|
|
||||||
@@ -484,9 +501,11 @@ install_dev: install_runtime_libs
|
|||||||
|
|
||||||
uninstall_dev:
|
uninstall_dev:
|
||||||
|
|
||||||
install_engines: install_runtime_libs build_modules
|
_install_modules_deps: install_runtime_libs build_modules
|
||||||
|
|
||||||
|
install_engines: _install_modules_deps
|
||||||
@if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
|
@if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
|
||||||
@$(ECHO) "*** Installing ENGINE modules"
|
@$(ECHO) "*** Installing engines"
|
||||||
@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
|
@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
|
||||||
@if not "$(INSTALL_ENGINES)"=="" \
|
@if not "$(INSTALL_ENGINES)"=="" \
|
||||||
"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
|
"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
|
||||||
@@ -495,6 +514,17 @@ install_engines: install_runtime_libs build_modules
|
|||||||
|
|
||||||
uninstall_engines:
|
uninstall_engines:
|
||||||
|
|
||||||
|
install_modules: _install_modules_deps
|
||||||
|
@if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
|
||||||
|
@$(ECHO) "*** Installing modules"
|
||||||
|
@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(MODULESDIR)"
|
||||||
|
@if not "$(INSTALL_MODULES)"=="" \
|
||||||
|
"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_MODULES) "$(MODULESDIR)"
|
||||||
|
@if not "$(INSTALL_MODULES)"=="" \
|
||||||
|
"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_MODULEPDBS) "$(MODULESDIR)"
|
||||||
|
|
||||||
|
uninstall_modules:
|
||||||
|
|
||||||
install_runtime: install_programs
|
install_runtime: install_programs
|
||||||
|
|
||||||
install_runtime_libs: build_libs
|
install_runtime_libs: build_libs
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#! /usr/bin/env perl
|
#! /usr/bin/env perl
|
||||||
# -*- mode: perl; -*-
|
# -*- mode: perl; -*-
|
||||||
# Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
|
# Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
# this file except in compliance with the License. You can obtain a copy
|
# this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -286,7 +286,13 @@ collect_information(
|
|||||||
qr/\s*(\w+)\s*=\s*(.*?)\s*$/ =>
|
qr/\s*(\w+)\s*=\s*(.*?)\s*$/ =>
|
||||||
sub {
|
sub {
|
||||||
# Only define it if there is a value at all
|
# Only define it if there is a value at all
|
||||||
$version{uc $1} = $2 if $2 ne '';
|
if ($2 ne '') {
|
||||||
|
my $k = $1;
|
||||||
|
my $v = $2;
|
||||||
|
# Some values are quoted. Trim the quotes
|
||||||
|
$v = $1 if $v =~ /^"(.*)"$/;
|
||||||
|
$version{uc $k} = $v;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"OTHERWISE" =>
|
"OTHERWISE" =>
|
||||||
sub { die "Something wrong with this line:\n$_\nin $srcdir/VERSION" },
|
sub { die "Something wrong with this line:\n$_\nin $srcdir/VERSION" },
|
||||||
@@ -518,7 +524,7 @@ my @disable_cascades = (
|
|||||||
"ssl3-method" => [ "ssl3" ],
|
"ssl3-method" => [ "ssl3" ],
|
||||||
"zlib" => [ "zlib-dynamic" ],
|
"zlib" => [ "zlib-dynamic" ],
|
||||||
"des" => [ "mdc2" ],
|
"des" => [ "mdc2" ],
|
||||||
"ec" => [ "ecdsa", "ecdh", "sm2" ],
|
"ec" => [ "ecdsa", "ecdh", "sm2", "gost" ],
|
||||||
sub { $disabled{"ec"} && $disabled{"dh"} }
|
sub { $disabled{"ec"} && $disabled{"dh"} }
|
||||||
=> [ "tls1_3" ],
|
=> [ "tls1_3" ],
|
||||||
"dgram" => [ "dtls", "sctp" ],
|
"dgram" => [ "dtls", "sctp" ],
|
||||||
|
|||||||
+18
-3
@@ -207,6 +207,9 @@ To avoid breaking other applications, install your copy of OpenSSL to a
|
|||||||
[different location](#installing-to-a-different-location) which is not in
|
[different location](#installing-to-a-different-location) which is not in
|
||||||
the global search path for system libraries.
|
the global search path for system libraries.
|
||||||
|
|
||||||
|
Finally, if you plan on using the FIPS module, you need to read the
|
||||||
|
[Post-installation Notes](#post-installation-notes) further down.
|
||||||
|
|
||||||
### Unix / Linux / macOS ###
|
### Unix / Linux / macOS ###
|
||||||
|
|
||||||
Depending on your distribution, you need to run the following command as
|
Depending on your distribution, you need to run the following command as
|
||||||
@@ -861,11 +864,11 @@ never be used in production environments. It will only work when used with gcc
|
|||||||
or clang and should be used in conjunction with the `-DPEDANTIC` option
|
or clang and should be used in conjunction with the `-DPEDANTIC` option
|
||||||
(or the `--strict-warnings` option).
|
(or the `--strict-warnings` option).
|
||||||
|
|
||||||
### no-ui ###
|
### no-ui-console ###
|
||||||
|
|
||||||
Don't build with the User Interface (UI) capability
|
Don't build with the User Interface (UI) console method
|
||||||
|
|
||||||
The User Interface is the set of features enabling text based prompts.
|
The User Interface console method enables text based console prompts.
|
||||||
|
|
||||||
### enable-unit-test ###
|
### enable-unit-test ###
|
||||||
|
|
||||||
@@ -1344,6 +1347,18 @@ Some APIs have changed as well. However, older APIs have been preserved when
|
|||||||
possible.
|
possible.
|
||||||
|
|
||||||
|
|
||||||
|
Post-installation Notes
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
With the default OpenSSL installation comes a FIPS provider module, which
|
||||||
|
needs some post-installation attention, without which it will not be usable.
|
||||||
|
This involves using the following command:
|
||||||
|
|
||||||
|
openssl fipsinstall
|
||||||
|
|
||||||
|
See the openssl-fipsinstall(1) manual for details and examples.
|
||||||
|
|
||||||
|
|
||||||
Advanced Build Options
|
Advanced Build Options
|
||||||
======================
|
======================
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ OpenSSL 3.0
|
|||||||
|
|
||||||
### Major changes between OpenSSL 1.1.1 and OpenSSL 3.0 [under development] ###
|
### Major changes between OpenSSL 1.1.1 and OpenSSL 3.0 [under development] ###
|
||||||
|
|
||||||
|
* The X25519, X448, Ed25519, Ed448 and SHAKE256 algorithms are included in
|
||||||
|
the FIPS provider. None have the "fips=yes" property set and, as such,
|
||||||
|
will not be accidentially used.
|
||||||
* The algorithm specific public key command line applications have
|
* The algorithm specific public key command line applications have
|
||||||
been deprecated. These include dhparam, gendsa and others. The pkey
|
been deprecated. These include dhparam, gendsa and others. The pkey
|
||||||
alternatives should be used intead: pkey, pkeyparam and genpkey.
|
alternatives should be used intead: pkey, pkeyparam and genpkey.
|
||||||
@@ -30,7 +33,14 @@ OpenSSL 3.0
|
|||||||
authenticate servers or clients.
|
authenticate servers or clients.
|
||||||
* enable-crypto-mdebug and enable-crypto-mdebug-backtrace were mostly
|
* enable-crypto-mdebug and enable-crypto-mdebug-backtrace were mostly
|
||||||
disabled; the project uses address sanitize/leak-detect instead.
|
disabled; the project uses address sanitize/leak-detect instead.
|
||||||
|
* Added a Certificate Management Protocol (CMP, RFC 4210) implementation
|
||||||
|
also covering CRMF (RFC 4211) and HTTP transfer (RFC 6712).
|
||||||
|
It is part of the crypto lib, while a 'cmp' app using it is in preparation.
|
||||||
|
All widely used CMP features are supported for both clients and servers.
|
||||||
|
* Added a proper HTTP(S) client to libcrypto supporting GET and POST,
|
||||||
|
redirection, plain and ASN.1-encoded contents, proxies, and timeouts.
|
||||||
* Added OSSL_SERIALIZER, a generic serializer API.
|
* Added OSSL_SERIALIZER, a generic serializer API.
|
||||||
|
* Added OSSL_PARAM_BLD, an easier to use API to OSSL_PARAM.
|
||||||
* Added error raising macros, ERR_raise() and ERR_raise_data().
|
* Added error raising macros, ERR_raise() and ERR_raise_data().
|
||||||
* Deprecated ERR_put_error().
|
* Deprecated ERR_put_error().
|
||||||
* Added OSSL_PROVIDER_available(), to check provider availibility.
|
* Added OSSL_PROVIDER_available(), to check provider availibility.
|
||||||
@@ -57,6 +67,15 @@ OpenSSL 3.0
|
|||||||
OpenSSL 1.1.1
|
OpenSSL 1.1.1
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
### Major changes between OpenSSL 1.1.1e and OpenSSL 1.1.1f [under development] ###
|
||||||
|
|
||||||
|
*
|
||||||
|
|
||||||
|
### Major changes between OpenSSL 1.1.1d and OpenSSL 1.1.1e [17 Mar 2020] ###
|
||||||
|
|
||||||
|
* Fixed an overflow bug in the x64_64 Montgomery squaring procedure
|
||||||
|
used in exponentiation with 512-bit moduli ([CVE-2019-1551][])
|
||||||
|
|
||||||
### Major changes between OpenSSL 1.1.1c and OpenSSL 1.1.1d [10 Sep 2019] ###
|
### Major changes between OpenSSL 1.1.1c and OpenSSL 1.1.1d [10 Sep 2019] ###
|
||||||
|
|
||||||
* Fixed a fork protection issue ([CVE-2019-1549][])
|
* Fixed a fork protection issue ([CVE-2019-1549][])
|
||||||
@@ -1295,6 +1314,7 @@ OpenSSL 0.9.x
|
|||||||
[CVE-2019-1563]: https://www.openssl.org/news/vulnerabilities.html#CVE-2019-1563
|
[CVE-2019-1563]: https://www.openssl.org/news/vulnerabilities.html#CVE-2019-1563
|
||||||
[CVE-2019-1559]: https://www.openssl.org/news/vulnerabilities.html#CVE-2019-1559
|
[CVE-2019-1559]: https://www.openssl.org/news/vulnerabilities.html#CVE-2019-1559
|
||||||
[CVE-2019-1552]: https://www.openssl.org/news/vulnerabilities.html#CVE-2019-1552
|
[CVE-2019-1552]: https://www.openssl.org/news/vulnerabilities.html#CVE-2019-1552
|
||||||
|
[CVE-2019-1551]: https://www.openssl.org/news/vulnerabilities.html#CVE-2019-1551
|
||||||
[CVE-2019-1549]: https://www.openssl.org/news/vulnerabilities.html#CVE-2019-1549
|
[CVE-2019-1549]: https://www.openssl.org/news/vulnerabilities.html#CVE-2019-1549
|
||||||
[CVE-2019-1547]: https://www.openssl.org/news/vulnerabilities.html#CVE-2019-1547
|
[CVE-2019-1547]: https://www.openssl.org/news/vulnerabilities.html#CVE-2019-1547
|
||||||
[CVE-2019-1543]: https://www.openssl.org/news/vulnerabilities.html#CVE-2019-1543
|
[CVE-2019-1543]: https://www.openssl.org/news/vulnerabilities.html#CVE-2019-1543
|
||||||
|
|||||||
+8
-8
@@ -24,7 +24,7 @@
|
|||||||
need to know the prefix to extend your PATH, in order to invoke
|
need to know the prefix to extend your PATH, in order to invoke
|
||||||
$(CROSS_COMPILE)clang [*gcc on NDK 19 and lower] and company. (Configure
|
$(CROSS_COMPILE)clang [*gcc on NDK 19 and lower] and company. (Configure
|
||||||
will fail and give you a hint if you get it wrong.) Apart from PATH
|
will fail and give you a hint if you get it wrong.) Apart from PATH
|
||||||
adjustment you need to set ANDROID_NDK_HOME environment to point at the
|
adjustment you need to set ANDROID_NDK_ROOT environment to point at the
|
||||||
NDK directory. If you're using a side-by-side NDK the path will look
|
NDK directory. If you're using a side-by-side NDK the path will look
|
||||||
something like /some/where/android-sdk/ndk/<ver>, and for a standalone
|
something like /some/where/android-sdk/ndk/<ver>, and for a standalone
|
||||||
NDK the path will be something like /some/where/android-ndk-<ver>.
|
NDK the path will be something like /some/where/android-ndk-<ver>.
|
||||||
@@ -35,21 +35,21 @@
|
|||||||
with N being the numerical value of the target platform version. For example,
|
with N being the numerical value of the target platform version. For example,
|
||||||
to compile for Android 10 arm64 with a side-by-side NDK r20.0.5594570
|
to compile for Android 10 arm64 with a side-by-side NDK r20.0.5594570
|
||||||
|
|
||||||
export ANDROID_NDK_HOME=/home/whoever/Android/android-sdk/ndk/20.0.5594570
|
export ANDROID_NDK_ROOT=/home/whoever/Android/android-sdk/ndk/20.0.5594570
|
||||||
PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$ANDROID_NDK_HOME/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin:$PATH
|
PATH=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin:$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin:$PATH
|
||||||
./Configure android-arm64 -D__ANDROID_API__=29
|
./Configure android-arm64 -D__ANDROID_API__=29
|
||||||
make
|
make
|
||||||
|
|
||||||
Older versions of the NDK have GCC under their common prebuilt tools directory, so the bin path
|
Older versions of the NDK have GCC under their common prebuilt tools directory, so the bin path
|
||||||
will be slightly different. EG: to compile for ICS on ARM with NDK 10d:
|
will be slightly different. EG: to compile for ICS on ARM with NDK 10d:
|
||||||
|
|
||||||
export ANDROID_NDK_HOME=/some/where/android-ndk-10d
|
export ANDROID_NDK_ROOT=/some/where/android-ndk-10d
|
||||||
PATH=$ANDROID_NDK_HOME/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin:$PATH
|
PATH=$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin:$PATH
|
||||||
./Configure android-arm -D__ANDROID_API__=14
|
./Configure android-arm -D__ANDROID_API__=14
|
||||||
make
|
make
|
||||||
|
|
||||||
Caveat lector! Earlier OpenSSL versions relied on additional CROSS_SYSROOT
|
Caveat lector! Earlier OpenSSL versions relied on additional CROSS_SYSROOT
|
||||||
variable set to $ANDROID_NDK_HOME/platforms/android-<api>/arch-<arch> to
|
variable set to $ANDROID_NDK_ROOT/platforms/android-<api>/arch-<arch> to
|
||||||
appoint headers-n-libraries' location. It's still recognized in order
|
appoint headers-n-libraries' location. It's still recognized in order
|
||||||
to facilitate migration from older projects. However, since API level
|
to facilitate migration from older projects. However, since API level
|
||||||
appears in CROSS_SYSROOT value, passing -D__ANDROID_API__=N can be in
|
appears in CROSS_SYSROOT value, passing -D__ANDROID_API__=N can be in
|
||||||
@@ -64,9 +64,9 @@
|
|||||||
|
|
||||||
Another option is to create so called "standalone toolchain" tailored
|
Another option is to create so called "standalone toolchain" tailored
|
||||||
for single specific platform including Android API level, and assign its
|
for single specific platform including Android API level, and assign its
|
||||||
location to ANDROID_NDK_HOME. In such case you have to pass matching
|
location to ANDROID_NDK_ROOT. In such case you have to pass matching
|
||||||
target name to Configure and shouldn't use -D__ANDROID_API__=N. PATH
|
target name to Configure and shouldn't use -D__ANDROID_API__=N. PATH
|
||||||
adjustment becomes simpler, $ANDROID_NDK_HOME/bin:$PATH suffices.
|
adjustment becomes simpler, $ANDROID_NDK_ROOT/bin:$PATH suffices.
|
||||||
|
|
||||||
Running tests (on Linux)
|
Running tests (on Linux)
|
||||||
------------------------
|
------------------------
|
||||||
|
|||||||
@@ -118,6 +118,9 @@ document.
|
|||||||
* [NOTES.VMS](NOTES.VMS)
|
* [NOTES.VMS](NOTES.VMS)
|
||||||
* [NOTES.WIN](NOTES.WIN)
|
* [NOTES.WIN](NOTES.WIN)
|
||||||
|
|
||||||
|
Specific notes on upgrading to OpenSSL 3.0 from previous versions, as well as
|
||||||
|
known issues are available on the OpenSSL
|
||||||
|
[wiki](https://wiki.openssl.org/index.php/OpenSSL_3.0).
|
||||||
|
|
||||||
Documentation
|
Documentation
|
||||||
=============
|
=============
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
MAJOR=3
|
MAJOR=3
|
||||||
MINOR=0
|
MINOR=0
|
||||||
PATCH=0
|
PATCH=0
|
||||||
PRE_RELEASE_TAG=dev
|
PRE_RELEASE_TAG=alpha2-dev
|
||||||
BUILD_METADATA=
|
BUILD_METADATA=
|
||||||
RELEASE_DATE=
|
RELEASE_DATE=""
|
||||||
SHLIB_VERSION=3
|
SHLIB_VERSION=3
|
||||||
+75
-55
@@ -1,5 +1,5 @@
|
|||||||
#!{- $config{HASHBANGPERL} -}
|
#!{- $config{HASHBANGPERL} -}
|
||||||
# Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
|
# Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
# this file except in compliance with the License. You can obtain a copy
|
# this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -14,57 +14,63 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
my $openssl = "openssl";
|
|
||||||
if(defined $ENV{'OPENSSL'}) {
|
|
||||||
$openssl = $ENV{'OPENSSL'};
|
|
||||||
} else {
|
|
||||||
$ENV{'OPENSSL'} = $openssl;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $verbose = 1;
|
my $verbose = 1;
|
||||||
|
my @OPENSSL_CMDS = ("req", "ca", "pkcs12", "x509", "verify");
|
||||||
|
|
||||||
my $OPENSSL_CONFIG = $ENV{"OPENSSL_CONFIG"} || "";
|
my $openssl = $ENV{'OPENSSL'} // "openssl";
|
||||||
my $DAYS = "-days 365";
|
$ENV{'OPENSSL'} = $openssl;
|
||||||
my $CADAYS = "-days 1095"; # 3 years
|
my $OPENSSL_CONFIG = $ENV{"OPENSSL_CONFIG"} // "";
|
||||||
|
|
||||||
|
# Command invocations.
|
||||||
my $REQ = "$openssl req $OPENSSL_CONFIG";
|
my $REQ = "$openssl req $OPENSSL_CONFIG";
|
||||||
my $CA = "$openssl ca $OPENSSL_CONFIG";
|
my $CA = "$openssl ca $OPENSSL_CONFIG";
|
||||||
my $VERIFY = "$openssl verify";
|
my $VERIFY = "$openssl verify";
|
||||||
my $X509 = "$openssl x509";
|
my $X509 = "$openssl x509";
|
||||||
my $PKCS12 = "$openssl pkcs12";
|
my $PKCS12 = "$openssl pkcs12";
|
||||||
|
|
||||||
# default openssl.cnf file has setup as per the following
|
# Default values for various configuration settings.
|
||||||
my $CATOP = "./demoCA";
|
my $CATOP = "./demoCA";
|
||||||
my $CAKEY = "cakey.pem";
|
my $CAKEY = "cakey.pem";
|
||||||
my $CAREQ = "careq.pem";
|
my $CAREQ = "careq.pem";
|
||||||
my $CACERT = "cacert.pem";
|
my $CACERT = "cacert.pem";
|
||||||
my $CACRL = "crl.pem";
|
my $CACRL = "crl.pem";
|
||||||
my $DIRMODE = 0777;
|
my $DAYS = "-days 365";
|
||||||
|
my $CADAYS = "-days 1095"; # 3 years
|
||||||
my $NEWKEY = "newkey.pem";
|
my $NEWKEY = "newkey.pem";
|
||||||
my $NEWREQ = "newreq.pem";
|
my $NEWREQ = "newreq.pem";
|
||||||
my $NEWCERT = "newcert.pem";
|
my $NEWCERT = "newcert.pem";
|
||||||
my $NEWP12 = "newcert.p12";
|
my $NEWP12 = "newcert.p12";
|
||||||
my $RET = 0;
|
|
||||||
my $WHAT = shift @ARGV || "";
|
|
||||||
my @OPENSSL_CMDS = ("req", "ca", "pkcs12", "x509", "verify");
|
|
||||||
my %EXTRA = extra_args(\@ARGV, "-extra-");
|
|
||||||
my $FILE;
|
|
||||||
|
|
||||||
sub extra_args {
|
# Commandline parsing
|
||||||
my ($args_ref, $arg_prefix) = @_;
|
my %EXTRA;
|
||||||
my %eargs = map {
|
my $WHAT = shift @ARGV || "";
|
||||||
if ($_ < $#$args_ref) {
|
@ARGV = parse_extra(@ARGV);
|
||||||
my ($arg, $value) = splice(@$args_ref, $_, 2);
|
my $RET = 0;
|
||||||
$arg =~ s/$arg_prefix//;
|
|
||||||
($arg, $value);
|
# Split out "-extra-CMD value", and return new |@ARGV|. Fill in
|
||||||
} else {
|
# |EXTRA{CMD}| with list of values.
|
||||||
();
|
sub parse_extra
|
||||||
|
{
|
||||||
|
foreach ( @OPENSSL_CMDS ) {
|
||||||
|
$EXTRA{$_} = '';
|
||||||
}
|
}
|
||||||
} reverse grep($$args_ref[$_] =~ /$arg_prefix/, 0..$#$args_ref);
|
|
||||||
my %empty = map { ($_, "") } @OPENSSL_CMDS;
|
my @result;
|
||||||
return (%empty, %eargs);
|
while ( scalar(@_) > 0 ) {
|
||||||
|
my $arg = shift;
|
||||||
|
if ( $arg !~ m/-extra-([a-z0-9]+)/ ) {
|
||||||
|
push @result, $arg;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
$arg =~ s/-extra-//;
|
||||||
|
die("Unknown \"-${arg}-extra\" option, exiting")
|
||||||
|
unless scalar grep { $arg eq $_ } @OPENSSL_CMDS;
|
||||||
|
$EXTRA{$arg} .= " " . shift;
|
||||||
|
}
|
||||||
|
return @result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# See if reason for a CRL entry is valid; exit if not.
|
# See if reason for a CRL entry is valid; exit if not.
|
||||||
sub crl_reason_ok
|
sub crl_reason_ok
|
||||||
{
|
{
|
||||||
@@ -113,19 +119,25 @@ sub run
|
|||||||
|
|
||||||
|
|
||||||
if ( $WHAT =~ /^(-\?|-h|-help)$/ ) {
|
if ( $WHAT =~ /^(-\?|-h|-help)$/ ) {
|
||||||
print STDERR "usage: CA.pl -newcert | -newreq | -newreq-nodes | -xsign | -sign | -signCA | -signcert | -crl | -newca [-extra-cmd extra-params]\n";
|
print STDERR <<EOF;
|
||||||
print STDERR " CA.pl -pkcs12 [-extra-pkcs12 extra-params] [certname]\n";
|
Usage:
|
||||||
print STDERR " CA.pl -verify [-extra-verify extra-params] certfile ...\n";
|
CA.pl -newcert | -newreq | -newreq-nodes | -xsign | -sign | -signCA | -signcert | -crl | -newca [-extra-cmd parameter]
|
||||||
print STDERR " CA.pl -revoke [-extra-ca extra-params] certfile [reason]\n";
|
CA.pl -pkcs12 [-extra-pkcs12 parameter] [certname]
|
||||||
|
CA.pl -verify [-extra-verify parameter] certfile ...
|
||||||
|
CA.pl -revoke [-extra-ca parameter] certfile [reason]
|
||||||
|
EOF
|
||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($WHAT eq '-newcert' ) {
|
if ($WHAT eq '-newcert' ) {
|
||||||
# create a certificate
|
# create a certificate
|
||||||
$RET = run("$REQ -new -x509 -keyout $NEWKEY -out $NEWCERT $DAYS $EXTRA{req}");
|
$RET = run("$REQ -new -x509 -keyout $NEWKEY -out $NEWCERT $DAYS"
|
||||||
|
. " $EXTRA{req}");
|
||||||
print "Cert is in $NEWCERT, private key is in $NEWKEY\n" if $RET == 0;
|
print "Cert is in $NEWCERT, private key is in $NEWKEY\n" if $RET == 0;
|
||||||
} elsif ($WHAT eq '-precert' ) {
|
} elsif ($WHAT eq '-precert' ) {
|
||||||
# create a pre-certificate
|
# create a pre-certificate
|
||||||
$RET = run("$REQ -x509 -precert -keyout $NEWKEY -out $NEWCERT $DAYS");
|
$RET = run("$REQ -x509 -precert -keyout $NEWKEY -out $NEWCERT $DAYS"
|
||||||
|
. " $EXTRA{req}");
|
||||||
print "Pre-cert is in $NEWCERT, private key is in $NEWKEY\n" if $RET == 0;
|
print "Pre-cert is in $NEWCERT, private key is in $NEWKEY\n" if $RET == 0;
|
||||||
} elsif ($WHAT =~ /^\-newreq(\-nodes)?$/ ) {
|
} elsif ($WHAT =~ /^\-newreq(\-nodes)?$/ ) {
|
||||||
# create a certificate request
|
# create a certificate request
|
||||||
@@ -133,11 +145,20 @@ if ($WHAT eq '-newcert' ) {
|
|||||||
print "Request is in $NEWREQ, private key is in $NEWKEY\n" if $RET == 0;
|
print "Request is in $NEWREQ, private key is in $NEWKEY\n" if $RET == 0;
|
||||||
} elsif ($WHAT eq '-newca' ) {
|
} elsif ($WHAT eq '-newca' ) {
|
||||||
# create the directory hierarchy
|
# create the directory hierarchy
|
||||||
mkdir ${CATOP}, $DIRMODE;
|
my @dirs = ( "${CATOP}", "${CATOP}/certs", "${CATOP}/crl",
|
||||||
mkdir "${CATOP}/certs", $DIRMODE;
|
"${CATOP}/newcerts", "${CATOP}/private" );
|
||||||
mkdir "${CATOP}/crl", $DIRMODE ;
|
die "${CATOP}/index.txt exists.\nRemove old sub-tree to proceed,"
|
||||||
mkdir "${CATOP}/newcerts", $DIRMODE;
|
if -f "${CATOP}/index.txt";
|
||||||
mkdir "${CATOP}/private", $DIRMODE;
|
die "${CATOP}/serial exists.\nRemove old sub-tree to proceed,"
|
||||||
|
if -f "${CATOP}/serial";
|
||||||
|
foreach my $d ( @dirs ) {
|
||||||
|
if ( -d $d ) {
|
||||||
|
warn "Directory $d exists" if -d $d;
|
||||||
|
} else {
|
||||||
|
mkdir $d or die "Can't mkdir $d, $!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open OUT, ">${CATOP}/index.txt";
|
open OUT, ">${CATOP}/index.txt";
|
||||||
close OUT;
|
close OUT;
|
||||||
open OUT, ">${CATOP}/crlnumber";
|
open OUT, ">${CATOP}/crlnumber";
|
||||||
@@ -145,6 +166,7 @@ if ($WHAT eq '-newcert' ) {
|
|||||||
close OUT;
|
close OUT;
|
||||||
# ask user for existing CA certificate
|
# ask user for existing CA certificate
|
||||||
print "CA certificate filename (or enter to create)\n";
|
print "CA certificate filename (or enter to create)\n";
|
||||||
|
my $FILE;
|
||||||
$FILE = "" unless defined($FILE = <STDIN>);
|
$FILE = "" unless defined($FILE = <STDIN>);
|
||||||
$FILE =~ s{\R$}{};
|
$FILE =~ s{\R$}{};
|
||||||
if ($FILE ne "") {
|
if ($FILE ne "") {
|
||||||
@@ -152,44 +174,42 @@ if ($WHAT eq '-newcert' ) {
|
|||||||
copy_pemfile($FILE,"${CATOP}/$CACERT", "CERTIFICATE");
|
copy_pemfile($FILE,"${CATOP}/$CACERT", "CERTIFICATE");
|
||||||
} else {
|
} else {
|
||||||
print "Making CA certificate ...\n";
|
print "Making CA certificate ...\n";
|
||||||
$RET = run("$REQ -new -keyout"
|
$RET = run("$REQ -new -keyout ${CATOP}/private/$CAKEY"
|
||||||
. " ${CATOP}/private/$CAKEY"
|
|
||||||
. " -out ${CATOP}/$CAREQ $EXTRA{req}");
|
. " -out ${CATOP}/$CAREQ $EXTRA{req}");
|
||||||
$RET = run("$CA -create_serial"
|
$RET = run("$CA -create_serial"
|
||||||
. " -out ${CATOP}/$CACERT $CADAYS -batch"
|
. " -out ${CATOP}/$CACERT $CADAYS -batch"
|
||||||
. " -keyfile ${CATOP}/private/$CAKEY -selfsign"
|
. " -keyfile ${CATOP}/private/$CAKEY -selfsign"
|
||||||
. " -extensions v3_ca $EXTRA{ca}"
|
. " -extensions v3_ca"
|
||||||
. " -infiles ${CATOP}/$CAREQ") if $RET == 0;
|
. " -infiles ${CATOP}/$CAREQ $EXTRA{ca}") if $RET == 0;
|
||||||
print "CA certificate is in ${CATOP}/$CACERT\n" if $RET == 0;
|
print "CA certificate is in ${CATOP}/$CACERT\n" if $RET == 0;
|
||||||
}
|
}
|
||||||
} elsif ($WHAT eq '-pkcs12' ) {
|
} elsif ($WHAT eq '-pkcs12' ) {
|
||||||
my $cname = $ARGV[0];
|
my $cname = $ARGV[0];
|
||||||
$cname = "My Certificate" unless defined $cname;
|
$cname = "My Certificate" unless defined $cname;
|
||||||
$RET = run("$PKCS12 -in $NEWCERT -inkey $NEWKEY"
|
$RET = run("$PKCS12 -in $NEWCERT -inkey $NEWKEY"
|
||||||
. " -certfile ${CATOP}/$CACERT"
|
. " -certfile ${CATOP}/$CACERT -out $NEWP12"
|
||||||
. " -out $NEWP12"
|
|
||||||
. " -export -name \"$cname\" $EXTRA{pkcs12}");
|
. " -export -name \"$cname\" $EXTRA{pkcs12}");
|
||||||
print "PKCS #12 file is in $NEWP12\n" if $RET == 0;
|
print "PKCS #12 file is in $NEWP12\n" if $RET == 0;
|
||||||
} elsif ($WHAT eq '-xsign' ) {
|
} elsif ($WHAT eq '-xsign' ) {
|
||||||
$RET = run("$CA -policy policy_anything $EXTRA{ca} -infiles $NEWREQ");
|
$RET = run("$CA -policy policy_anything -infiles $NEWREQ $EXTRA{ca}");
|
||||||
} elsif ($WHAT eq '-sign' ) {
|
} elsif ($WHAT eq '-sign' ) {
|
||||||
$RET = run("$CA -policy policy_anything -out $NEWCERT $EXTRA{ca} -infiles $NEWREQ");
|
$RET = run("$CA -policy policy_anything -out $NEWCERT"
|
||||||
|
. " -infiles $NEWREQ $EXTRA{ca}");
|
||||||
print "Signed certificate is in $NEWCERT\n" if $RET == 0;
|
print "Signed certificate is in $NEWCERT\n" if $RET == 0;
|
||||||
} elsif ($WHAT eq '-signCA' ) {
|
} elsif ($WHAT eq '-signCA' ) {
|
||||||
$RET = run("$CA -policy policy_anything -out $NEWCERT"
|
$RET = run("$CA -policy policy_anything -out $NEWCERT"
|
||||||
. " -extensions v3_ca $EXTRA{ca} -infiles $NEWREQ");
|
. " -extensions v3_ca -infiles $NEWREQ $EXTRA{ca}");
|
||||||
print "Signed CA certificate is in $NEWCERT\n" if $RET == 0;
|
print "Signed CA certificate is in $NEWCERT\n" if $RET == 0;
|
||||||
} elsif ($WHAT eq '-signcert' ) {
|
} elsif ($WHAT eq '-signcert' ) {
|
||||||
$RET = run("$X509 -x509toreq -in $NEWREQ -signkey $NEWREQ"
|
$RET = run("$X509 -x509toreq -in $NEWREQ -signkey $NEWREQ"
|
||||||
. " -out tmp.pem $EXTRA{x509}");
|
. " -out tmp.pem $EXTRA{x509}");
|
||||||
$RET = run("$CA -policy policy_anything -out $NEWCERT"
|
$RET = run("$CA -policy policy_anything -out $NEWCERT"
|
||||||
. "$EXTRA{ca} -infiles tmp.pem") if $RET == 0;
|
. "-infiles tmp.pem $EXTRA{ca}") if $RET == 0;
|
||||||
print "Signed certificate is in $NEWCERT\n" if $RET == 0;
|
print "Signed certificate is in $NEWCERT\n" if $RET == 0;
|
||||||
} elsif ($WHAT eq '-verify' ) {
|
} elsif ($WHAT eq '-verify' ) {
|
||||||
my @files = @ARGV ? @ARGV : ( $NEWCERT );
|
my @files = @ARGV ? @ARGV : ( $NEWCERT );
|
||||||
my $file;
|
foreach my $file (@files) {
|
||||||
foreach $file (@files) {
|
my $status = run("$VERIFY -CAfile ${CATOP}/$CACERT $file $EXTRA{verify}");
|
||||||
my $status = run("$VERIFY \"-CAfile\" ${CATOP}/$CACERT $file $EXTRA{verify}");
|
|
||||||
$RET = $status if $status != 0;
|
$RET = $status if $status != 0;
|
||||||
}
|
}
|
||||||
} elsif ($WHAT eq '-crl' ) {
|
} elsif ($WHAT eq '-crl' ) {
|
||||||
|
|||||||
@@ -18,6 +18,9 @@
|
|||||||
#include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
#include <openssl/asn1t.h>
|
#include <openssl/asn1t.h>
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(ASN1_OBJECT)
|
||||||
|
DEFINE_STACK_OF_STRING()
|
||||||
|
|
||||||
typedef enum OPTION_choice {
|
typedef enum OPTION_choice {
|
||||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||||
OPT_INFORM, OPT_IN, OPT_OUT, OPT_INDENT, OPT_NOOUT,
|
OPT_INFORM, OPT_IN, OPT_OUT, OPT_INDENT, OPT_NOOUT,
|
||||||
|
|||||||
+28
-5
@@ -13,15 +13,38 @@ ENDIF
|
|||||||
$OPENSSLSRC=\
|
$OPENSSLSRC=\
|
||||||
openssl.c progs.c \
|
openssl.c progs.c \
|
||||||
asn1pars.c ca.c ciphers.c cms.c crl.c crl2p7.c dgst.c \
|
asn1pars.c ca.c ciphers.c cms.c crl.c crl2p7.c dgst.c \
|
||||||
ec.c ecparam.c enc.c engine.c errstr.c \
|
enc.c errstr.c \
|
||||||
genpkey.c genrsa.c kdf.c mac.c nseq.c ocsp.c passwd.c pkcs12.c pkcs7.c \
|
genpkey.c genrsa.c kdf.c mac.c nseq.c ocsp.c passwd.c pkcs12.c pkcs7.c \
|
||||||
pkcs8.c pkey.c pkeyparam.c pkeyutl.c prime.c rand.c req.c rsa.c \
|
pkcs8.c pkey.c pkeyparam.c pkeyutl.c prime.c rand.c req.c rsa.c \
|
||||||
rsautl.c s_client.c s_server.c s_time.c sess_id.c smime.c speed.c \
|
rsautl.c s_client.c s_server.c s_time.c sess_id.c smime.c speed.c \
|
||||||
spkac.c srp.c ts.c verify.c version.c x509.c rehash.c storeutl.c \
|
spkac.c verify.c version.c x509.c rehash.c storeutl.c \
|
||||||
list.c info.c provider.c fipsinstall.c
|
list.c info.c provider.c fipsinstall.c
|
||||||
IF[{- !$disabled{'deprecated-3.0'} -}]
|
IF[{- !$disabled{'des'} -}]
|
||||||
$OPENSSLSRC=$OPENSSLSRC \
|
$OPENSSLSRC=$OPENSSLSRC pkcs12.c
|
||||||
dhparam.c dsa.c dsaparam.c gendsa.c
|
ENDIF
|
||||||
|
IF[{- !$disabled{'ec'} -}]
|
||||||
|
$OPENSSLSRC=$OPENSSLSRC ec.c ecparam.c
|
||||||
|
ENDIF
|
||||||
|
IF[{- !$disabled{'ocsp'} -}]
|
||||||
|
$OPENSSLSRC=$OPENSSLSRC ocsp.c
|
||||||
|
ENDIF
|
||||||
|
IF[{- !$disabled{'srp'} -}]
|
||||||
|
$OPENSSLSRC=$OPENSSLSRC srp.c
|
||||||
|
ENDIF
|
||||||
|
IF[{- !$disabled{'ts'} -}]
|
||||||
|
$OPENSSLSRC=$OPENSSLSRC ts.c
|
||||||
|
ENDIF
|
||||||
|
IF[{- !$disabled{'dh'} -}]
|
||||||
|
$OPENSSLSRC=$OPENSSLSRC dhparam.c
|
||||||
|
ENDIF
|
||||||
|
IF[{- !$disabled{'dsa'} -}]
|
||||||
|
$OPENSSLSRC=$OPENSSLSRC dsa.c dsaparam.c gendsa.c
|
||||||
|
ENDIF
|
||||||
|
IF[{- !$disabled{'engine'} -}]
|
||||||
|
$OPENSSLSRC=$OPENSSLSRC engine.c
|
||||||
|
ENDIF
|
||||||
|
IF[{- !$disabled{'cmp'} -}]
|
||||||
|
$OPENSSLSRC=$OPENSSLSRC cmp_mock_srv.c
|
||||||
ENDIF
|
ENDIF
|
||||||
|
|
||||||
IF[{- !$disabled{apps} -}]
|
IF[{- !$disabled{apps} -}]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -34,6 +34,11 @@
|
|||||||
#include "apps.h"
|
#include "apps.h"
|
||||||
#include "progs.h"
|
#include "progs.h"
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(X509)
|
||||||
|
DEFINE_STACK_OF(X509_EXTENSION)
|
||||||
|
DEFINE_STACK_OF(CONF_VALUE)
|
||||||
|
DEFINE_STACK_OF_STRING()
|
||||||
|
|
||||||
#ifndef W_OK
|
#ifndef W_OK
|
||||||
# define F_OK 0
|
# define F_OK 0
|
||||||
# define W_OK 2
|
# define W_OK 2
|
||||||
@@ -88,18 +93,23 @@ typedef enum {
|
|||||||
|
|
||||||
static char *lookup_conf(const CONF *conf, const char *group, const char *tag);
|
static char *lookup_conf(const CONF *conf, const char *group, const char *tag);
|
||||||
|
|
||||||
static int certify(X509 **xret, const char *infile, EVP_PKEY *pkey, X509 *x509,
|
static int certify(X509 **xret, const char *infile, int informat,
|
||||||
const EVP_MD *dgst, STACK_OF(OPENSSL_STRING) *sigopts,
|
EVP_PKEY *pkey, X509 *x509,
|
||||||
|
const EVP_MD *dgst,
|
||||||
|
STACK_OF(OPENSSL_STRING) *sigopts,
|
||||||
|
STACK_OF(OPENSSL_STRING) *vfyopts,
|
||||||
STACK_OF(CONF_VALUE) *policy, CA_DB *db,
|
STACK_OF(CONF_VALUE) *policy, CA_DB *db,
|
||||||
BIGNUM *serial, const char *subj, unsigned long chtype,
|
BIGNUM *serial, const char *subj, unsigned long chtype,
|
||||||
int multirdn, int email_dn, const char *startdate,
|
int multirdn, int email_dn, const char *startdate,
|
||||||
const char *enddate,
|
const char *enddate,
|
||||||
long days, int batch, const char *ext_sect, CONF *conf,
|
long days, int batch, const char *ext_sect, CONF *conf,
|
||||||
int verbose, unsigned long certopt, unsigned long nameopt,
|
int verbose, unsigned long certopt, unsigned long nameopt,
|
||||||
int default_op, int ext_copy, int selfsign,
|
int default_op, int ext_copy, int selfsign);
|
||||||
unsigned char *sm2_id, size_t sm2idlen);
|
static int certify_cert(X509 **xret, const char *infile, int informat,
|
||||||
static int certify_cert(X509 **xret, const char *infile, EVP_PKEY *pkey, X509 *x509,
|
EVP_PKEY *pkey, X509 *x509,
|
||||||
const EVP_MD *dgst, STACK_OF(OPENSSL_STRING) *sigopts,
|
const EVP_MD *dgst,
|
||||||
|
STACK_OF(OPENSSL_STRING) *sigopts,
|
||||||
|
STACK_OF(OPENSSL_STRING) *vfyopts,
|
||||||
STACK_OF(CONF_VALUE) *policy, CA_DB *db,
|
STACK_OF(CONF_VALUE) *policy, CA_DB *db,
|
||||||
BIGNUM *serial, const char *subj, unsigned long chtype,
|
BIGNUM *serial, const char *subj, unsigned long chtype,
|
||||||
int multirdn, int email_dn, const char *startdate,
|
int multirdn, int email_dn, const char *startdate,
|
||||||
@@ -142,13 +152,14 @@ typedef enum OPTION_choice {
|
|||||||
OPT_ENGINE, OPT_VERBOSE, OPT_CONFIG, OPT_NAME, OPT_SUBJ, OPT_UTF8,
|
OPT_ENGINE, OPT_VERBOSE, OPT_CONFIG, OPT_NAME, OPT_SUBJ, OPT_UTF8,
|
||||||
OPT_CREATE_SERIAL, OPT_MULTIVALUE_RDN, OPT_STARTDATE, OPT_ENDDATE,
|
OPT_CREATE_SERIAL, OPT_MULTIVALUE_RDN, OPT_STARTDATE, OPT_ENDDATE,
|
||||||
OPT_DAYS, OPT_MD, OPT_POLICY, OPT_KEYFILE, OPT_KEYFORM, OPT_PASSIN,
|
OPT_DAYS, OPT_MD, OPT_POLICY, OPT_KEYFILE, OPT_KEYFORM, OPT_PASSIN,
|
||||||
OPT_KEY, OPT_CERT, OPT_SELFSIGN, OPT_IN, OPT_OUT, OPT_OUTDIR,
|
OPT_KEY, OPT_CERT, OPT_CERTFORM, OPT_SELFSIGN,
|
||||||
|
OPT_IN, OPT_INFORM, OPT_OUT, OPT_OUTDIR, OPT_VFYOPT,
|
||||||
OPT_SIGOPT, OPT_NOTEXT, OPT_BATCH, OPT_PRESERVEDN, OPT_NOEMAILDN,
|
OPT_SIGOPT, OPT_NOTEXT, OPT_BATCH, OPT_PRESERVEDN, OPT_NOEMAILDN,
|
||||||
OPT_GENCRL, OPT_MSIE_HACK, OPT_CRLDAYS, OPT_CRLHOURS, OPT_CRLSEC,
|
OPT_GENCRL, OPT_MSIE_HACK, OPT_CRLDAYS, OPT_CRLHOURS, OPT_CRLSEC,
|
||||||
OPT_INFILES, OPT_SS_CERT, OPT_SPKAC, OPT_REVOKE, OPT_VALID,
|
OPT_INFILES, OPT_SS_CERT, OPT_SPKAC, OPT_REVOKE, OPT_VALID,
|
||||||
OPT_EXTENSIONS, OPT_EXTFILE, OPT_STATUS, OPT_UPDATEDB, OPT_CRLEXTS,
|
OPT_EXTENSIONS, OPT_EXTFILE, OPT_STATUS, OPT_UPDATEDB, OPT_CRLEXTS,
|
||||||
OPT_RAND_SERIAL,
|
OPT_RAND_SERIAL,
|
||||||
OPT_R_ENUM, OPT_SM2ID, OPT_SM2HEXID, OPT_PROV_ENUM,
|
OPT_R_ENUM, OPT_PROV_ENUM,
|
||||||
/* Do not change the order here; see related case statements below */
|
/* Do not change the order here; see related case statements below */
|
||||||
OPT_CRL_REASON, OPT_CRL_HOLD, OPT_CRL_COMPROMISE, OPT_CRL_CA_COMPROMISE
|
OPT_CRL_REASON, OPT_CRL_HOLD, OPT_CRL_COMPROMISE, OPT_CRL_CA_COMPROMISE
|
||||||
} OPTION_CHOICE;
|
} OPTION_CHOICE;
|
||||||
@@ -160,7 +171,8 @@ const OPTIONS ca_options[] = {
|
|||||||
{"help", OPT_HELP, '-', "Display this summary"},
|
{"help", OPT_HELP, '-', "Display this summary"},
|
||||||
{"verbose", OPT_VERBOSE, '-', "Verbose output during processing"},
|
{"verbose", OPT_VERBOSE, '-', "Verbose output during processing"},
|
||||||
{"outdir", OPT_OUTDIR, '/', "Where to put output cert"},
|
{"outdir", OPT_OUTDIR, '/', "Where to put output cert"},
|
||||||
{"in", OPT_IN, '<', "The input PEM encoded cert request(s)"},
|
{"in", OPT_IN, '<', "The input cert request(s)"},
|
||||||
|
{"inform", OPT_INFORM, 'F', "CSR input format (DER or PEM); default PEM"},
|
||||||
{"infiles", OPT_INFILES, '-', "The last argument, requests to process"},
|
{"infiles", OPT_INFILES, '-', "The last argument, requests to process"},
|
||||||
{"out", OPT_OUT, '>', "Where to put the output file(s)"},
|
{"out", OPT_OUT, '>', "Where to put the output file(s)"},
|
||||||
{"notext", OPT_NOTEXT, '-', "Do not print the generated certificate"},
|
{"notext", OPT_NOTEXT, '-', "Do not print the generated certificate"},
|
||||||
@@ -182,7 +194,7 @@ const OPTIONS ca_options[] = {
|
|||||||
|
|
||||||
OPT_SECTION("Certificate"),
|
OPT_SECTION("Certificate"),
|
||||||
{"subj", OPT_SUBJ, 's', "Use arg instead of request's subject"},
|
{"subj", OPT_SUBJ, 's', "Use arg instead of request's subject"},
|
||||||
{"utf8", OPT_UTF8, '-', "Input characters are UTF8 (default ASCII)"},
|
{"utf8", OPT_UTF8, '-', "Input characters are UTF8; default ASCII"},
|
||||||
{"create_serial", OPT_CREATE_SERIAL, '-',
|
{"create_serial", OPT_CREATE_SERIAL, '-',
|
||||||
"If reading serial fails, create a new random serial"},
|
"If reading serial fails, create a new random serial"},
|
||||||
{"rand_serial", OPT_RAND_SERIAL, '-',
|
{"rand_serial", OPT_RAND_SERIAL, '-',
|
||||||
@@ -197,12 +209,6 @@ const OPTIONS ca_options[] = {
|
|||||||
"Extension section (override value in config file)"},
|
"Extension section (override value in config file)"},
|
||||||
{"extfile", OPT_EXTFILE, '<',
|
{"extfile", OPT_EXTFILE, '<',
|
||||||
"Configuration file with X509v3 extensions to add"},
|
"Configuration file with X509v3 extensions to add"},
|
||||||
#ifndef OPENSSL_NO_SM2
|
|
||||||
{"sm2-id", OPT_SM2ID, 's',
|
|
||||||
"Specify an ID string to verify an SM2 certificate request"},
|
|
||||||
{"sm2-hex-id", OPT_SM2HEXID, 's',
|
|
||||||
"Specify a hex ID string to verify an SM2 certificate request"},
|
|
||||||
#endif
|
|
||||||
{"preserveDN", OPT_PRESERVEDN, '-', "Don't re-order the DN"},
|
{"preserveDN", OPT_PRESERVEDN, '-', "Don't re-order the DN"},
|
||||||
{"noemailDN", OPT_NOEMAILDN, '-', "Don't add the EMAIL field to the DN"},
|
{"noemailDN", OPT_NOEMAILDN, '-', "Don't add the EMAIL field to the DN"},
|
||||||
|
|
||||||
@@ -213,9 +219,12 @@ const OPTIONS ca_options[] = {
|
|||||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||||
{"key", OPT_KEY, 's', "Key to decode the private key if it is encrypted"},
|
{"key", OPT_KEY, 's', "Key to decode the private key if it is encrypted"},
|
||||||
{"cert", OPT_CERT, '<', "The CA cert"},
|
{"cert", OPT_CERT, '<', "The CA cert"},
|
||||||
|
{"certform", OPT_CERTFORM, 'F',
|
||||||
|
"certificate input format (DER or PEM); default PEM"},
|
||||||
{"selfsign", OPT_SELFSIGN, '-',
|
{"selfsign", OPT_SELFSIGN, '-',
|
||||||
"Sign a cert with the key associated with it"},
|
"Sign a cert with the key associated with it"},
|
||||||
{"sigopt", OPT_SIGOPT, 's', "Signature parameter in n:v form"},
|
{"sigopt", OPT_SIGOPT, 's', "Signature parameter in n:v form"},
|
||||||
|
{"vfyopt", OPT_SIGOPT, 's', "Verification parameter in n:v form"},
|
||||||
|
|
||||||
OPT_SECTION("Revocation"),
|
OPT_SECTION("Revocation"),
|
||||||
{"gencrl", OPT_GENCRL, '-', "Generate a new CRL"},
|
{"gencrl", OPT_GENCRL, '-', "Generate a new CRL"},
|
||||||
@@ -257,13 +266,14 @@ int ca_main(int argc, char **argv)
|
|||||||
CA_DB *db = NULL;
|
CA_DB *db = NULL;
|
||||||
DB_ATTR db_attr;
|
DB_ATTR db_attr;
|
||||||
STACK_OF(CONF_VALUE) *attribs = NULL;
|
STACK_OF(CONF_VALUE) *attribs = NULL;
|
||||||
STACK_OF(OPENSSL_STRING) *sigopts = NULL;
|
STACK_OF(OPENSSL_STRING) *sigopts = NULL, *vfyopts = NULL;
|
||||||
STACK_OF(X509) *cert_sk = NULL;
|
STACK_OF(X509) *cert_sk = NULL;
|
||||||
X509_CRL *crl = NULL;
|
X509_CRL *crl = NULL;
|
||||||
const EVP_MD *dgst = NULL;
|
const EVP_MD *dgst = NULL;
|
||||||
char *configfile = default_config_file, *section = NULL;
|
char *configfile = default_config_file, *section = NULL;
|
||||||
char *md = NULL, *policy = NULL, *keyfile = NULL;
|
char *md = NULL, *policy = NULL, *keyfile = NULL;
|
||||||
char *certfile = NULL, *crl_ext = NULL, *crlnumberfile = NULL, *key = NULL;
|
char *certfile = NULL, *crl_ext = NULL, *crlnumberfile = NULL, *key = NULL;
|
||||||
|
int certformat = FORMAT_PEM, informat = FORMAT_PEM;
|
||||||
const char *infile = NULL, *spkac_file = NULL, *ss_cert_file = NULL;
|
const char *infile = NULL, *spkac_file = NULL, *ss_cert_file = NULL;
|
||||||
const char *extensions = NULL, *extfile = NULL, *passinarg = NULL;
|
const char *extensions = NULL, *extfile = NULL, *passinarg = NULL;
|
||||||
char *outdir = NULL, *outfile = NULL, *rev_arg = NULL, *ser_status = NULL;
|
char *outdir = NULL, *outfile = NULL, *rev_arg = NULL, *ser_status = NULL;
|
||||||
@@ -286,9 +296,6 @@ int ca_main(int argc, char **argv)
|
|||||||
REVINFO_TYPE rev_type = REV_NONE;
|
REVINFO_TYPE rev_type = REV_NONE;
|
||||||
X509_REVOKED *r = NULL;
|
X509_REVOKED *r = NULL;
|
||||||
OPTION_CHOICE o;
|
OPTION_CHOICE o;
|
||||||
unsigned char *sm2_id = NULL;
|
|
||||||
size_t sm2_idlen = 0;
|
|
||||||
int sm2_free = 0;
|
|
||||||
|
|
||||||
prog = opt_init(argc, argv, ca_options);
|
prog = opt_init(argc, argv, ca_options);
|
||||||
while ((o = opt_next()) != OPT_EOF) {
|
while ((o = opt_next()) != OPT_EOF) {
|
||||||
@@ -306,6 +313,10 @@ opthelp:
|
|||||||
req = 1;
|
req = 1;
|
||||||
infile = opt_arg();
|
infile = opt_arg();
|
||||||
break;
|
break;
|
||||||
|
case OPT_INFORM:
|
||||||
|
if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &informat))
|
||||||
|
goto opthelp;
|
||||||
|
break;
|
||||||
case OPT_OUT:
|
case OPT_OUT:
|
||||||
outfile = opt_arg();
|
outfile = opt_arg();
|
||||||
break;
|
break;
|
||||||
@@ -373,6 +384,10 @@ opthelp:
|
|||||||
case OPT_CERT:
|
case OPT_CERT:
|
||||||
certfile = opt_arg();
|
certfile = opt_arg();
|
||||||
break;
|
break;
|
||||||
|
case OPT_CERTFORM:
|
||||||
|
if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &certformat))
|
||||||
|
goto opthelp;
|
||||||
|
break;
|
||||||
case OPT_SELFSIGN:
|
case OPT_SELFSIGN:
|
||||||
selfsign = 1;
|
selfsign = 1;
|
||||||
break;
|
break;
|
||||||
@@ -385,6 +400,12 @@ opthelp:
|
|||||||
if (sigopts == NULL || !sk_OPENSSL_STRING_push(sigopts, opt_arg()))
|
if (sigopts == NULL || !sk_OPENSSL_STRING_push(sigopts, opt_arg()))
|
||||||
goto end;
|
goto end;
|
||||||
break;
|
break;
|
||||||
|
case OPT_VFYOPT:
|
||||||
|
if (vfyopts == NULL)
|
||||||
|
vfyopts = sk_OPENSSL_STRING_new_null();
|
||||||
|
if (vfyopts == NULL || !sk_OPENSSL_STRING_push(vfyopts, opt_arg()))
|
||||||
|
goto end;
|
||||||
|
break;
|
||||||
case OPT_NOTEXT:
|
case OPT_NOTEXT:
|
||||||
notext = 1;
|
notext = 1;
|
||||||
break;
|
break;
|
||||||
@@ -456,30 +477,6 @@ opthelp:
|
|||||||
case OPT_ENGINE:
|
case OPT_ENGINE:
|
||||||
e = setup_engine(opt_arg(), 0);
|
e = setup_engine(opt_arg(), 0);
|
||||||
break;
|
break;
|
||||||
case OPT_SM2ID:
|
|
||||||
/* we assume the input is not a hex string */
|
|
||||||
if (sm2_id != NULL) {
|
|
||||||
BIO_printf(bio_err,
|
|
||||||
"Use one of the options 'sm2-hex-id' or 'sm2-id'\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
sm2_id = (unsigned char *)opt_arg();
|
|
||||||
sm2_idlen = strlen((const char *)sm2_id);
|
|
||||||
break;
|
|
||||||
case OPT_SM2HEXID:
|
|
||||||
/* try to parse the input as hex string first */
|
|
||||||
if (sm2_id != NULL) {
|
|
||||||
BIO_printf(bio_err,
|
|
||||||
"Use one of the options 'sm2-hex-id' or 'sm2-id'\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
sm2_free = 1;
|
|
||||||
sm2_id = OPENSSL_hexstr2buf(opt_arg(), (long *)&sm2_idlen);
|
|
||||||
if (sm2_id == NULL) {
|
|
||||||
BIO_printf(bio_err, "Invalid hex string input\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end_of_options:
|
end_of_options:
|
||||||
@@ -589,7 +586,7 @@ end_of_options:
|
|||||||
&& (certfile = lookup_conf(conf, section, ENV_CERTIFICATE)) == NULL)
|
&& (certfile = lookup_conf(conf, section, ENV_CERTIFICATE)) == NULL)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
x509 = load_cert(certfile, FORMAT_PEM, "CA certificate");
|
x509 = load_cert(certfile, certformat, "CA certificate");
|
||||||
if (x509 == NULL)
|
if (x509 == NULL)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
@@ -944,8 +941,8 @@ end_of_options:
|
|||||||
}
|
}
|
||||||
if (ss_cert_file != NULL) {
|
if (ss_cert_file != NULL) {
|
||||||
total++;
|
total++;
|
||||||
j = certify_cert(&x, ss_cert_file, pkey, x509, dgst, sigopts,
|
j = certify_cert(&x, ss_cert_file, certformat, pkey, x509, dgst,
|
||||||
attribs,
|
sigopts, vfyopts, attribs,
|
||||||
db, serial, subj, chtype, multirdn, email_dn,
|
db, serial, subj, chtype, multirdn, email_dn,
|
||||||
startdate, enddate, days, batch, extensions,
|
startdate, enddate, days, batch, extensions,
|
||||||
conf, verbose, certopt, get_nameopt(), default_op,
|
conf, verbose, certopt, get_nameopt(), default_op,
|
||||||
@@ -965,11 +962,11 @@ end_of_options:
|
|||||||
}
|
}
|
||||||
if (infile != NULL) {
|
if (infile != NULL) {
|
||||||
total++;
|
total++;
|
||||||
j = certify(&x, infile, pkey, x509p, dgst, sigopts, attribs, db,
|
j = certify(&x, infile, informat, pkey, x509p, dgst,
|
||||||
|
sigopts, vfyopts, attribs, db,
|
||||||
serial, subj, chtype, multirdn, email_dn, startdate,
|
serial, subj, chtype, multirdn, email_dn, startdate,
|
||||||
enddate, days, batch, extensions, conf, verbose,
|
enddate, days, batch, extensions, conf, verbose,
|
||||||
certopt, get_nameopt(), default_op, ext_copy, selfsign,
|
certopt, get_nameopt(), default_op, ext_copy, selfsign);
|
||||||
sm2_id, sm2_idlen);
|
|
||||||
if (j < 0)
|
if (j < 0)
|
||||||
goto end;
|
goto end;
|
||||||
if (j > 0) {
|
if (j > 0) {
|
||||||
@@ -985,11 +982,12 @@ end_of_options:
|
|||||||
}
|
}
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
total++;
|
total++;
|
||||||
j = certify(&x, argv[i], pkey, x509p, dgst, sigopts, attribs, db,
|
j = certify(&x, argv[i], informat, pkey, x509p, dgst,
|
||||||
|
sigopts, vfyopts,
|
||||||
|
attribs, db,
|
||||||
serial, subj, chtype, multirdn, email_dn, startdate,
|
serial, subj, chtype, multirdn, email_dn, startdate,
|
||||||
enddate, days, batch, extensions, conf, verbose,
|
enddate, days, batch, extensions, conf, verbose,
|
||||||
certopt, get_nameopt(), default_op, ext_copy, selfsign,
|
certopt, get_nameopt(), default_op, ext_copy, selfsign);
|
||||||
sm2_id, sm2_idlen);
|
|
||||||
if (j < 0)
|
if (j < 0)
|
||||||
goto end;
|
goto end;
|
||||||
if (j > 0) {
|
if (j > 0) {
|
||||||
@@ -1265,7 +1263,7 @@ end_of_options:
|
|||||||
goto end;
|
goto end;
|
||||||
} else {
|
} else {
|
||||||
X509 *revcert;
|
X509 *revcert;
|
||||||
revcert = load_cert(infile, FORMAT_PEM, infile);
|
revcert = load_cert(infile, certformat, infile);
|
||||||
if (revcert == NULL)
|
if (revcert == NULL)
|
||||||
goto end;
|
goto end;
|
||||||
if (dorevoke == 2)
|
if (dorevoke == 2)
|
||||||
@@ -1287,8 +1285,6 @@ end_of_options:
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
if (sm2_free)
|
|
||||||
OPENSSL_free(sm2_id);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
BIO_free_all(Sout);
|
BIO_free_all(Sout);
|
||||||
@@ -1302,6 +1298,7 @@ end_of_options:
|
|||||||
BN_free(crlnumber);
|
BN_free(crlnumber);
|
||||||
free_index(db);
|
free_index(db);
|
||||||
sk_OPENSSL_STRING_free(sigopts);
|
sk_OPENSSL_STRING_free(sigopts);
|
||||||
|
sk_OPENSSL_STRING_free(vfyopts);
|
||||||
EVP_PKEY_free(pkey);
|
EVP_PKEY_free(pkey);
|
||||||
X509_free(x509);
|
X509_free(x509);
|
||||||
X509_CRL_free(crl);
|
X509_CRL_free(crl);
|
||||||
@@ -1319,32 +1316,26 @@ static char *lookup_conf(const CONF *conf, const char *section, const char *tag)
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int certify(X509 **xret, const char *infile, EVP_PKEY *pkey, X509 *x509,
|
static int certify(X509 **xret, const char *infile, int informat,
|
||||||
const EVP_MD *dgst, STACK_OF(OPENSSL_STRING) *sigopts,
|
EVP_PKEY *pkey, X509 *x509,
|
||||||
|
const EVP_MD *dgst,
|
||||||
|
STACK_OF(OPENSSL_STRING) *sigopts,
|
||||||
|
STACK_OF(OPENSSL_STRING) *vfyopts,
|
||||||
STACK_OF(CONF_VALUE) *policy, CA_DB *db,
|
STACK_OF(CONF_VALUE) *policy, CA_DB *db,
|
||||||
BIGNUM *serial, const char *subj, unsigned long chtype,
|
BIGNUM *serial, const char *subj, unsigned long chtype,
|
||||||
int multirdn, int email_dn, const char *startdate,
|
int multirdn, int email_dn, const char *startdate,
|
||||||
const char *enddate,
|
const char *enddate,
|
||||||
long days, int batch, const char *ext_sect, CONF *lconf,
|
long days, int batch, const char *ext_sect, CONF *lconf,
|
||||||
int verbose, unsigned long certopt, unsigned long nameopt,
|
int verbose, unsigned long certopt, unsigned long nameopt,
|
||||||
int default_op, int ext_copy, int selfsign,
|
int default_op, int ext_copy, int selfsign)
|
||||||
unsigned char *sm2id, size_t sm2idlen)
|
|
||||||
{
|
{
|
||||||
X509_REQ *req = NULL;
|
X509_REQ *req = NULL;
|
||||||
BIO *in = NULL;
|
|
||||||
EVP_PKEY *pktmp = NULL;
|
EVP_PKEY *pktmp = NULL;
|
||||||
int ok = -1, i;
|
int ok = -1, i;
|
||||||
|
|
||||||
in = BIO_new_file(infile, "r");
|
req = load_csr(infile, informat, "certificate request");
|
||||||
if (in == NULL) {
|
if (req == NULL)
|
||||||
ERR_print_errors(bio_err);
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
|
||||||
if ((req = PEM_read_bio_X509_REQ(in, NULL, NULL, NULL)) == NULL) {
|
|
||||||
BIO_printf(bio_err, "Error reading certificate request in %s\n",
|
|
||||||
infile);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
X509_REQ_print_ex(bio_err, req, nameopt, X509_FLAG_COMPAT);
|
X509_REQ_print_ex(bio_err, req, nameopt, X509_FLAG_COMPAT);
|
||||||
|
|
||||||
@@ -1360,26 +1351,7 @@ static int certify(X509 **xret, const char *infile, EVP_PKEY *pkey, X509 *x509,
|
|||||||
BIO_printf(bio_err, "error unpacking public key\n");
|
BIO_printf(bio_err, "error unpacking public key\n");
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
if (sm2id != NULL) {
|
i = do_X509_REQ_verify(req, pktmp, vfyopts);
|
||||||
#ifndef OPENSSL_NO_SM2
|
|
||||||
ASN1_OCTET_STRING *v;
|
|
||||||
|
|
||||||
v = ASN1_OCTET_STRING_new();
|
|
||||||
if (v == NULL) {
|
|
||||||
BIO_printf(bio_err, "error: SM2 ID allocation failed\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ASN1_OCTET_STRING_set(v, sm2id, sm2idlen)) {
|
|
||||||
BIO_printf(bio_err, "error: setting SM2 ID failed\n");
|
|
||||||
ASN1_OCTET_STRING_free(v);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
X509_REQ_set0_sm2_id(req, v);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
i = X509_REQ_verify(req, pktmp);
|
|
||||||
pktmp = NULL;
|
pktmp = NULL;
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
ok = 0;
|
ok = 0;
|
||||||
@@ -1404,12 +1376,14 @@ static int certify(X509 **xret, const char *infile, EVP_PKEY *pkey, X509 *x509,
|
|||||||
|
|
||||||
end:
|
end:
|
||||||
X509_REQ_free(req);
|
X509_REQ_free(req);
|
||||||
BIO_free(in);
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int certify_cert(X509 **xret, const char *infile, EVP_PKEY *pkey, X509 *x509,
|
static int certify_cert(X509 **xret, const char *infile, int certformat,
|
||||||
const EVP_MD *dgst, STACK_OF(OPENSSL_STRING) *sigopts,
|
EVP_PKEY *pkey, X509 *x509,
|
||||||
|
const EVP_MD *dgst,
|
||||||
|
STACK_OF(OPENSSL_STRING) *sigopts,
|
||||||
|
STACK_OF(OPENSSL_STRING) *vfyopts,
|
||||||
STACK_OF(CONF_VALUE) *policy, CA_DB *db,
|
STACK_OF(CONF_VALUE) *policy, CA_DB *db,
|
||||||
BIGNUM *serial, const char *subj, unsigned long chtype,
|
BIGNUM *serial, const char *subj, unsigned long chtype,
|
||||||
int multirdn, int email_dn, const char *startdate,
|
int multirdn, int email_dn, const char *startdate,
|
||||||
@@ -1422,7 +1396,7 @@ static int certify_cert(X509 **xret, const char *infile, EVP_PKEY *pkey, X509 *x
|
|||||||
EVP_PKEY *pktmp = NULL;
|
EVP_PKEY *pktmp = NULL;
|
||||||
int ok = -1, i;
|
int ok = -1, i;
|
||||||
|
|
||||||
if ((req = load_cert(infile, FORMAT_PEM, infile)) == NULL)
|
if ((req = load_cert(infile, certformat, infile)) == NULL)
|
||||||
goto end;
|
goto end;
|
||||||
if (verbose)
|
if (verbose)
|
||||||
X509_print(bio_err, req);
|
X509_print(bio_err, req);
|
||||||
@@ -1433,7 +1407,7 @@ static int certify_cert(X509 **xret, const char *infile, EVP_PKEY *pkey, X509 *x
|
|||||||
BIO_printf(bio_err, "error unpacking public key\n");
|
BIO_printf(bio_err, "error unpacking public key\n");
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
i = X509_verify(req, pktmp);
|
i = do_X509_verify(req, pktmp, vfyopts);
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
ok = 0;
|
ok = 0;
|
||||||
BIO_printf(bio_err, "Signature verification problems....\n");
|
BIO_printf(bio_err, "Signature verification problems....\n");
|
||||||
@@ -1470,7 +1444,8 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
|
|||||||
CONF *lconf, unsigned long certopt, unsigned long nameopt,
|
CONF *lconf, unsigned long certopt, unsigned long nameopt,
|
||||||
int default_op, int ext_copy, int selfsign)
|
int default_op, int ext_copy, int selfsign)
|
||||||
{
|
{
|
||||||
X509_NAME *name = NULL, *CAname = NULL, *subject = NULL;
|
const X509_NAME *name = NULL;
|
||||||
|
X509_NAME *CAname = NULL, *subject = NULL;
|
||||||
const ASN1_TIME *tm;
|
const ASN1_TIME *tm;
|
||||||
ASN1_STRING *str, *str2;
|
ASN1_STRING *str, *str2;
|
||||||
ASN1_OBJECT *obj;
|
ASN1_OBJECT *obj;
|
||||||
|
|||||||
+3
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -15,6 +15,8 @@
|
|||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
|
|
||||||
|
DEFINE_STACK_OF_CONST(SSL_CIPHER)
|
||||||
|
|
||||||
typedef enum OPTION_choice {
|
typedef enum OPTION_choice {
|
||||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||||
OPT_STDNAME,
|
OPT_STDNAME,
|
||||||
|
|||||||
@@ -0,0 +1,411 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
* Copyright Siemens AG 2018-2020
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or atf
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "apps.h"
|
||||||
|
#include "cmp_mock_srv.h"
|
||||||
|
|
||||||
|
#include <openssl/cmp.h>
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/cmperr.h>
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(X509)
|
||||||
|
DEFINE_STACK_OF(OSSL_CMP_ITAV)
|
||||||
|
DEFINE_STACK_OF(ASN1_UTF8STRING)
|
||||||
|
|
||||||
|
/* the context for the CMP mock server */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
X509 *certOut; /* certificate to be returned in cp/ip/kup msg */
|
||||||
|
STACK_OF(X509) *chainOut; /* chain of certOut to add to extraCerts field */
|
||||||
|
STACK_OF(X509) *caPubsOut; /* certs to return in caPubs field of ip msg */
|
||||||
|
OSSL_CMP_PKISI *statusOut; /* status for ip/cp/kup/rp msg unless polling */
|
||||||
|
int sendError; /* send error response also on valid requests */
|
||||||
|
OSSL_CMP_MSG *certReq; /* ir/cr/p10cr/kur remembered while polling */
|
||||||
|
int certReqId; /* id of last ir/cr/kur, used for polling */
|
||||||
|
int pollCount; /* number of polls before actual cert response */
|
||||||
|
int checkAfterTime; /* time the client should wait between polling */
|
||||||
|
} mock_srv_ctx;
|
||||||
|
|
||||||
|
|
||||||
|
static void mock_srv_ctx_free(mock_srv_ctx *ctx)
|
||||||
|
{
|
||||||
|
if (ctx == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
OSSL_CMP_PKISI_free(ctx->statusOut);
|
||||||
|
X509_free(ctx->certOut);
|
||||||
|
sk_X509_pop_free(ctx->chainOut, X509_free);
|
||||||
|
sk_X509_pop_free(ctx->caPubsOut, X509_free);
|
||||||
|
OSSL_CMP_MSG_free(ctx->certReq);
|
||||||
|
OPENSSL_free(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static mock_srv_ctx *mock_srv_ctx_new(void)
|
||||||
|
{
|
||||||
|
mock_srv_ctx *ctx = OPENSSL_zalloc(sizeof(mock_srv_ctx));
|
||||||
|
|
||||||
|
if (ctx == NULL)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
if ((ctx->statusOut = OSSL_CMP_PKISI_new()) == NULL)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
ctx->certReqId = -1;
|
||||||
|
|
||||||
|
/* all other elements are initialized to 0 or NULL, respectively */
|
||||||
|
return ctx;
|
||||||
|
err:
|
||||||
|
mock_srv_ctx_free(ctx);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ossl_cmp_mock_srv_set1_certOut(OSSL_CMP_SRV_CTX *srv_ctx, X509 *cert)
|
||||||
|
{
|
||||||
|
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
||||||
|
|
||||||
|
if (ctx == NULL) {
|
||||||
|
CMPerr(0, CMP_R_NULL_ARGUMENT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (cert == NULL || X509_up_ref(cert)) {
|
||||||
|
X509_free(ctx->certOut);
|
||||||
|
ctx->certOut = cert;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ossl_cmp_mock_srv_set1_chainOut(OSSL_CMP_SRV_CTX *srv_ctx,
|
||||||
|
STACK_OF(X509) *chain)
|
||||||
|
{
|
||||||
|
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
||||||
|
STACK_OF(X509) *chain_copy = NULL;
|
||||||
|
|
||||||
|
if (ctx == NULL) {
|
||||||
|
CMPerr(0, CMP_R_NULL_ARGUMENT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (chain != NULL && (chain_copy = X509_chain_up_ref(chain)) == NULL)
|
||||||
|
return 0;
|
||||||
|
sk_X509_pop_free(ctx->chainOut, X509_free);
|
||||||
|
ctx->chainOut = chain_copy;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ossl_cmp_mock_srv_set1_caPubsOut(OSSL_CMP_SRV_CTX *srv_ctx,
|
||||||
|
STACK_OF(X509) *caPubs)
|
||||||
|
{
|
||||||
|
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
||||||
|
STACK_OF(X509) *caPubs_copy = NULL;
|
||||||
|
|
||||||
|
if (ctx == NULL) {
|
||||||
|
CMPerr(0, CMP_R_NULL_ARGUMENT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (caPubs != NULL && (caPubs_copy = X509_chain_up_ref(caPubs)) == NULL)
|
||||||
|
return 0;
|
||||||
|
sk_X509_pop_free(ctx->caPubsOut, X509_free);
|
||||||
|
ctx->caPubsOut = caPubs_copy;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ossl_cmp_mock_srv_set_statusInfo(OSSL_CMP_SRV_CTX *srv_ctx, int status,
|
||||||
|
int fail_info, const char *text)
|
||||||
|
{
|
||||||
|
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
||||||
|
OSSL_CMP_PKISI *si;
|
||||||
|
|
||||||
|
if (ctx == NULL) {
|
||||||
|
CMPerr(0, CMP_R_NULL_ARGUMENT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if ((si = OSSL_CMP_STATUSINFO_new(status, fail_info, text)) == NULL)
|
||||||
|
return 0;
|
||||||
|
OSSL_CMP_PKISI_free(ctx->statusOut);
|
||||||
|
ctx->statusOut = si;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ossl_cmp_mock_srv_set_send_error(OSSL_CMP_SRV_CTX *srv_ctx, int val)
|
||||||
|
{
|
||||||
|
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
||||||
|
|
||||||
|
if (ctx == NULL) {
|
||||||
|
CMPerr(0, CMP_R_NULL_ARGUMENT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ctx->sendError = val != 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ossl_cmp_mock_srv_set_pollCount(OSSL_CMP_SRV_CTX *srv_ctx, int count)
|
||||||
|
{
|
||||||
|
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
||||||
|
|
||||||
|
if (ctx == NULL) {
|
||||||
|
CMPerr(0, CMP_R_NULL_ARGUMENT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (count < 0) {
|
||||||
|
CMPerr(0, CMP_R_INVALID_ARGS);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ctx->pollCount = count;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ossl_cmp_mock_srv_set_checkAfterTime(OSSL_CMP_SRV_CTX *srv_ctx, int sec)
|
||||||
|
{
|
||||||
|
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
||||||
|
|
||||||
|
if (ctx == NULL) {
|
||||||
|
CMPerr(0, CMP_R_NULL_ARGUMENT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ctx->checkAfterTime = sec;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static OSSL_CMP_PKISI *process_cert_request(OSSL_CMP_SRV_CTX *srv_ctx,
|
||||||
|
const OSSL_CMP_MSG *cert_req,
|
||||||
|
int certReqId,
|
||||||
|
const OSSL_CRMF_MSG *crm,
|
||||||
|
const X509_REQ *p10cr,
|
||||||
|
X509 **certOut,
|
||||||
|
STACK_OF(X509) **chainOut,
|
||||||
|
STACK_OF(X509) **caPubs)
|
||||||
|
{
|
||||||
|
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
||||||
|
OSSL_CMP_PKISI *si = NULL;
|
||||||
|
|
||||||
|
if (ctx == NULL || cert_req == NULL
|
||||||
|
|| certOut == NULL || chainOut == NULL || caPubs == NULL) {
|
||||||
|
CMPerr(0, CMP_R_NULL_ARGUMENT);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (ctx->sendError) {
|
||||||
|
CMPerr(0, CMP_R_ERROR_PROCESSING_MESSAGE);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*certOut = NULL;
|
||||||
|
*chainOut = NULL;
|
||||||
|
*caPubs = NULL;
|
||||||
|
ctx->certReqId = certReqId;
|
||||||
|
if (ctx->pollCount > 0) {
|
||||||
|
ctx->pollCount--;
|
||||||
|
OSSL_CMP_MSG_free(ctx->certReq);
|
||||||
|
if ((ctx->certReq = OSSL_CMP_MSG_dup(cert_req)) == NULL)
|
||||||
|
return NULL;
|
||||||
|
return OSSL_CMP_STATUSINFO_new(OSSL_CMP_PKISTATUS_waiting, 0, NULL);
|
||||||
|
}
|
||||||
|
if (ctx->certOut != NULL
|
||||||
|
&& (*certOut = X509_dup(ctx->certOut)) == NULL)
|
||||||
|
goto err;
|
||||||
|
if (ctx->chainOut != NULL
|
||||||
|
&& (*chainOut = X509_chain_up_ref(ctx->chainOut)) == NULL)
|
||||||
|
goto err;
|
||||||
|
if (ctx->caPubsOut != NULL
|
||||||
|
&& (*caPubs = X509_chain_up_ref(ctx->caPubsOut)) == NULL)
|
||||||
|
goto err;
|
||||||
|
if (ctx->statusOut != NULL
|
||||||
|
&& (si = OSSL_CMP_PKISI_dup(ctx->statusOut)) == NULL)
|
||||||
|
goto err;
|
||||||
|
return si;
|
||||||
|
|
||||||
|
err:
|
||||||
|
X509_free(*certOut);
|
||||||
|
*certOut = NULL;
|
||||||
|
sk_X509_pop_free(*chainOut, X509_free);
|
||||||
|
*chainOut = NULL;
|
||||||
|
sk_X509_pop_free(*caPubs, X509_free);
|
||||||
|
*caPubs = NULL;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static OSSL_CMP_PKISI *process_rr(OSSL_CMP_SRV_CTX *srv_ctx,
|
||||||
|
const OSSL_CMP_MSG *rr,
|
||||||
|
const X509_NAME *issuer,
|
||||||
|
const ASN1_INTEGER *serial)
|
||||||
|
{
|
||||||
|
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
||||||
|
|
||||||
|
if (ctx == NULL || rr == NULL || issuer == NULL || serial == NULL) {
|
||||||
|
CMPerr(0, CMP_R_NULL_ARGUMENT);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (ctx->sendError || ctx->certOut == NULL) {
|
||||||
|
CMPerr(0, CMP_R_ERROR_PROCESSING_MESSAGE);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* accept revocation only for the certificate we sent in ir/cr/kur */
|
||||||
|
if (X509_NAME_cmp(issuer, X509_get_issuer_name(ctx->certOut)) != 0
|
||||||
|
|| ASN1_INTEGER_cmp(serial,
|
||||||
|
X509_get0_serialNumber(ctx->certOut)) != 0) {
|
||||||
|
CMPerr(0, CMP_R_REQUEST_NOT_ACCEPTED);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return OSSL_CMP_PKISI_dup(ctx->statusOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int process_genm(OSSL_CMP_SRV_CTX *srv_ctx,
|
||||||
|
const OSSL_CMP_MSG *genm,
|
||||||
|
const STACK_OF(OSSL_CMP_ITAV) *in,
|
||||||
|
STACK_OF(OSSL_CMP_ITAV) **out)
|
||||||
|
{
|
||||||
|
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
||||||
|
|
||||||
|
if (ctx == NULL || genm == NULL || in == NULL || out == NULL) {
|
||||||
|
CMPerr(0, CMP_R_NULL_ARGUMENT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (ctx->sendError) {
|
||||||
|
CMPerr(0, CMP_R_ERROR_PROCESSING_MESSAGE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = sk_OSSL_CMP_ITAV_deep_copy(in, OSSL_CMP_ITAV_dup,
|
||||||
|
OSSL_CMP_ITAV_free);
|
||||||
|
return *out != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void process_error(OSSL_CMP_SRV_CTX *srv_ctx, const OSSL_CMP_MSG *error,
|
||||||
|
const OSSL_CMP_PKISI *statusInfo,
|
||||||
|
const ASN1_INTEGER *errorCode,
|
||||||
|
const OSSL_CMP_PKIFREETEXT *errorDetails)
|
||||||
|
{
|
||||||
|
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
||||||
|
char buf[OSSL_CMP_PKISI_BUFLEN];
|
||||||
|
char *sibuf;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (ctx == NULL || error == NULL) {
|
||||||
|
CMPerr(0, CMP_R_NULL_ARGUMENT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BIO_printf(bio_err, "mock server received error:\n");
|
||||||
|
|
||||||
|
if (statusInfo == NULL) {
|
||||||
|
BIO_printf(bio_err, "pkiStatusInfo absent\n");
|
||||||
|
} else {
|
||||||
|
sibuf = OSSL_CMP_snprint_PKIStatusInfo(statusInfo, buf, sizeof(buf));
|
||||||
|
BIO_printf(bio_err, "pkiStatusInfo: %s\n",
|
||||||
|
sibuf != NULL ? sibuf: "<invalid>");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errorCode == NULL)
|
||||||
|
BIO_printf(bio_err, "errorCode absent\n");
|
||||||
|
else
|
||||||
|
BIO_printf(bio_err, "errorCode: %ld\n", ASN1_INTEGER_get(errorCode));
|
||||||
|
|
||||||
|
if (sk_ASN1_UTF8STRING_num(errorDetails) <= 0) {
|
||||||
|
BIO_printf(bio_err, "errorDetails absent\n");
|
||||||
|
} else {
|
||||||
|
/* TODO could use sk_ASN1_UTF8STRING2text() if exported */
|
||||||
|
BIO_printf(bio_err, "errorDetails: ");
|
||||||
|
for (i = 0; i < sk_ASN1_UTF8STRING_num(errorDetails); i++) {
|
||||||
|
if (i > 0)
|
||||||
|
BIO_printf(bio_err, ", ");
|
||||||
|
BIO_printf(bio_err, "\"");
|
||||||
|
ASN1_STRING_print(bio_err,
|
||||||
|
sk_ASN1_UTF8STRING_value(errorDetails, i));
|
||||||
|
BIO_printf(bio_err, "\"");
|
||||||
|
}
|
||||||
|
BIO_printf(bio_err, "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int process_certConf(OSSL_CMP_SRV_CTX *srv_ctx,
|
||||||
|
const OSSL_CMP_MSG *certConf, int certReqId,
|
||||||
|
const ASN1_OCTET_STRING *certHash,
|
||||||
|
const OSSL_CMP_PKISI *si)
|
||||||
|
{
|
||||||
|
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
||||||
|
ASN1_OCTET_STRING *digest;
|
||||||
|
|
||||||
|
if (ctx == NULL || certConf == NULL || certHash == NULL) {
|
||||||
|
CMPerr(0, CMP_R_NULL_ARGUMENT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (ctx->sendError || ctx->certOut == NULL) {
|
||||||
|
CMPerr(0, CMP_R_ERROR_PROCESSING_MESSAGE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (certReqId != ctx->certReqId) {
|
||||||
|
/* in case of error, invalid reqId -1 */
|
||||||
|
CMPerr(0, CMP_R_BAD_REQUEST_ID);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((digest = X509_digest_sig(ctx->certOut)) == NULL)
|
||||||
|
return 0;
|
||||||
|
if (ASN1_OCTET_STRING_cmp(certHash, digest) != 0) {
|
||||||
|
ASN1_OCTET_STRING_free(digest);
|
||||||
|
CMPerr(0, CMP_R_CERTHASH_UNMATCHED);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ASN1_OCTET_STRING_free(digest);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int process_pollReq(OSSL_CMP_SRV_CTX *srv_ctx,
|
||||||
|
const OSSL_CMP_MSG *pollReq, int certReqId,
|
||||||
|
OSSL_CMP_MSG **certReq, int64_t *check_after)
|
||||||
|
{
|
||||||
|
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);
|
||||||
|
|
||||||
|
if (ctx == NULL || pollReq == NULL
|
||||||
|
|| certReq == NULL || check_after == NULL) {
|
||||||
|
CMPerr(0, CMP_R_NULL_ARGUMENT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (ctx->sendError || ctx->certReq == NULL) {
|
||||||
|
*certReq = NULL;
|
||||||
|
CMPerr(0, CMP_R_ERROR_PROCESSING_MESSAGE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ctx->pollCount == 0) {
|
||||||
|
*certReq = ctx->certReq;
|
||||||
|
ctx->certReq = NULL;
|
||||||
|
*check_after = 0;
|
||||||
|
} else {
|
||||||
|
ctx->pollCount--;
|
||||||
|
*certReq = NULL;
|
||||||
|
*check_after = ctx->checkAfterTime;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
OSSL_CMP_SRV_CTX *ossl_cmp_mock_srv_new(void)
|
||||||
|
{
|
||||||
|
OSSL_CMP_SRV_CTX *srv_ctx = OSSL_CMP_SRV_CTX_new();
|
||||||
|
mock_srv_ctx *ctx = mock_srv_ctx_new();
|
||||||
|
|
||||||
|
if (srv_ctx != NULL && ctx != NULL
|
||||||
|
&& OSSL_CMP_SRV_CTX_init(srv_ctx, ctx, process_cert_request,
|
||||||
|
process_rr, process_genm, process_error,
|
||||||
|
process_certConf, process_pollReq))
|
||||||
|
return srv_ctx;
|
||||||
|
|
||||||
|
mock_srv_ctx_free(ctx);
|
||||||
|
OSSL_CMP_SRV_CTX_free(srv_ctx);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ossl_cmp_mock_srv_free(OSSL_CMP_SRV_CTX *srv_ctx)
|
||||||
|
{
|
||||||
|
if (srv_ctx != NULL)
|
||||||
|
mock_srv_ctx_free(OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx));
|
||||||
|
OSSL_CMP_SRV_CTX_free(srv_ctx);
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
* Copyright Siemens AG 2018-2020
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef OSSL_APPS_CMP_MOCK_SRV_H
|
||||||
|
# define OSSL_APPS_CMP_MOCK_SRV_H
|
||||||
|
|
||||||
|
# include <openssl/opensslconf.h>
|
||||||
|
# ifndef OPENSSL_NO_CMP
|
||||||
|
|
||||||
|
# include <openssl/cmp.h>
|
||||||
|
|
||||||
|
OSSL_CMP_SRV_CTX *ossl_cmp_mock_srv_new(void);
|
||||||
|
void ossl_cmp_mock_srv_free(OSSL_CMP_SRV_CTX *srv_ctx);
|
||||||
|
|
||||||
|
int ossl_cmp_mock_srv_set1_certOut(OSSL_CMP_SRV_CTX *srv_ctx, X509 *cert);
|
||||||
|
int ossl_cmp_mock_srv_set1_chainOut(OSSL_CMP_SRV_CTX *srv_ctx,
|
||||||
|
STACK_OF(X509) *chain);
|
||||||
|
int ossl_cmp_mock_srv_set1_caPubsOut(OSSL_CMP_SRV_CTX *srv_ctx,
|
||||||
|
STACK_OF(X509) *caPubs);
|
||||||
|
int ossl_cmp_mock_srv_set_statusInfo(OSSL_CMP_SRV_CTX *srv_ctx, int status,
|
||||||
|
int fail_info, const char *text);
|
||||||
|
int ossl_cmp_mock_srv_set_send_error(OSSL_CMP_SRV_CTX *srv_ctx, int val);
|
||||||
|
int ossl_cmp_mock_srv_set_pollCount(OSSL_CMP_SRV_CTX *srv_ctx, int count);
|
||||||
|
int ossl_cmp_mock_srv_set_checkAfterTime(OSSL_CMP_SRV_CTX *srv_ctx, int sec);
|
||||||
|
|
||||||
|
# endif /* !defined(OPENSSL_NO_CMP) */
|
||||||
|
#endif /* !defined(OSSL_APPS_CMP_MOCK_SRV_H) */
|
||||||
+7
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008-2019 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2008-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -23,6 +23,12 @@
|
|||||||
# include <openssl/x509v3.h>
|
# include <openssl/x509v3.h>
|
||||||
# include <openssl/cms.h>
|
# include <openssl/cms.h>
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(X509)
|
||||||
|
DEFINE_STACK_OF(CMS_SignerInfo)
|
||||||
|
DEFINE_STACK_OF(GENERAL_NAME)
|
||||||
|
DEFINE_STACK_OF(GENERAL_NAMES)
|
||||||
|
DEFINE_STACK_OF_STRING()
|
||||||
|
|
||||||
static int save_certs(char *signerfile, STACK_OF(X509) *signers);
|
static int save_certs(char *signerfile, STACK_OF(X509) *signers);
|
||||||
static int cms_cb(int ok, X509_STORE_CTX *ctx);
|
static int cms_cb(int ok, X509_STORE_CTX *ctx);
|
||||||
static void receipt_request_print(CMS_ContentInfo *cms);
|
static void receipt_request_print(CMS_ContentInfo *cms);
|
||||||
|
|||||||
+4
-4
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -46,7 +46,7 @@ const OPTIONS crl_options[] = {
|
|||||||
#ifndef OPENSSL_NO_MD5
|
#ifndef OPENSSL_NO_MD5
|
||||||
{"hash_old", OPT_HASH_OLD, '-', "Print old-style (MD5) hash value"},
|
{"hash_old", OPT_HASH_OLD, '-', "Print old-style (MD5) hash value"},
|
||||||
#endif
|
#endif
|
||||||
{"nameopt", OPT_NAMEOPT, 's', "Various certificate name options"},
|
{"nameopt", OPT_NAMEOPT, 's', "Certificate subject/issuer name printing options"},
|
||||||
{"", OPT_MD, '-', "Any supported digest"},
|
{"", OPT_MD, '-', "Any supported digest"},
|
||||||
|
|
||||||
OPT_SECTION("CRL"),
|
OPT_SECTION("CRL"),
|
||||||
@@ -205,7 +205,7 @@ int crl_main(int argc, char **argv)
|
|||||||
if (argc != 0)
|
if (argc != 0)
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
|
||||||
x = load_crl(infile, informat);
|
x = load_crl(infile, informat, "CRL");
|
||||||
if (x == NULL)
|
if (x == NULL)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
@@ -250,7 +250,7 @@ int crl_main(int argc, char **argv)
|
|||||||
BIO_puts(bio_err, "Missing CRL signing key\n");
|
BIO_puts(bio_err, "Missing CRL signing key\n");
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
newcrl = load_crl(crldiff, informat);
|
newcrl = load_crl(crldiff, informat, "other CRL");
|
||||||
if (!newcrl)
|
if (!newcrl)
|
||||||
goto end;
|
goto end;
|
||||||
pkey = load_key(keyfile, keyformat, 0, NULL, NULL, "CRL signing key");
|
pkey = load_key(keyfile, keyformat, 0, NULL, NULL, "CRL signing key");
|
||||||
|
|||||||
+6
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -19,6 +19,11 @@
|
|||||||
#include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
#include <openssl/objects.h>
|
#include <openssl/objects.h>
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(X509_CRL)
|
||||||
|
DEFINE_STACK_OF(X509)
|
||||||
|
DEFINE_STACK_OF(X509_INFO)
|
||||||
|
DEFINE_STACK_OF_STRING()
|
||||||
|
|
||||||
static int add_certs_from_file(STACK_OF(X509) *stack, char *certfile);
|
static int add_certs_from_file(STACK_OF(X509) *stack, char *certfile);
|
||||||
|
|
||||||
typedef enum OPTION_choice {
|
typedef enum OPTION_choice {
|
||||||
|
|||||||
+3
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -21,6 +21,8 @@
|
|||||||
#include <openssl/hmac.h>
|
#include <openssl/hmac.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
DEFINE_STACK_OF_STRING()
|
||||||
|
|
||||||
#undef BUFSIZE
|
#undef BUFSIZE
|
||||||
#define BUFSIZE 1024*8
|
#define BUFSIZE 1024*8
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
-----BEGIN DH PARAMETERS-----
|
|
||||||
MIGHAoGBAP//////////yQ/aoiFowjTExmKLgNwc0SkCTgiKZ8x0Agu+pjsTmyJR
|
|
||||||
Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL
|
|
||||||
/1y29Aa37e44a/taiZ+lrp8kEXxLH+ZJKGZR7OZTgf//////////AgEC
|
|
||||||
-----END DH PARAMETERS-----
|
|
||||||
|
|
||||||
These are the 1024-bit DH parameters from "Internet Key Exchange
|
|
||||||
Protocol Version 2 (IKEv2)": https://tools.ietf.org/html/rfc5996
|
|
||||||
|
|
||||||
See https://tools.ietf.org/html/rfc2412 for how they were generated.
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
-----BEGIN DH PARAMETERS-----
|
|
||||||
MIIBCAKCAQEA///////////JD9qiIWjCNMTGYouA3BzRKQJOCIpnzHQCC76mOxOb
|
|
||||||
IlFKCHmONATd75UZs806QxswKwpt8l8UN0/hNW1tUcJF5IW1dmJefsb0TELppjft
|
|
||||||
awv/XLb0Brft7jhr+1qJn6WunyQRfEsf5kkoZlHs5Fs9wgB8uKFjvwWY2kg2HFXT
|
|
||||||
mmkWP6j9JM9fg2VdI9yjrZYcYvNWIIVSu57VKQdwlpZtZww1Tkq8mATxdGwIyhgh
|
|
||||||
fDKQXkYuNs474553LBgOhgObJ4Oi7Aeij7XFXfBvTFLJ3ivL9pVYFxg5lUl86pVq
|
|
||||||
5RXSJhiY+gUQFXKOWoqsqmj//////////wIBAg==
|
|
||||||
-----END DH PARAMETERS-----
|
|
||||||
|
|
||||||
These are the 2048-bit DH parameters from "More Modular Exponential
|
|
||||||
(MODP) Diffie-Hellman groups for Internet Key Exchange (IKE)":
|
|
||||||
https://tools.ietf.org/html/rfc3526
|
|
||||||
|
|
||||||
See https://tools.ietf.org/html/rfc2412 for how they were generated.
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
-----BEGIN DH PARAMETERS-----
|
|
||||||
MIICCAKCAgEA///////////JD9qiIWjCNMTGYouA3BzRKQJOCIpnzHQCC76mOxOb
|
|
||||||
IlFKCHmONATd75UZs806QxswKwpt8l8UN0/hNW1tUcJF5IW1dmJefsb0TELppjft
|
|
||||||
awv/XLb0Brft7jhr+1qJn6WunyQRfEsf5kkoZlHs5Fs9wgB8uKFjvwWY2kg2HFXT
|
|
||||||
mmkWP6j9JM9fg2VdI9yjrZYcYvNWIIVSu57VKQdwlpZtZww1Tkq8mATxdGwIyhgh
|
|
||||||
fDKQXkYuNs474553LBgOhgObJ4Oi7Aeij7XFXfBvTFLJ3ivL9pVYFxg5lUl86pVq
|
|
||||||
5RXSJhiY+gUQFXKOWoqqxC2tMxcNBFB6M6hVIavfHLpk7PuFBFjb7wqK6nFXXQYM
|
|
||||||
fbOXD4Wm4eTHq/WujNsJM9cejJTgSiVhnc7j0iYa0u5r8S/6BtmKCGTYdgJzPshq
|
|
||||||
ZFIfKxgXeyAMu+EXV3phXWx3CYjAutlG4gjiT6B05asxQ9tb/OD9EI5LgtEgqSEI
|
|
||||||
ARpyPBKnh+bXiHGaEL26WyaZwycYavTiPBqUaDS2FQvaJYPpyirUTOjbu8LbBN6O
|
|
||||||
+S6O/BQfvsqmKHxZR05rwF2ZspZPoJDDoiM7oYZRW+ftH2EpcM7i16+4G912IXBI
|
|
||||||
HNAGkSfVsFqpk7TqmI2P3cGG/7fckKbAj030Nck0BjGZ//////////8CAQI=
|
|
||||||
-----END DH PARAMETERS-----
|
|
||||||
|
|
||||||
These are the 4096-bit DH parameters from "More Modular Exponential
|
|
||||||
(MODP) Diffie-Hellman groups for Internet Key Exchange (IKE)":
|
|
||||||
https://tools.ietf.org/html/rfc3526
|
|
||||||
|
|
||||||
See https://tools.ietf.org/html/rfc2412 for how they were generated.
|
|
||||||
+97
-76
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -7,34 +7,35 @@
|
|||||||
* https://www.openssl.org/source/license.html
|
* https://www.openssl.org/source/license.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||||
/* We need to use some deprecated APIs */
|
/* We need to use some deprecated APIs */
|
||||||
#define OPENSSL_SUPPRESS_DEPRECATED
|
# define OPENSSL_SUPPRESS_DEPRECATED
|
||||||
|
#endif
|
||||||
#include <openssl/opensslconf.h>
|
#include <openssl/opensslconf.h>
|
||||||
#ifdef OPENSSL_NO_DH
|
|
||||||
NON_EMPTY_TRANSLATION_UNIT
|
|
||||||
#else
|
|
||||||
|
|
||||||
# include <stdio.h>
|
#include <stdio.h>
|
||||||
# include <stdlib.h>
|
#include <stdlib.h>
|
||||||
# include <time.h>
|
#include <time.h>
|
||||||
# include <string.h>
|
#include <string.h>
|
||||||
# include "apps.h"
|
#include "apps.h"
|
||||||
# include "progs.h"
|
#include "progs.h"
|
||||||
# include <openssl/bio.h>
|
#include <openssl/bio.h>
|
||||||
# include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
# include <openssl/bn.h>
|
#include <openssl/bn.h>
|
||||||
# include <openssl/dh.h>
|
#include <openssl/dh.h>
|
||||||
# include <openssl/x509.h>
|
#include <openssl/x509.h>
|
||||||
# include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_DSA
|
#if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||||
# include <openssl/dsa.h>
|
# include <openssl/dsa.h>
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
# define DEFBITS 2048
|
#define DEFBITS 2048
|
||||||
|
|
||||||
|
#if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||||
static int dh_cb(int p, int n, BN_GENCB *cb);
|
static int dh_cb(int p, int n, BN_GENCB *cb);
|
||||||
|
#endif
|
||||||
|
static int gendh_cb(EVP_PKEY_CTX *ctx);
|
||||||
|
|
||||||
typedef enum OPTION_choice {
|
typedef enum OPTION_choice {
|
||||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||||
@@ -50,13 +51,13 @@ const OPTIONS dhparam_options[] = {
|
|||||||
OPT_SECTION("General"),
|
OPT_SECTION("General"),
|
||||||
{"help", OPT_HELP, '-', "Display this summary"},
|
{"help", OPT_HELP, '-', "Display this summary"},
|
||||||
{"check", OPT_CHECK, '-', "Check the DH parameters"},
|
{"check", OPT_CHECK, '-', "Check the DH parameters"},
|
||||||
# ifndef OPENSSL_NO_DSA
|
#ifndef OPENSSL_NO_DSA
|
||||||
{"dsaparam", OPT_DSAPARAM, '-',
|
{"dsaparam", OPT_DSAPARAM, '-',
|
||||||
"Read or generate DSA parameters, convert to DH"},
|
"Read or generate DSA parameters, convert to DH"},
|
||||||
# endif
|
#endif
|
||||||
# ifndef OPENSSL_NO_ENGINE
|
#ifndef OPENSSL_NO_ENGINE
|
||||||
{"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
|
{"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
OPT_SECTION("Input"),
|
OPT_SECTION("Input"),
|
||||||
{"in", OPT_IN, '<', "Input file"},
|
{"in", OPT_IN, '<', "Input file"},
|
||||||
@@ -84,9 +85,11 @@ int dhparam_main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
BIO *in = NULL, *out = NULL;
|
BIO *in = NULL, *out = NULL;
|
||||||
DH *dh = NULL;
|
DH *dh = NULL;
|
||||||
|
EVP_PKEY *pkey = NULL;
|
||||||
|
EVP_PKEY_CTX *ctx = NULL;
|
||||||
char *infile = NULL, *outfile = NULL, *prog;
|
char *infile = NULL, *outfile = NULL, *prog;
|
||||||
ENGINE *e = NULL;
|
ENGINE *e = NULL;
|
||||||
#ifndef OPENSSL_NO_DSA
|
#if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||||
int dsaparam = 0;
|
int dsaparam = 0;
|
||||||
#endif
|
#endif
|
||||||
int i, text = 0, C = 0, ret = 1, num = 0, g = 0;
|
int i, text = 0, C = 0, ret = 1, num = 0, g = 0;
|
||||||
@@ -130,7 +133,11 @@ int dhparam_main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
case OPT_DSAPARAM:
|
case OPT_DSAPARAM:
|
||||||
#ifndef OPENSSL_NO_DSA
|
#ifndef OPENSSL_NO_DSA
|
||||||
|
# ifdef OPENSSL_NO_DEPRECATED_3_0
|
||||||
|
BIO_printf(bio_err, "The dsaparam option is deprecated.\n");
|
||||||
|
# else
|
||||||
dsaparam = 1;
|
dsaparam = 1;
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case OPT_C:
|
case OPT_C:
|
||||||
@@ -167,13 +174,13 @@ int dhparam_main(int argc, char **argv)
|
|||||||
if (g && !num)
|
if (g && !num)
|
||||||
num = DEFBITS;
|
num = DEFBITS;
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_DSA
|
#if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||||
if (dsaparam && g) {
|
if (dsaparam && g) {
|
||||||
BIO_printf(bio_err,
|
BIO_printf(bio_err,
|
||||||
"generator may not be chosen for DSA parameters\n");
|
"generator may not be chosen for DSA parameters\n");
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
out = bio_open_default(outfile, 'w', outformat);
|
out = bio_open_default(outfile, 'w', outformat);
|
||||||
if (out == NULL)
|
if (out == NULL)
|
||||||
@@ -185,8 +192,12 @@ int dhparam_main(int argc, char **argv)
|
|||||||
|
|
||||||
if (num) {
|
if (num) {
|
||||||
|
|
||||||
BN_GENCB *cb;
|
|
||||||
cb = BN_GENCB_new();
|
#if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||||
|
if (dsaparam) {
|
||||||
|
DSA *dsa = DSA_new();
|
||||||
|
BN_GENCB *cb = BN_GENCB_new();
|
||||||
|
|
||||||
if (cb == NULL) {
|
if (cb == NULL) {
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
goto end;
|
goto end;
|
||||||
@@ -194,10 +205,6 @@ int dhparam_main(int argc, char **argv)
|
|||||||
|
|
||||||
BN_GENCB_set(cb, dh_cb, bio_err);
|
BN_GENCB_set(cb, dh_cb, bio_err);
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_DSA
|
|
||||||
if (dsaparam) {
|
|
||||||
DSA *dsa = DSA_new();
|
|
||||||
|
|
||||||
BIO_printf(bio_err,
|
BIO_printf(bio_err,
|
||||||
"Generating DSA parameters, %d bit long prime\n", num);
|
"Generating DSA parameters, %d bit long prime\n", num);
|
||||||
if (dsa == NULL
|
if (dsa == NULL
|
||||||
@@ -211,34 +218,51 @@ int dhparam_main(int argc, char **argv)
|
|||||||
|
|
||||||
dh = DSA_dup_DH(dsa);
|
dh = DSA_dup_DH(dsa);
|
||||||
DSA_free(dsa);
|
DSA_free(dsa);
|
||||||
if (dh == NULL) {
|
|
||||||
BN_GENCB_free(cb);
|
BN_GENCB_free(cb);
|
||||||
|
if (dh == NULL) {
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
# endif
|
#endif
|
||||||
{
|
{
|
||||||
dh = DH_new();
|
ctx = EVP_PKEY_CTX_new_from_name(NULL, "DH", NULL);
|
||||||
|
if (ctx == NULL) {
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
BIO_printf(bio_err,
|
||||||
|
"Error, DH key generation context allocation failed\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
EVP_PKEY_CTX_set_cb(ctx, gendh_cb);
|
||||||
|
EVP_PKEY_CTX_set_app_data(ctx, bio_err);
|
||||||
BIO_printf(bio_err,
|
BIO_printf(bio_err,
|
||||||
"Generating DH parameters, %d bit long safe prime, generator %d\n",
|
"Generating DH parameters, %d bit long safe prime, generator %d\n",
|
||||||
num, g);
|
num, g);
|
||||||
BIO_printf(bio_err, "This is going to take a long time\n");
|
BIO_printf(bio_err, "This is going to take a long time\n");
|
||||||
if (dh == NULL || !DH_generate_parameters_ex(dh, num, g, cb)) {
|
if (!EVP_PKEY_paramgen_init(ctx)) {
|
||||||
BN_GENCB_free(cb);
|
BIO_printf(bio_err,
|
||||||
|
"Error, unable to initialise DH param generation\n");
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx, num)) {
|
||||||
|
BIO_printf(bio_err, "Error, unable to set DH prime length\n");
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
if (!EVP_PKEY_paramgen(ctx, &pkey)) {
|
||||||
|
BIO_printf(bio_err, "Error, DH generation failed\n");
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BN_GENCB_free(cb);
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
in = bio_open_default(infile, 'r', informat);
|
in = bio_open_default(infile, 'r', informat);
|
||||||
if (in == NULL)
|
if (in == NULL)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_DSA
|
#if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||||
if (dsaparam) {
|
if (dsaparam) {
|
||||||
DSA *dsa;
|
DSA *dsa;
|
||||||
|
|
||||||
@@ -260,17 +284,17 @@ int dhparam_main(int argc, char **argv)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
# endif
|
#endif
|
||||||
{
|
{
|
||||||
if (informat == FORMAT_ASN1) {
|
if (informat == FORMAT_ASN1) {
|
||||||
/*
|
/*
|
||||||
* We have no PEM header to determine what type of DH params it
|
* We have no PEM header to determine what type of DH params it
|
||||||
* is. We'll just try both.
|
* is. We'll just try both.
|
||||||
*/
|
*/
|
||||||
dh = d2i_DHparams_bio(in, NULL);
|
dh = ASN1_d2i_bio_of(DH, DH_new, d2i_DHparams, in, NULL);
|
||||||
/* BIO_reset() returns 0 for success for file BIOs only!!! */
|
/* BIO_reset() returns 0 for success for file BIOs only!!! */
|
||||||
if (dh == NULL && BIO_reset(in) == 0)
|
if (dh == NULL && BIO_reset(in) == 0)
|
||||||
dh = d2i_DHxparams_bio(in, NULL);
|
dh = ASN1_d2i_bio_of(DH, DH_new, d2i_DHxparams, in, NULL);
|
||||||
} else {
|
} else {
|
||||||
/* informat == FORMAT_PEM */
|
/* informat == FORMAT_PEM */
|
||||||
dh = PEM_read_bio_DHparams(in, NULL, NULL, NULL);
|
dh = PEM_read_bio_DHparams(in, NULL, NULL, NULL);
|
||||||
@@ -282,37 +306,20 @@ int dhparam_main(int argc, char **argv)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* dh != NULL */
|
/* dh != NULL */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text) {
|
if (text)
|
||||||
DHparams_print(out, dh);
|
EVP_PKEY_print_params(out, pkey, 4, NULL);
|
||||||
}
|
|
||||||
|
|
||||||
if (check) {
|
if (check) {
|
||||||
if (!DH_check(dh, &i)) {
|
if (!EVP_PKEY_param_check(ctx) /* DH_check(dh, &i) */) {
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
|
BIO_printf(bio_err, "ERROR: Invalid parameters generated\n");
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
if (i & DH_CHECK_P_NOT_PRIME)
|
|
||||||
BIO_printf(bio_err, "WARNING: p value is not prime\n");
|
|
||||||
if (i & DH_CHECK_P_NOT_SAFE_PRIME)
|
|
||||||
BIO_printf(bio_err, "WARNING: p value is not a safe prime\n");
|
|
||||||
if (i & DH_CHECK_Q_NOT_PRIME)
|
|
||||||
BIO_printf(bio_err, "WARNING: q value is not a prime\n");
|
|
||||||
if (i & DH_CHECK_INVALID_Q_VALUE)
|
|
||||||
BIO_printf(bio_err, "WARNING: q value is invalid\n");
|
|
||||||
if (i & DH_CHECK_INVALID_J_VALUE)
|
|
||||||
BIO_printf(bio_err, "WARNING: j value is invalid\n");
|
|
||||||
if (i & DH_UNABLE_TO_CHECK_GENERATOR)
|
|
||||||
BIO_printf(bio_err,
|
|
||||||
"WARNING: unable to check the generator value\n");
|
|
||||||
if (i & DH_NOT_SUITABLE_GENERATOR)
|
|
||||||
BIO_printf(bio_err, "WARNING: the g value is not a generator\n");
|
|
||||||
if (i == 0)
|
|
||||||
BIO_printf(bio_err, "DH parameters appear to be ok.\n");
|
BIO_printf(bio_err, "DH parameters appear to be ok.\n");
|
||||||
if (num != 0 && i != 0) {
|
if (num != 0) {
|
||||||
/*
|
/*
|
||||||
* We have generated parameters but DH_check() indicates they are
|
* We have generated parameters but DH_check() indicates they are
|
||||||
* invalid! This should never happen!
|
* invalid! This should never happen!
|
||||||
@@ -326,8 +333,9 @@ int dhparam_main(int argc, char **argv)
|
|||||||
int len, bits;
|
int len, bits;
|
||||||
const BIGNUM *pbn, *gbn;
|
const BIGNUM *pbn, *gbn;
|
||||||
|
|
||||||
len = DH_size(dh);
|
dh = EVP_PKEY_get0_DH(pkey);
|
||||||
bits = DH_bits(dh);
|
len = EVP_PKEY_size(pkey);
|
||||||
|
bits = EVP_PKEY_size(pkey);
|
||||||
DH_get0_pqg(dh, &pbn, NULL, &gbn);
|
DH_get0_pqg(dh, &pbn, NULL, &gbn);
|
||||||
data = app_malloc(len, "print a BN");
|
data = app_malloc(len, "print a BN");
|
||||||
|
|
||||||
@@ -365,9 +373,9 @@ int dhparam_main(int argc, char **argv)
|
|||||||
DH_get0_pqg(dh, NULL, &q, NULL);
|
DH_get0_pqg(dh, NULL, &q, NULL);
|
||||||
if (outformat == FORMAT_ASN1) {
|
if (outformat == FORMAT_ASN1) {
|
||||||
if (q != NULL)
|
if (q != NULL)
|
||||||
i = i2d_DHxparams_bio(out, dh);
|
i = ASN1_i2d_bio_of(DH, i2d_DHxparams, out, dh);
|
||||||
else
|
else
|
||||||
i = i2d_DHparams_bio(out, dh);
|
i = ASN1_i2d_bio_of(DH, i2d_DHparams, out, dh);
|
||||||
} else if (q != NULL) {
|
} else if (q != NULL) {
|
||||||
i = PEM_write_bio_DHxparams(out, dh);
|
i = PEM_write_bio_DHxparams(out, dh);
|
||||||
} else {
|
} else {
|
||||||
@@ -383,18 +391,31 @@ int dhparam_main(int argc, char **argv)
|
|||||||
end:
|
end:
|
||||||
BIO_free(in);
|
BIO_free(in);
|
||||||
BIO_free_all(out);
|
BIO_free_all(out);
|
||||||
DH_free(dh);
|
EVP_PKEY_free(pkey);
|
||||||
|
EVP_PKEY_CTX_free(ctx);
|
||||||
release_engine(e);
|
release_engine(e);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dh_cb(int p, int n, BN_GENCB *cb)
|
static int common_dh_cb(int p, BIO *b)
|
||||||
{
|
{
|
||||||
static const char symbols[] = ".+*\n";
|
static const char symbols[] = ".+*\n";
|
||||||
char c = (p >= 0 && (size_t)p < sizeof(symbols) - 1) ? symbols[p] : '?';
|
char c = (p >= 0 && (size_t)p < sizeof(symbols) - 1) ? symbols[p] : '?';
|
||||||
|
|
||||||
BIO_write(BN_GENCB_get_arg(cb), &c, 1);
|
BIO_write(b, &c, 1);
|
||||||
(void)BIO_flush(BN_GENCB_get_arg(cb));
|
(void)BIO_flush(b);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||||
|
static int dh_cb(int p, int n, BN_GENCB *cb)
|
||||||
|
{
|
||||||
|
return common_dh_cb(p, BN_GENCB_get_arg(cb));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static int gendh_cb(EVP_PKEY_CTX *ctx)
|
||||||
|
{
|
||||||
|
return common_dh_cb(EVP_PKEY_CTX_get_keygen_info(ctx, 0),
|
||||||
|
EVP_PKEY_CTX_get_app_data(ctx));
|
||||||
|
}
|
||||||
+27
-37
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -7,27 +7,21 @@
|
|||||||
* https://www.openssl.org/source/license.html
|
* https://www.openssl.org/source/license.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* We need to use the deprecated DSA_print */
|
|
||||||
#define OPENSSL_SUPPRESS_DEPRECATED
|
|
||||||
|
|
||||||
#include <openssl/opensslconf.h>
|
#include <openssl/opensslconf.h>
|
||||||
#ifdef OPENSSL_NO_DSA
|
|
||||||
NON_EMPTY_TRANSLATION_UNIT
|
|
||||||
#else
|
|
||||||
|
|
||||||
# include <stdio.h>
|
#include <stdio.h>
|
||||||
# include <stdlib.h>
|
#include <stdlib.h>
|
||||||
# include <string.h>
|
#include <string.h>
|
||||||
# include <time.h>
|
#include <time.h>
|
||||||
# include "apps.h"
|
#include "apps.h"
|
||||||
# include "progs.h"
|
#include "progs.h"
|
||||||
# include <openssl/bio.h>
|
#include <openssl/bio.h>
|
||||||
# include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
# include <openssl/dsa.h>
|
#include <openssl/dsa.h>
|
||||||
# include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
# include <openssl/x509.h>
|
#include <openssl/x509.h>
|
||||||
# include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
# include <openssl/bn.h>
|
#include <openssl/bn.h>
|
||||||
|
|
||||||
typedef enum OPTION_choice {
|
typedef enum OPTION_choice {
|
||||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||||
@@ -43,14 +37,14 @@ const OPTIONS dsa_options[] = {
|
|||||||
OPT_SECTION("General"),
|
OPT_SECTION("General"),
|
||||||
{"help", OPT_HELP, '-', "Display this summary"},
|
{"help", OPT_HELP, '-', "Display this summary"},
|
||||||
{"", OPT_CIPHER, '-', "Any supported cipher"},
|
{"", OPT_CIPHER, '-', "Any supported cipher"},
|
||||||
# ifndef OPENSSL_NO_RC4
|
#ifndef OPENSSL_NO_RC4
|
||||||
{"pvk-strong", OPT_PVK_STRONG, '-', "Enable 'Strong' PVK encoding level (default)"},
|
{"pvk-strong", OPT_PVK_STRONG, '-', "Enable 'Strong' PVK encoding level (default)"},
|
||||||
{"pvk-weak", OPT_PVK_WEAK, '-', "Enable 'Weak' PVK encoding level"},
|
{"pvk-weak", OPT_PVK_WEAK, '-', "Enable 'Weak' PVK encoding level"},
|
||||||
{"pvk-none", OPT_PVK_NONE, '-', "Don't enforce PVK encoding"},
|
{"pvk-none", OPT_PVK_NONE, '-', "Don't enforce PVK encoding"},
|
||||||
# endif
|
#endif
|
||||||
# ifndef OPENSSL_NO_ENGINE
|
#ifndef OPENSSL_NO_ENGINE
|
||||||
{"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
|
{"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
OPT_SECTION("Input"),
|
OPT_SECTION("Input"),
|
||||||
{"in", OPT_IN, 's', "Input key"},
|
{"in", OPT_IN, 's', "Input key"},
|
||||||
@@ -76,15 +70,16 @@ int dsa_main(int argc, char **argv)
|
|||||||
BIO *out = NULL;
|
BIO *out = NULL;
|
||||||
DSA *dsa = NULL;
|
DSA *dsa = NULL;
|
||||||
ENGINE *e = NULL;
|
ENGINE *e = NULL;
|
||||||
|
EVP_PKEY *pkey = NULL;
|
||||||
const EVP_CIPHER *enc = NULL;
|
const EVP_CIPHER *enc = NULL;
|
||||||
char *infile = NULL, *outfile = NULL, *prog;
|
char *infile = NULL, *outfile = NULL, *prog;
|
||||||
char *passin = NULL, *passout = NULL, *passinarg = NULL, *passoutarg = NULL;
|
char *passin = NULL, *passout = NULL, *passinarg = NULL, *passoutarg = NULL;
|
||||||
OPTION_CHOICE o;
|
OPTION_CHOICE o;
|
||||||
int informat = FORMAT_PEM, outformat = FORMAT_PEM, text = 0, noout = 0;
|
int informat = FORMAT_PEM, outformat = FORMAT_PEM, text = 0, noout = 0;
|
||||||
int i, modulus = 0, pubin = 0, pubout = 0, ret = 1;
|
int i, modulus = 0, pubin = 0, pubout = 0, ret = 1;
|
||||||
# ifndef OPENSSL_NO_RC4
|
#ifndef OPENSSL_NO_RC4
|
||||||
int pvk_encr = 2;
|
int pvk_encr = 2;
|
||||||
# endif
|
#endif
|
||||||
int private = 0;
|
int private = 0;
|
||||||
|
|
||||||
prog = opt_init(argc, argv, dsa_options);
|
prog = opt_init(argc, argv, dsa_options);
|
||||||
@@ -169,19 +164,13 @@ int dsa_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
BIO_printf(bio_err, "read DSA key\n");
|
BIO_printf(bio_err, "read DSA key\n");
|
||||||
{
|
|
||||||
EVP_PKEY *pkey;
|
|
||||||
|
|
||||||
if (pubin)
|
if (pubin)
|
||||||
pkey = load_pubkey(infile, informat, 1, passin, e, "Public Key");
|
pkey = load_pubkey(infile, informat, 1, passin, e, "Public Key");
|
||||||
else
|
else
|
||||||
pkey = load_key(infile, informat, 1, passin, e, "Private Key");
|
pkey = load_key(infile, informat, 1, passin, e, "Private Key");
|
||||||
|
|
||||||
if (pkey != NULL) {
|
if (pkey != NULL)
|
||||||
dsa = EVP_PKEY_get1_DSA(pkey);
|
dsa = EVP_PKEY_get1_DSA(pkey);
|
||||||
EVP_PKEY_free(pkey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dsa == NULL) {
|
if (dsa == NULL) {
|
||||||
BIO_printf(bio_err, "unable to load Key\n");
|
BIO_printf(bio_err, "unable to load Key\n");
|
||||||
@@ -195,7 +184,8 @@ int dsa_main(int argc, char **argv)
|
|||||||
|
|
||||||
if (text) {
|
if (text) {
|
||||||
assert(pubin || private);
|
assert(pubin || private);
|
||||||
if (!DSA_print(out, dsa, 0)) {
|
if ((pubin && EVP_PKEY_print_public(out, pkey, 0, NULL) <= 0)
|
||||||
|
|| (!pubin && EVP_PKEY_print_private(out, pkey, 0, NULL) <= 0)) {
|
||||||
perror(outfile);
|
perror(outfile);
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
goto end;
|
goto end;
|
||||||
@@ -230,7 +220,7 @@ int dsa_main(int argc, char **argv)
|
|||||||
i = PEM_write_bio_DSAPrivateKey(out, dsa, enc,
|
i = PEM_write_bio_DSAPrivateKey(out, dsa, enc,
|
||||||
NULL, 0, NULL, passout);
|
NULL, 0, NULL, passout);
|
||||||
}
|
}
|
||||||
# ifndef OPENSSL_NO_RSA
|
#ifndef OPENSSL_NO_RSA
|
||||||
} else if (outformat == FORMAT_MSBLOB || outformat == FORMAT_PVK) {
|
} else if (outformat == FORMAT_MSBLOB || outformat == FORMAT_PVK) {
|
||||||
EVP_PKEY *pk;
|
EVP_PKEY *pk;
|
||||||
pk = EVP_PKEY_new();
|
pk = EVP_PKEY_new();
|
||||||
@@ -259,7 +249,7 @@ int dsa_main(int argc, char **argv)
|
|||||||
i = i2b_PrivateKey_bio(out, pk);
|
i = i2b_PrivateKey_bio(out, pk);
|
||||||
}
|
}
|
||||||
EVP_PKEY_free(pk);
|
EVP_PKEY_free(pk);
|
||||||
# endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
BIO_printf(bio_err, "bad output format specified for outfile\n");
|
BIO_printf(bio_err, "bad output format specified for outfile\n");
|
||||||
goto end;
|
goto end;
|
||||||
@@ -272,10 +262,10 @@ int dsa_main(int argc, char **argv)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
end:
|
end:
|
||||||
BIO_free_all(out);
|
BIO_free_all(out);
|
||||||
|
EVP_PKEY_free(pkey);
|
||||||
DSA_free(dsa);
|
DSA_free(dsa);
|
||||||
release_engine(e);
|
release_engine(e);
|
||||||
OPENSSL_free(passin);
|
OPENSSL_free(passin);
|
||||||
OPENSSL_free(passout);
|
OPENSSL_free(passout);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
+93
-47
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -7,30 +7,24 @@
|
|||||||
* https://www.openssl.org/source/license.html
|
* https://www.openssl.org/source/license.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* We need to use some deprecated APIs */
|
|
||||||
#define OPENSSL_SUPPRESS_DEPRECATED
|
|
||||||
|
|
||||||
#include <openssl/opensslconf.h>
|
#include <openssl/opensslconf.h>
|
||||||
#ifdef OPENSSL_NO_DSA
|
|
||||||
NON_EMPTY_TRANSLATION_UNIT
|
|
||||||
#else
|
|
||||||
|
|
||||||
# include <stdio.h>
|
#include <stdio.h>
|
||||||
# include <stdlib.h>
|
#include <stdlib.h>
|
||||||
# include <time.h>
|
#include <time.h>
|
||||||
# include <string.h>
|
#include <string.h>
|
||||||
# include "apps.h"
|
#include "apps.h"
|
||||||
# include "progs.h"
|
#include "progs.h"
|
||||||
# include <openssl/bio.h>
|
#include <openssl/bio.h>
|
||||||
# include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
# include <openssl/bn.h>
|
#include <openssl/bn.h>
|
||||||
# include <openssl/dsa.h>
|
#include <openssl/dsa.h>
|
||||||
# include <openssl/x509.h>
|
#include <openssl/x509.h>
|
||||||
# include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
|
|
||||||
static int verbose = 0;
|
static int verbose = 0;
|
||||||
|
|
||||||
static int dsa_cb(int p, int n, BN_GENCB *cb);
|
static int gendsa_cb(EVP_PKEY_CTX *ctx);
|
||||||
|
|
||||||
typedef enum OPTION_choice {
|
typedef enum OPTION_choice {
|
||||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||||
@@ -44,9 +38,9 @@ const OPTIONS dsaparam_options[] = {
|
|||||||
|
|
||||||
OPT_SECTION("General"),
|
OPT_SECTION("General"),
|
||||||
{"help", OPT_HELP, '-', "Display this summary"},
|
{"help", OPT_HELP, '-', "Display this summary"},
|
||||||
# ifndef OPENSSL_NO_ENGINE
|
#ifndef OPENSSL_NO_ENGINE
|
||||||
{"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
|
{"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
OPT_SECTION("Input"),
|
OPT_SECTION("Input"),
|
||||||
{"in", OPT_IN, '<', "Input file"},
|
{"in", OPT_IN, '<', "Input file"},
|
||||||
@@ -74,7 +68,8 @@ int dsaparam_main(int argc, char **argv)
|
|||||||
ENGINE *e = NULL;
|
ENGINE *e = NULL;
|
||||||
DSA *dsa = NULL;
|
DSA *dsa = NULL;
|
||||||
BIO *in = NULL, *out = NULL;
|
BIO *in = NULL, *out = NULL;
|
||||||
BN_GENCB *cb = NULL;
|
EVP_PKEY *pkey = NULL;
|
||||||
|
EVP_PKEY_CTX *ctx = NULL;
|
||||||
int numbits = -1, num = 0, genkey = 0;
|
int numbits = -1, num = 0, genkey = 0;
|
||||||
int informat = FORMAT_PEM, outformat = FORMAT_PEM, noout = 0, C = 0;
|
int informat = FORMAT_PEM, outformat = FORMAT_PEM, noout = 0, C = 0;
|
||||||
int ret = 1, i, text = 0, private = 0;
|
int ret = 1, i, text = 0, private = 0;
|
||||||
@@ -153,6 +148,13 @@ int dsaparam_main(int argc, char **argv)
|
|||||||
if (out == NULL)
|
if (out == NULL)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
|
ctx = EVP_PKEY_CTX_new_from_name(NULL, "DSA", NULL);
|
||||||
|
if (ctx == NULL) {
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
BIO_printf(bio_err,
|
||||||
|
"Error, DSA parameter generation context allocation failed\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
if (numbits > 0) {
|
if (numbits > 0) {
|
||||||
if (numbits > OPENSSL_DSA_MAX_MODULUS_BITS)
|
if (numbits > OPENSSL_DSA_MAX_MODULUS_BITS)
|
||||||
BIO_printf(bio_err,
|
BIO_printf(bio_err,
|
||||||
@@ -160,27 +162,36 @@ int dsaparam_main(int argc, char **argv)
|
|||||||
" Your key size is %d! Larger key size may behave not as expected.\n",
|
" Your key size is %d! Larger key size may behave not as expected.\n",
|
||||||
OPENSSL_DSA_MAX_MODULUS_BITS, numbits);
|
OPENSSL_DSA_MAX_MODULUS_BITS, numbits);
|
||||||
|
|
||||||
cb = BN_GENCB_new();
|
EVP_PKEY_CTX_set_cb(ctx, gendsa_cb);
|
||||||
if (cb == NULL) {
|
EVP_PKEY_CTX_set_app_data(ctx, bio_err);
|
||||||
BIO_printf(bio_err, "Error allocating BN_GENCB object\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
BN_GENCB_set(cb, dsa_cb, bio_err);
|
|
||||||
dsa = DSA_new();
|
|
||||||
if (dsa == NULL) {
|
|
||||||
BIO_printf(bio_err, "Error allocating DSA object\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
BIO_printf(bio_err, "Generating DSA parameters, %d bit long prime\n",
|
BIO_printf(bio_err, "Generating DSA parameters, %d bit long prime\n",
|
||||||
num);
|
num);
|
||||||
BIO_printf(bio_err, "This could take some time\n");
|
BIO_printf(bio_err, "This could take some time\n");
|
||||||
}
|
}
|
||||||
if (!DSA_generate_parameters_ex(dsa, num, NULL, 0, NULL, NULL, cb)) {
|
if (EVP_PKEY_paramgen_init(ctx) <= 0) {
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
BIO_printf(bio_err,
|
||||||
|
"Error, DSA key generation paramgen init failed\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
if (!EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, num)) {
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
BIO_printf(bio_err,
|
||||||
|
"Error, DSA key generation setting bit length failed\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
if (EVP_PKEY_paramgen(ctx, &pkey) <= 0) {
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
BIO_printf(bio_err, "Error, DSA key generation failed\n");
|
BIO_printf(bio_err, "Error, DSA key generation failed\n");
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
dsa = EVP_PKEY_get1_DSA(pkey);
|
||||||
|
if (dsa == NULL) {
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
BIO_printf(bio_err, "Error, DSA key extraction failed\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
} else if (informat == FORMAT_ASN1) {
|
} else if (informat == FORMAT_ASN1) {
|
||||||
dsa = d2i_DSAparams_bio(in, NULL);
|
dsa = d2i_DSAparams_bio(in, NULL);
|
||||||
} else {
|
} else {
|
||||||
@@ -192,8 +203,21 @@ int dsaparam_main(int argc, char **argv)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pkey == NULL) {
|
||||||
|
pkey = EVP_PKEY_new();
|
||||||
|
if (pkey == NULL) {
|
||||||
|
BIO_printf(bio_err, "Error, unable to allocate PKEY object\n");
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
if (!EVP_PKEY_set1_DSA(pkey, dsa)) {
|
||||||
|
BIO_printf(bio_err, "Error, unable to set DSA parameters\n");
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (text) {
|
if (text) {
|
||||||
DSAparams_print(out, dsa);
|
EVP_PKEY_print_params(out, pkey, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (C) {
|
if (C) {
|
||||||
@@ -249,11 +273,28 @@ int dsaparam_main(int argc, char **argv)
|
|||||||
if (genkey) {
|
if (genkey) {
|
||||||
DSA *dsakey;
|
DSA *dsakey;
|
||||||
|
|
||||||
if ((dsakey = DSAparams_dup(dsa)) == NULL)
|
EVP_PKEY_CTX_free(ctx);
|
||||||
goto end;
|
ctx = EVP_PKEY_CTX_new_from_name(NULL, "DSA", NULL);
|
||||||
if (!DSA_generate_key(dsakey)) {
|
if (ctx == NULL) {
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
BIO_printf(bio_err,
|
||||||
|
"Error, DSA key generation context allocation failed\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
if (!EVP_PKEY_keygen_init(ctx)) {
|
||||||
|
BIO_printf(bio_err, "unable to initialise for key generation\n");
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
if (!EVP_PKEY_keygen(ctx, &pkey)) {
|
||||||
|
BIO_printf(bio_err, "unable to generate key\n");
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
dsakey = EVP_PKEY_get0_DSA(pkey);
|
||||||
|
if (dsakey == NULL) {
|
||||||
|
BIO_printf(bio_err, "unable to extract generated key\n");
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
DSA_free(dsakey);
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
assert(private);
|
assert(private);
|
||||||
@@ -262,28 +303,33 @@ int dsaparam_main(int argc, char **argv)
|
|||||||
else
|
else
|
||||||
i = PEM_write_bio_DSAPrivateKey(out, dsakey, NULL, NULL, 0, NULL,
|
i = PEM_write_bio_DSAPrivateKey(out, dsakey, NULL, NULL, 0, NULL,
|
||||||
NULL);
|
NULL);
|
||||||
DSA_free(dsakey);
|
|
||||||
}
|
}
|
||||||
ret = 0;
|
ret = 0;
|
||||||
end:
|
end:
|
||||||
BN_GENCB_free(cb);
|
|
||||||
BIO_free(in);
|
BIO_free(in);
|
||||||
BIO_free_all(out);
|
BIO_free_all(out);
|
||||||
|
EVP_PKEY_CTX_free(ctx);
|
||||||
|
EVP_PKEY_free(pkey);
|
||||||
DSA_free(dsa);
|
DSA_free(dsa);
|
||||||
release_engine(e);
|
release_engine(e);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dsa_cb(int p, int n, BN_GENCB *cb)
|
static int gendsa_cb(EVP_PKEY_CTX *ctx)
|
||||||
{
|
{
|
||||||
static const char symbols[] = ".+*\n";
|
static const char symbols[] = ".+*\n";
|
||||||
char c = (p >= 0 && (size_t)p < sizeof(symbols) - 1) ? symbols[p] : '?';
|
int p;
|
||||||
|
char c;
|
||||||
|
BIO *b;
|
||||||
|
|
||||||
if (!verbose)
|
if (!verbose)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
BIO_write(BN_GENCB_get_arg(cb), &c, 1);
|
b = EVP_PKEY_CTX_get_app_data(ctx);
|
||||||
(void)BIO_flush(BN_GENCB_get_arg(cb));
|
p = EVP_PKEY_CTX_get_keygen_info(ctx, 0);
|
||||||
|
c = (p >= 0 && (size_t)p < sizeof(symbols) - 1) ? symbols[p] : '?';
|
||||||
|
|
||||||
|
BIO_write(b, &c, 1);
|
||||||
|
(void)BIO_flush(b);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -8,19 +8,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <openssl/opensslconf.h>
|
#include <openssl/opensslconf.h>
|
||||||
#ifdef OPENSSL_NO_EC
|
|
||||||
NON_EMPTY_TRANSLATION_UNIT
|
|
||||||
#else
|
|
||||||
|
|
||||||
# include <stdio.h>
|
#include <stdio.h>
|
||||||
# include <stdlib.h>
|
#include <stdlib.h>
|
||||||
# include <string.h>
|
#include <string.h>
|
||||||
# include "apps.h"
|
#include "apps.h"
|
||||||
# include "progs.h"
|
#include "progs.h"
|
||||||
# include <openssl/bio.h>
|
#include <openssl/bio.h>
|
||||||
# include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
# include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
# include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
|
|
||||||
static OPT_PAIR conv_forms[] = {
|
static OPT_PAIR conv_forms[] = {
|
||||||
{"compressed", POINT_CONVERSION_COMPRESSED},
|
{"compressed", POINT_CONVERSION_COMPRESSED},
|
||||||
@@ -46,9 +43,9 @@ typedef enum OPTION_choice {
|
|||||||
const OPTIONS ec_options[] = {
|
const OPTIONS ec_options[] = {
|
||||||
OPT_SECTION("General"),
|
OPT_SECTION("General"),
|
||||||
{"help", OPT_HELP, '-', "Display this summary"},
|
{"help", OPT_HELP, '-', "Display this summary"},
|
||||||
# ifndef OPENSSL_NO_ENGINE
|
#ifndef OPENSSL_NO_ENGINE
|
||||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
OPT_SECTION("Input"),
|
OPT_SECTION("Input"),
|
||||||
{"in", OPT_IN, 's', "Input file"},
|
{"in", OPT_IN, 's', "Input file"},
|
||||||
@@ -291,4 +288,3 @@ int ec_main(int argc, char **argv)
|
|||||||
OPENSSL_free(passout);
|
OPENSSL_free(passout);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
+15
-20
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
|
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
@@ -9,22 +9,19 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <openssl/opensslconf.h>
|
#include <openssl/opensslconf.h>
|
||||||
#ifdef OPENSSL_NO_EC
|
|
||||||
NON_EMPTY_TRANSLATION_UNIT
|
|
||||||
#else
|
|
||||||
|
|
||||||
# include <stdio.h>
|
#include <stdio.h>
|
||||||
# include <stdlib.h>
|
#include <stdlib.h>
|
||||||
# include <time.h>
|
#include <time.h>
|
||||||
# include <string.h>
|
#include <string.h>
|
||||||
# include "apps.h"
|
#include "apps.h"
|
||||||
# include "progs.h"
|
#include "progs.h"
|
||||||
# include <openssl/bio.h>
|
#include <openssl/bio.h>
|
||||||
# include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
# include <openssl/bn.h>
|
#include <openssl/bn.h>
|
||||||
# include <openssl/ec.h>
|
#include <openssl/ec.h>
|
||||||
# include <openssl/x509.h>
|
#include <openssl/x509.h>
|
||||||
# include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
|
|
||||||
typedef enum OPTION_choice {
|
typedef enum OPTION_choice {
|
||||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||||
@@ -39,9 +36,9 @@ const OPTIONS ecparam_options[] = {
|
|||||||
{"help", OPT_HELP, '-', "Display this summary"},
|
{"help", OPT_HELP, '-', "Display this summary"},
|
||||||
{"list_curves", OPT_LIST_CURVES, '-',
|
{"list_curves", OPT_LIST_CURVES, '-',
|
||||||
"Prints a list of all curve 'short names'"},
|
"Prints a list of all curve 'short names'"},
|
||||||
# ifndef OPENSSL_NO_ENGINE
|
#ifndef OPENSSL_NO_ENGINE
|
||||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
{"genkey", OPT_GENKEY, '-', "Generate ec key"},
|
{"genkey", OPT_GENKEY, '-', "Generate ec key"},
|
||||||
{"in", OPT_IN, '<', "Input file - default stdin"},
|
{"in", OPT_IN, '<', "Input file - default stdin"},
|
||||||
@@ -473,5 +470,3 @@ int ecparam_main(int argc, char **argv)
|
|||||||
BIO_free_all(out);
|
BIO_free_all(out);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
+13
-14
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -8,19 +8,19 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <openssl/opensslconf.h>
|
#include <openssl/opensslconf.h>
|
||||||
#ifdef OPENSSL_NO_ENGINE
|
|
||||||
NON_EMPTY_TRANSLATION_UNIT
|
|
||||||
#else
|
|
||||||
|
|
||||||
# include "apps.h"
|
#include "apps.h"
|
||||||
# include "progs.h"
|
#include "progs.h"
|
||||||
# include <stdio.h>
|
#include <stdio.h>
|
||||||
# include <stdlib.h>
|
#include <stdlib.h>
|
||||||
# include <string.h>
|
#include <string.h>
|
||||||
# include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
# include <openssl/engine.h>
|
#include <openssl/engine.h>
|
||||||
# include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
# include <openssl/store.h>
|
#include <openssl/store.h>
|
||||||
|
|
||||||
|
DEFINE_STACK_OF_STRING()
|
||||||
|
DEFINE_STACK_OF_CSTRING()
|
||||||
|
|
||||||
typedef enum OPTION_choice {
|
typedef enum OPTION_choice {
|
||||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||||
@@ -491,4 +491,3 @@ int engine_main(int argc, char **argv)
|
|||||||
BIO_free_all(out);
|
BIO_free_all(out);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
+14
-3
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -18,6 +18,8 @@
|
|||||||
#include "apps.h"
|
#include "apps.h"
|
||||||
#include "progs.h"
|
#include "progs.h"
|
||||||
|
|
||||||
|
DEFINE_STACK_OF_STRING()
|
||||||
|
|
||||||
#define BUFSIZE 4096
|
#define BUFSIZE 4096
|
||||||
#define DEFAULT_MAC_NAME "HMAC"
|
#define DEFAULT_MAC_NAME "HMAC"
|
||||||
#define DEFAULT_FIPS_SECTION "fips_check_section"
|
#define DEFAULT_FIPS_SECTION "fips_check_section"
|
||||||
@@ -31,12 +33,13 @@ static OSSL_CALLBACK self_test_events;
|
|||||||
static char *self_test_corrupt_desc = NULL;
|
static char *self_test_corrupt_desc = NULL;
|
||||||
static char *self_test_corrupt_type = NULL;
|
static char *self_test_corrupt_type = NULL;
|
||||||
static int self_test_log = 1;
|
static int self_test_log = 1;
|
||||||
|
static int quiet = 0;
|
||||||
|
|
||||||
typedef enum OPTION_choice {
|
typedef enum OPTION_choice {
|
||||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||||
OPT_IN, OPT_OUT, OPT_MODULE,
|
OPT_IN, OPT_OUT, OPT_MODULE,
|
||||||
OPT_PROV_NAME, OPT_SECTION_NAME, OPT_MAC_NAME, OPT_MACOPT, OPT_VERIFY,
|
OPT_PROV_NAME, OPT_SECTION_NAME, OPT_MAC_NAME, OPT_MACOPT, OPT_VERIFY,
|
||||||
OPT_NO_LOG, OPT_CORRUPT_DESC, OPT_CORRUPT_TYPE
|
OPT_NO_LOG, OPT_CORRUPT_DESC, OPT_CORRUPT_TYPE, OPT_QUIET
|
||||||
} OPTION_CHOICE;
|
} OPTION_CHOICE;
|
||||||
|
|
||||||
const OPTIONS fipsinstall_options[] = {
|
const OPTIONS fipsinstall_options[] = {
|
||||||
@@ -60,6 +63,7 @@ const OPTIONS fipsinstall_options[] = {
|
|||||||
{"noout", OPT_NO_LOG, '-', "Disable logging of self test events"},
|
{"noout", OPT_NO_LOG, '-', "Disable logging of self test events"},
|
||||||
{"corrupt_desc", OPT_CORRUPT_DESC, 's', "Corrupt a self test by description"},
|
{"corrupt_desc", OPT_CORRUPT_DESC, 's', "Corrupt a self test by description"},
|
||||||
{"corrupt_type", OPT_CORRUPT_TYPE, 's', "Corrupt a self test by type"},
|
{"corrupt_type", OPT_CORRUPT_TYPE, 's', "Corrupt a self test by type"},
|
||||||
|
{"quiet", OPT_QUIET, '-', "No messages, just exit status"},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -287,7 +291,7 @@ int fipsinstall_main(int argc, char **argv)
|
|||||||
case OPT_ERR:
|
case OPT_ERR:
|
||||||
opthelp:
|
opthelp:
|
||||||
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
||||||
goto end;
|
goto cleanup;
|
||||||
case OPT_HELP:
|
case OPT_HELP:
|
||||||
opt_help(fipsinstall_options);
|
opt_help(fipsinstall_options);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@@ -298,6 +302,9 @@ opthelp:
|
|||||||
case OPT_OUT:
|
case OPT_OUT:
|
||||||
out_fname = opt_arg();
|
out_fname = opt_arg();
|
||||||
break;
|
break;
|
||||||
|
case OPT_QUIET:
|
||||||
|
quiet = 1;
|
||||||
|
/* FALLTHROUGH */
|
||||||
case OPT_NO_LOG:
|
case OPT_NO_LOG:
|
||||||
self_test_log = 0;
|
self_test_log = 0;
|
||||||
break;
|
break;
|
||||||
@@ -405,6 +412,7 @@ opthelp:
|
|||||||
if (!verify_config(in_fname, section_name, module_mac, module_mac_len,
|
if (!verify_config(in_fname, section_name, module_mac, module_mac_len,
|
||||||
install_mac, install_mac_len))
|
install_mac, install_mac_len))
|
||||||
goto end;
|
goto end;
|
||||||
|
if (!quiet)
|
||||||
BIO_printf(bio_out, "VERIFY PASSED\n");
|
BIO_printf(bio_out, "VERIFY PASSED\n");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@@ -424,16 +432,19 @@ opthelp:
|
|||||||
module_mac_len, install_mac,
|
module_mac_len, install_mac,
|
||||||
install_mac_len))
|
install_mac_len))
|
||||||
goto end;
|
goto end;
|
||||||
|
if (!quiet)
|
||||||
BIO_printf(bio_out, "INSTALL PASSED\n");
|
BIO_printf(bio_out, "INSTALL PASSED\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
end:
|
end:
|
||||||
if (ret == 1) {
|
if (ret == 1) {
|
||||||
|
if (!quiet)
|
||||||
BIO_printf(bio_err, "%s FAILED\n", verify ? "VERIFY" : "INSTALL");
|
BIO_printf(bio_err, "%s FAILED\n", verify ? "VERIFY" : "INSTALL");
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanup:
|
||||||
BIO_free(fout);
|
BIO_free(fout);
|
||||||
BIO_free(mem_bio);
|
BIO_free(mem_bio);
|
||||||
BIO_free(module_bio);
|
BIO_free(module_bio);
|
||||||
|
|||||||
+45
-24
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -7,26 +7,20 @@
|
|||||||
* https://www.openssl.org/source/license.html
|
* https://www.openssl.org/source/license.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* We need to use some deprecated APIs */
|
|
||||||
#define OPENSSL_SUPPRESS_DEPRECATED
|
|
||||||
|
|
||||||
#include <openssl/opensslconf.h>
|
#include <openssl/opensslconf.h>
|
||||||
#ifdef OPENSSL_NO_DSA
|
|
||||||
NON_EMPTY_TRANSLATION_UNIT
|
|
||||||
#else
|
|
||||||
|
|
||||||
# include <stdio.h>
|
#include <stdio.h>
|
||||||
# include <string.h>
|
#include <string.h>
|
||||||
# include <sys/types.h>
|
#include <sys/types.h>
|
||||||
# include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
# include "apps.h"
|
#include "apps.h"
|
||||||
# include "progs.h"
|
#include "progs.h"
|
||||||
# include <openssl/bio.h>
|
#include <openssl/bio.h>
|
||||||
# include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
# include <openssl/bn.h>
|
#include <openssl/bn.h>
|
||||||
# include <openssl/dsa.h>
|
#include <openssl/dsa.h>
|
||||||
# include <openssl/x509.h>
|
#include <openssl/x509.h>
|
||||||
# include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
|
|
||||||
typedef enum OPTION_choice {
|
typedef enum OPTION_choice {
|
||||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||||
@@ -39,9 +33,9 @@ const OPTIONS gendsa_options[] = {
|
|||||||
|
|
||||||
OPT_SECTION("General"),
|
OPT_SECTION("General"),
|
||||||
{"help", OPT_HELP, '-', "Display this summary"},
|
{"help", OPT_HELP, '-', "Display this summary"},
|
||||||
# ifndef OPENSSL_NO_ENGINE
|
#ifndef OPENSSL_NO_ENGINE
|
||||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
OPT_SECTION("Output"),
|
OPT_SECTION("Output"),
|
||||||
{"out", OPT_OUT, '>', "Output the key to the specified file"},
|
{"out", OPT_OUT, '>', "Output the key to the specified file"},
|
||||||
@@ -61,6 +55,8 @@ int gendsa_main(int argc, char **argv)
|
|||||||
ENGINE *e = NULL;
|
ENGINE *e = NULL;
|
||||||
BIO *out = NULL, *in = NULL;
|
BIO *out = NULL, *in = NULL;
|
||||||
DSA *dsa = NULL;
|
DSA *dsa = NULL;
|
||||||
|
EVP_PKEY *pkey = NULL;
|
||||||
|
EVP_PKEY_CTX *ctx = NULL;
|
||||||
const EVP_CIPHER *enc = NULL;
|
const EVP_CIPHER *enc = NULL;
|
||||||
char *dsaparams = NULL;
|
char *dsaparams = NULL;
|
||||||
char *outfile = NULL, *passoutarg = NULL, *passout = NULL, *prog;
|
char *outfile = NULL, *passoutarg = NULL, *passout = NULL, *prog;
|
||||||
@@ -142,14 +138,38 @@ int gendsa_main(int argc, char **argv)
|
|||||||
" Your key size is %d! Larger key size may behave not as expected.\n",
|
" Your key size is %d! Larger key size may behave not as expected.\n",
|
||||||
OPENSSL_DSA_MAX_MODULUS_BITS, BN_num_bits(p));
|
OPENSSL_DSA_MAX_MODULUS_BITS, BN_num_bits(p));
|
||||||
|
|
||||||
|
pkey = EVP_PKEY_new();
|
||||||
|
if (pkey == NULL) {
|
||||||
|
BIO_printf(bio_err, "unable to allocate PKEY\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
if (!EVP_PKEY_set1_DSA(pkey, dsa)) {
|
||||||
|
BIO_printf(bio_err, "unable to associate DSA parameters with PKEY\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
ctx = EVP_PKEY_CTX_new(pkey, NULL);
|
||||||
|
if (ctx == NULL) {
|
||||||
|
BIO_printf(bio_err, "unable to create PKEY context\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
EVP_PKEY_free(pkey);
|
||||||
|
pkey = NULL;
|
||||||
|
if (EVP_PKEY_keygen_init(ctx) <= 0) {
|
||||||
|
BIO_printf(bio_err, "unable to set up for key generation\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
if (verbose)
|
if (verbose)
|
||||||
BIO_printf(bio_err, "Generating DSA key, %d bits\n", BN_num_bits(p));
|
BIO_printf(bio_err, "Generating DSA key, %d bits\n", BN_num_bits(p));
|
||||||
if (!DSA_generate_key(dsa))
|
if (EVP_PKEY_keygen(ctx, &pkey) <= 0) {
|
||||||
|
BIO_printf(bio_err, "unable to generate key\n");
|
||||||
goto end;
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
assert(private);
|
assert(private);
|
||||||
if (!PEM_write_bio_DSAPrivateKey(out, dsa, enc, NULL, 0, NULL, passout))
|
if (!PEM_write_bio_PrivateKey(out, pkey, enc, NULL, 0, NULL, passout)) {
|
||||||
|
BIO_printf(bio_err, "unable to output generated key\n");
|
||||||
goto end;
|
goto end;
|
||||||
|
}
|
||||||
ret = 0;
|
ret = 0;
|
||||||
end:
|
end:
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
@@ -158,8 +178,9 @@ int gendsa_main(int argc, char **argv)
|
|||||||
BIO_free(in);
|
BIO_free(in);
|
||||||
BIO_free_all(out);
|
BIO_free_all(out);
|
||||||
DSA_free(dsa);
|
DSA_free(dsa);
|
||||||
|
EVP_PKEY_free(pkey);
|
||||||
|
EVP_PKEY_CTX_free(ctx);
|
||||||
release_engine(e);
|
release_engine(e);
|
||||||
OPENSSL_free(passout);
|
OPENSSL_free(passout);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
+67
-46
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -8,31 +8,28 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <openssl/opensslconf.h>
|
#include <openssl/opensslconf.h>
|
||||||
#ifdef OPENSSL_NO_RSA
|
|
||||||
NON_EMPTY_TRANSLATION_UNIT
|
|
||||||
#else
|
|
||||||
|
|
||||||
# include <stdio.h>
|
#include <stdio.h>
|
||||||
# include <string.h>
|
#include <string.h>
|
||||||
# include <sys/types.h>
|
#include <sys/types.h>
|
||||||
# include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
# include "apps.h"
|
#include "apps.h"
|
||||||
# include "progs.h"
|
#include "progs.h"
|
||||||
# include <openssl/bio.h>
|
#include <openssl/bio.h>
|
||||||
# include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
# include <openssl/bn.h>
|
#include <openssl/bn.h>
|
||||||
# include <openssl/rsa.h>
|
#include <openssl/rsa.h>
|
||||||
# include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
# include <openssl/x509.h>
|
#include <openssl/x509.h>
|
||||||
# include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
# include <openssl/rand.h>
|
#include <openssl/rand.h>
|
||||||
|
|
||||||
# define DEFBITS 2048
|
#define DEFBITS 2048
|
||||||
# define DEFPRIMES 2
|
#define DEFPRIMES 2
|
||||||
|
|
||||||
static int verbose = 0;
|
static int verbose = 0;
|
||||||
|
|
||||||
static int genrsa_cb(int p, int n, BN_GENCB *cb);
|
static int genrsa_cb(EVP_PKEY_CTX *ctx);
|
||||||
|
|
||||||
typedef enum OPTION_choice {
|
typedef enum OPTION_choice {
|
||||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||||
@@ -46,9 +43,9 @@ const OPTIONS genrsa_options[] = {
|
|||||||
|
|
||||||
OPT_SECTION("General"),
|
OPT_SECTION("General"),
|
||||||
{"help", OPT_HELP, '-', "Display this summary"},
|
{"help", OPT_HELP, '-', "Display this summary"},
|
||||||
# ifndef OPENSSL_NO_ENGINE
|
#ifndef OPENSSL_NO_ENGINE
|
||||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
OPT_SECTION("Input"),
|
OPT_SECTION("Input"),
|
||||||
{"3", OPT_3, '-', "Use 3 for the E value"},
|
{"3", OPT_3, '-', "Use 3 for the E value"},
|
||||||
@@ -73,24 +70,24 @@ const OPTIONS genrsa_options[] = {
|
|||||||
int genrsa_main(int argc, char **argv)
|
int genrsa_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
BN_GENCB *cb = BN_GENCB_new();
|
BN_GENCB *cb = BN_GENCB_new();
|
||||||
PW_CB_DATA cb_data;
|
|
||||||
ENGINE *eng = NULL;
|
ENGINE *eng = NULL;
|
||||||
BIGNUM *bn = BN_new();
|
BIGNUM *bn = BN_new();
|
||||||
|
RSA *rsa;
|
||||||
BIO *out = NULL;
|
BIO *out = NULL;
|
||||||
const BIGNUM *e;
|
const BIGNUM *e;
|
||||||
RSA *rsa = NULL;
|
EVP_PKEY *pkey = NULL;
|
||||||
|
EVP_PKEY_CTX *ctx = NULL;
|
||||||
const EVP_CIPHER *enc = NULL;
|
const EVP_CIPHER *enc = NULL;
|
||||||
int ret = 1, num = DEFBITS, private = 0, primes = DEFPRIMES;
|
int ret = 1, num = DEFBITS, private = 0, primes = DEFPRIMES;
|
||||||
unsigned long f4 = RSA_F4;
|
unsigned long f4 = RSA_F4;
|
||||||
char *outfile = NULL, *passoutarg = NULL, *passout = NULL;
|
char *outfile = NULL, *passoutarg = NULL, *passout = NULL;
|
||||||
char *prog, *hexe, *dece;
|
char *prog, *hexe, *dece;
|
||||||
OPTION_CHOICE o;
|
OPTION_CHOICE o;
|
||||||
|
unsigned char *ebuf = NULL;
|
||||||
|
|
||||||
if (bn == NULL || cb == NULL)
|
if (bn == NULL || cb == NULL)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
BN_GENCB_set(cb, genrsa_cb, bio_err);
|
|
||||||
|
|
||||||
prog = opt_init(argc, argv, genrsa_options);
|
prog = opt_init(argc, argv, genrsa_options);
|
||||||
while ((o = opt_next()) != OPT_EOF) {
|
while ((o = opt_next()) != OPT_EOF) {
|
||||||
switch (o) {
|
switch (o) {
|
||||||
@@ -104,7 +101,7 @@ opthelp:
|
|||||||
opt_help(genrsa_options);
|
opt_help(genrsa_options);
|
||||||
goto end;
|
goto end;
|
||||||
case OPT_3:
|
case OPT_3:
|
||||||
f4 = 3;
|
f4 = RSA_3;
|
||||||
break;
|
break;
|
||||||
case OPT_F4:
|
case OPT_F4:
|
||||||
f4 = RSA_F4;
|
f4 = RSA_F4;
|
||||||
@@ -165,49 +162,74 @@ opthelp:
|
|||||||
if (out == NULL)
|
if (out == NULL)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
|
if (!init_gen_str(&ctx, "RSA", eng, 0))
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
EVP_PKEY_CTX_set_cb(ctx, genrsa_cb);
|
||||||
|
EVP_PKEY_CTX_set_app_data(ctx, bio_err);
|
||||||
|
|
||||||
|
if (EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, num) <= 0) {
|
||||||
|
BIO_printf(bio_err, "Error setting RSA length\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
if (!BN_set_word(bn, f4)) {
|
||||||
|
BIO_printf(bio_err, "Error allocating RSA public exponent\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
if (EVP_PKEY_CTX_set_rsa_keygen_pubexp(ctx, bn) <= 0) {
|
||||||
|
BIO_printf(bio_err, "Error setting RSA public exponent\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
if (EVP_PKEY_CTX_set_rsa_keygen_primes(ctx, primes) <= 0) {
|
||||||
|
BIO_printf(bio_err, "Error setting number of primes\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
if (verbose)
|
if (verbose)
|
||||||
BIO_printf(bio_err, "Generating RSA private key, %d bit long modulus (%d primes)\n",
|
BIO_printf(bio_err, "Generating RSA private key, %d bit long modulus (%d primes)\n",
|
||||||
num, primes);
|
num, primes);
|
||||||
rsa = eng ? RSA_new_method(eng) : RSA_new();
|
if (!EVP_PKEY_keygen(ctx, &pkey)) {
|
||||||
if (rsa == NULL)
|
BIO_printf(bio_err, "Error generating RSA key\n");
|
||||||
goto end;
|
|
||||||
|
|
||||||
if (!BN_set_word(bn, f4)
|
|
||||||
|| !RSA_generate_multi_prime_key(rsa, num, primes, bn, cb))
|
|
||||||
goto end;
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbose) {
|
||||||
|
if ((rsa = EVP_PKEY_get0_RSA(pkey)) != NULL) {
|
||||||
RSA_get0_key(rsa, NULL, &e, NULL);
|
RSA_get0_key(rsa, NULL, &e, NULL);
|
||||||
|
} else {
|
||||||
|
BIO_printf(bio_err, "Error cannot access RSA e\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
hexe = BN_bn2hex(e);
|
hexe = BN_bn2hex(e);
|
||||||
dece = BN_bn2dec(e);
|
dece = BN_bn2dec(e);
|
||||||
if (hexe && dece && verbose) {
|
if (hexe && dece) {
|
||||||
BIO_printf(bio_err, "e is %s (0x%s)\n", dece, hexe);
|
BIO_printf(bio_err, "e is %s (0x%s)\n", dece, hexe);
|
||||||
}
|
}
|
||||||
OPENSSL_free(hexe);
|
OPENSSL_free(hexe);
|
||||||
OPENSSL_free(dece);
|
OPENSSL_free(dece);
|
||||||
cb_data.password = passout;
|
}
|
||||||
cb_data.prompt_info = outfile;
|
if (!PEM_write_bio_PrivateKey(out, pkey, enc, NULL, 0, NULL, passout))
|
||||||
assert(private);
|
|
||||||
if (!PEM_write_bio_RSAPrivateKey(out, rsa, enc, NULL, 0,
|
|
||||||
(pem_password_cb *)password_callback,
|
|
||||||
&cb_data))
|
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
end:
|
end:
|
||||||
BN_free(bn);
|
BN_free(bn);
|
||||||
BN_GENCB_free(cb);
|
BN_GENCB_free(cb);
|
||||||
RSA_free(rsa);
|
EVP_PKEY_CTX_free(ctx);
|
||||||
|
EVP_PKEY_free(pkey);
|
||||||
BIO_free_all(out);
|
BIO_free_all(out);
|
||||||
release_engine(eng);
|
release_engine(eng);
|
||||||
OPENSSL_free(passout);
|
OPENSSL_free(passout);
|
||||||
|
OPENSSL_free(ebuf);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int genrsa_cb(int p, int n, BN_GENCB *cb)
|
static int genrsa_cb(EVP_PKEY_CTX *ctx)
|
||||||
{
|
{
|
||||||
char c = '*';
|
char c = '*';
|
||||||
|
BIO *b = EVP_PKEY_CTX_get_app_data(ctx);
|
||||||
|
int p = EVP_PKEY_CTX_get_keygen_info(ctx, 0);
|
||||||
|
|
||||||
if (!verbose)
|
if (!verbose)
|
||||||
return 1;
|
return 1;
|
||||||
@@ -220,8 +242,7 @@ static int genrsa_cb(int p, int n, BN_GENCB *cb)
|
|||||||
c = '*';
|
c = '*';
|
||||||
if (p == 3)
|
if (p == 3)
|
||||||
c = '\n';
|
c = '\n';
|
||||||
BIO_write(BN_GENCB_get_arg(cb), &c, 1);
|
BIO_write(b, &c, 1);
|
||||||
(void)BIO_flush(BN_GENCB_get_arg(cb));
|
(void)BIO_flush(b);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
+17
-10
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -91,7 +91,7 @@ int wrap_password_callback(char *buf, int bufsiz, int verify, void *cb_data);
|
|||||||
|
|
||||||
int chopup_args(ARGS *arg, char *buf);
|
int chopup_args(ARGS *arg, char *buf);
|
||||||
int dump_cert_text(BIO *out, X509 *x);
|
int dump_cert_text(BIO *out, X509 *x);
|
||||||
void print_name(BIO *out, const char *title, X509_NAME *nm,
|
void print_name(BIO *out, const char *title, const X509_NAME *nm,
|
||||||
unsigned long lflags);
|
unsigned long lflags);
|
||||||
void print_bignum_var(BIO *, const BIGNUM *, const char*,
|
void print_bignum_var(BIO *, const BIGNUM *, const char*,
|
||||||
int, unsigned char *);
|
int, unsigned char *);
|
||||||
@@ -104,16 +104,17 @@ int set_ext_copy(int *copy_type, const char *arg);
|
|||||||
int copy_extensions(X509 *x, X509_REQ *req, int copy_type);
|
int copy_extensions(X509 *x, X509_REQ *req, int copy_type);
|
||||||
int app_passwd(const char *arg1, const char *arg2, char **pass1, char **pass2);
|
int app_passwd(const char *arg1, const char *arg2, char **pass1, char **pass2);
|
||||||
int add_oid_section(CONF *conf);
|
int add_oid_section(CONF *conf);
|
||||||
X509 *load_cert(const char *file, int format, const char *cert_descrip);
|
X509_REQ *load_csr(const char *file, int format, const char *desc);
|
||||||
X509_CRL *load_crl(const char *infile, int format);
|
X509 *load_cert(const char *file, int format, const char *desc);
|
||||||
|
X509_CRL *load_crl(const char *infile, int format, const char *desc);
|
||||||
EVP_PKEY *load_key(const char *file, int format, int maybe_stdin,
|
EVP_PKEY *load_key(const char *file, int format, int maybe_stdin,
|
||||||
const char *pass, ENGINE *e, const char *key_descrip);
|
const char *pass, ENGINE *e, const char *desc);
|
||||||
EVP_PKEY *load_pubkey(const char *file, int format, int maybe_stdin,
|
EVP_PKEY *load_pubkey(const char *file, int format, int maybe_stdin,
|
||||||
const char *pass, ENGINE *e, const char *key_descrip);
|
const char *pass, ENGINE *e, const char *desc);
|
||||||
int load_certs(const char *file, STACK_OF(X509) **certs, int format,
|
int load_certs(const char *file, STACK_OF(X509) **certs, int format,
|
||||||
const char *pass, const char *cert_descrip);
|
const char *pass, const char *desc);
|
||||||
int load_crls(const char *file, STACK_OF(X509_CRL) **crls, int format,
|
int load_crls(const char *file, STACK_OF(X509_CRL) **crls, int format,
|
||||||
const char *pass, const char *cert_descrip);
|
const char *pass, const char *desc);
|
||||||
X509_STORE *setup_verify(const char *CAfile, int noCAfile,
|
X509_STORE *setup_verify(const char *CAfile, int noCAfile,
|
||||||
const char *CApath, int noCApath,
|
const char *CApath, int noCApath,
|
||||||
const char *CAstore, int noCAstore);
|
const char *CAstore, int noCAstore);
|
||||||
@@ -197,12 +198,17 @@ X509_NAME *parse_name(const char *str, long chtype, int multirdn);
|
|||||||
void policies_print(X509_STORE_CTX *ctx);
|
void policies_print(X509_STORE_CTX *ctx);
|
||||||
int bio_to_mem(unsigned char **out, int maxlen, BIO *in);
|
int bio_to_mem(unsigned char **out, int maxlen, BIO *in);
|
||||||
int pkey_ctrl_string(EVP_PKEY_CTX *ctx, const char *value);
|
int pkey_ctrl_string(EVP_PKEY_CTX *ctx, const char *value);
|
||||||
|
int x509_ctrl_string(X509 *x, const char *value);
|
||||||
|
int x509_req_ctrl_string(X509_REQ *x, const char *value);
|
||||||
int init_gen_str(EVP_PKEY_CTX **pctx,
|
int init_gen_str(EVP_PKEY_CTX **pctx,
|
||||||
const char *algname, ENGINE *e, int do_param);
|
const char *algname, ENGINE *e, int do_param);
|
||||||
int do_X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md,
|
int do_X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md,
|
||||||
STACK_OF(OPENSSL_STRING) *sigopts);
|
STACK_OF(OPENSSL_STRING) *sigopts);
|
||||||
|
int do_X509_verify(X509 *x, EVP_PKEY *pkey, STACK_OF(OPENSSL_STRING) *vfyopts);
|
||||||
int do_X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md,
|
int do_X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md,
|
||||||
STACK_OF(OPENSSL_STRING) *sigopts);
|
STACK_OF(OPENSSL_STRING) *sigopts);
|
||||||
|
int do_X509_REQ_verify(X509_REQ *x, EVP_PKEY *pkey,
|
||||||
|
STACK_OF(OPENSSL_STRING) *vfyopts);
|
||||||
int do_X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md,
|
int do_X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md,
|
||||||
STACK_OF(OPENSSL_STRING) *sigopts);
|
STACK_OF(OPENSSL_STRING) *sigopts);
|
||||||
|
|
||||||
@@ -228,13 +234,13 @@ BIO *app_http_tls_cb(BIO *hbio, /* APP_HTTP_TLS_INFO */ void *arg,
|
|||||||
int connect, int detail);
|
int connect, int detail);
|
||||||
# ifndef OPENSSL_NO_SOCK
|
# ifndef OPENSSL_NO_SOCK
|
||||||
ASN1_VALUE *app_http_get_asn1(const char *url, const char *proxy,
|
ASN1_VALUE *app_http_get_asn1(const char *url, const char *proxy,
|
||||||
const char *proxy_port, SSL_CTX *ssl_ctx,
|
const char *no_proxy, SSL_CTX *ssl_ctx,
|
||||||
const STACK_OF(CONF_VALUE) *headers,
|
const STACK_OF(CONF_VALUE) *headers,
|
||||||
long timeout, const char *expected_content_type,
|
long timeout, const char *expected_content_type,
|
||||||
const ASN1_ITEM *it);
|
const ASN1_ITEM *it);
|
||||||
ASN1_VALUE *app_http_post_asn1(const char *host, const char *port,
|
ASN1_VALUE *app_http_post_asn1(const char *host, const char *port,
|
||||||
const char *path, const char *proxy,
|
const char *path, const char *proxy,
|
||||||
const char *proxy_port, SSL_CTX *ctx,
|
const char *no_proxy, SSL_CTX *ctx,
|
||||||
const STACK_OF(CONF_VALUE) *headers,
|
const STACK_OF(CONF_VALUE) *headers,
|
||||||
const char *content_type,
|
const char *content_type,
|
||||||
ASN1_VALUE *req, const ASN1_ITEM *req_it,
|
ASN1_VALUE *req, const ASN1_ITEM *req_it,
|
||||||
@@ -281,5 +287,6 @@ extern VERIFY_CB_ARGS verify_args;
|
|||||||
OSSL_PARAM *app_params_new_from_opts(STACK_OF(OPENSSL_STRING) *opts,
|
OSSL_PARAM *app_params_new_from_opts(STACK_OF(OPENSSL_STRING) *opts,
|
||||||
const OSSL_PARAM *paramdefs);
|
const OSSL_PARAM *paramdefs);
|
||||||
void app_params_free(OSSL_PARAM *params);
|
void app_params_free(OSSL_PARAM *params);
|
||||||
|
void app_providers_cleanup(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -26,6 +26,7 @@ typedef struct function_st {
|
|||||||
int (*func)(int argc, char *argv[]);
|
int (*func)(int argc, char *argv[]);
|
||||||
const OPTIONS *help;
|
const OPTIONS *help;
|
||||||
const char *deprecated_alternative;
|
const char *deprecated_alternative;
|
||||||
|
const char *deprecated_version;
|
||||||
} FUNCTION;
|
} FUNCTION;
|
||||||
|
|
||||||
DEFINE_LHASH_OF(FUNCTION);
|
DEFINE_LHASH_OF(FUNCTION);
|
||||||
|
|||||||
+5
-3
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -275,8 +275,8 @@
|
|||||||
|
|
||||||
# define OPT_PROV_OPTIONS \
|
# define OPT_PROV_OPTIONS \
|
||||||
OPT_SECTION("Provider"), \
|
OPT_SECTION("Provider"), \
|
||||||
{ "provider", OPT_PROV_PROVIDER, 's', "Provder to load (can be specified multiple times)" }, \
|
{ "provider_path", OPT_PROV_PROVIDER_PATH, 's', "Provider load path (must be before 'provider' argument if required)" }, \
|
||||||
{ "provider_path", OPT_PROV_PROVIDER_PATH, 's', "Provider load path" }
|
{ "provider", OPT_PROV_PROVIDER, 's', "Provider to load (can be specified multiple times)" }
|
||||||
|
|
||||||
# define OPT_PROV_CASES \
|
# define OPT_PROV_CASES \
|
||||||
OPT_PROV__FIRST: case OPT_PROV__LAST: break; \
|
OPT_PROV__FIRST: case OPT_PROV__LAST: break; \
|
||||||
@@ -342,6 +342,7 @@ char *opt_init(int ac, char **av, const OPTIONS * o);
|
|||||||
int opt_next(void);
|
int opt_next(void);
|
||||||
void opt_begin(void);
|
void opt_begin(void);
|
||||||
int opt_format(const char *s, unsigned long flags, int *result);
|
int opt_format(const char *s, unsigned long flags, int *result);
|
||||||
|
const char *format2str(int format);
|
||||||
int opt_int(const char *arg, int *result);
|
int opt_int(const char *arg, int *result);
|
||||||
int opt_ulong(const char *arg, unsigned long *result);
|
int opt_ulong(const char *arg, unsigned long *result);
|
||||||
int opt_long(const char *arg, long *result);
|
int opt_long(const char *arg, long *result);
|
||||||
@@ -370,6 +371,7 @@ int opt_provider(int i);
|
|||||||
void opt_help(const OPTIONS * list);
|
void opt_help(const OPTIONS * list);
|
||||||
void opt_print(const OPTIONS * opt, int doingparams, int width);
|
void opt_print(const OPTIONS * opt, int doingparams, int width);
|
||||||
int opt_format_error(const char *s, unsigned long flags);
|
int opt_format_error(const char *s, unsigned long flags);
|
||||||
|
void print_format_error(int format, unsigned long flags);
|
||||||
int opt_isdir(const char *name);
|
int opt_isdir(const char *name);
|
||||||
int opt_printf_stderr(const char *fmt, ...);
|
int opt_printf_stderr(const char *fmt, ...);
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -17,6 +17,8 @@
|
|||||||
#include <openssl/kdf.h>
|
#include <openssl/kdf.h>
|
||||||
#include <openssl/params.h>
|
#include <openssl/params.h>
|
||||||
|
|
||||||
|
DEFINE_STACK_OF_STRING()
|
||||||
|
|
||||||
typedef enum OPTION_choice {
|
typedef enum OPTION_choice {
|
||||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||||
OPT_KDFOPT, OPT_BIN, OPT_KEYLEN, OPT_OUT,
|
OPT_KDFOPT, OPT_BIN, OPT_KEYLEN, OPT_OUT,
|
||||||
|
|||||||
@@ -10,12 +10,17 @@
|
|||||||
#include "apps.h"
|
#include "apps.h"
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
#include <openssl/provider.h>
|
#include <openssl/provider.h>
|
||||||
|
#include <openssl/safestack.h>
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(OSSL_PROVIDER)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* See comments in opt_verify for explanation of this.
|
* See comments in opt_verify for explanation of this.
|
||||||
*/
|
*/
|
||||||
enum prov_range { OPT_PROV_ENUM };
|
enum prov_range { OPT_PROV_ENUM };
|
||||||
|
|
||||||
|
static STACK_OF(OSSL_PROVIDER) *app_providers = NULL;
|
||||||
|
|
||||||
static int opt_provider_load(const char *provider)
|
static int opt_provider_load(const char *provider)
|
||||||
{
|
{
|
||||||
OSSL_PROVIDER *prov;
|
OSSL_PROVIDER *prov;
|
||||||
@@ -26,9 +31,27 @@ static int opt_provider_load(const char *provider)
|
|||||||
opt_getprog(), provider);
|
opt_getprog(), provider);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (app_providers == NULL)
|
||||||
|
app_providers = sk_OSSL_PROVIDER_new_null();
|
||||||
|
if (app_providers == NULL
|
||||||
|
|| !sk_OSSL_PROVIDER_push(app_providers, prov)) {
|
||||||
|
app_providers_cleanup();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void provider_free(OSSL_PROVIDER *prov)
|
||||||
|
{
|
||||||
|
OSSL_PROVIDER_unload(prov);
|
||||||
|
}
|
||||||
|
|
||||||
|
void app_providers_cleanup(void)
|
||||||
|
{
|
||||||
|
sk_OSSL_PROVIDER_pop_free(app_providers, provider_free);
|
||||||
|
app_providers = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static int opt_provider_path(const char *path)
|
static int opt_provider_path(const char *path)
|
||||||
{
|
{
|
||||||
if (path != NULL && *path == '\0')
|
if (path != NULL && *path == '\0')
|
||||||
|
|||||||
@@ -0,0 +1,134 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
* in the file LICENSE in the source distribution or at
|
||||||
|
* https://www.openssl.org/source/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include "apps.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* X509_ctrl_str() is sorely lacking in libcrypto, but is still needed to
|
||||||
|
* allow the application to process verification options in a manner similar
|
||||||
|
* to signature or other options that pass through EVP_PKEY_CTX_ctrl_str(),
|
||||||
|
* for uniformity.
|
||||||
|
*
|
||||||
|
* As soon as more stuff is added, the code will need serious rework. For
|
||||||
|
* the moment, it only handles the FIPS 196 / SM2 distinguishing ID.
|
||||||
|
*/
|
||||||
|
#ifdef EVP_PKEY_CTRL_SET1_ID
|
||||||
|
static ASN1_OCTET_STRING *mk_octet_string(void *value, size_t value_n)
|
||||||
|
{
|
||||||
|
ASN1_OCTET_STRING *v = ASN1_OCTET_STRING_new();
|
||||||
|
|
||||||
|
if (v == NULL) {
|
||||||
|
BIO_printf(bio_err, "error: allocation failed\n");
|
||||||
|
} else if (!ASN1_OCTET_STRING_set(v, value, value_n)) {
|
||||||
|
ASN1_OCTET_STRING_free(v);
|
||||||
|
v = NULL;
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static int x509_ctrl(void *object, int cmd, void *value, size_t value_n)
|
||||||
|
{
|
||||||
|
switch (cmd) {
|
||||||
|
#ifdef EVP_PKEY_CTRL_SET1_ID
|
||||||
|
case EVP_PKEY_CTRL_SET1_ID:
|
||||||
|
{
|
||||||
|
ASN1_OCTET_STRING *v = mk_octet_string(value, value_n);
|
||||||
|
|
||||||
|
if (v == NULL) {
|
||||||
|
BIO_printf(bio_err,
|
||||||
|
"error: setting distinguishing ID in certificate failed\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
X509_set0_distinguishing_id(object, v);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return -2; /* typical EVP_PKEY return for "unsupported" */
|
||||||
|
}
|
||||||
|
|
||||||
|
static int x509_req_ctrl(void *object, int cmd, void *value, size_t value_n)
|
||||||
|
{
|
||||||
|
switch (cmd) {
|
||||||
|
#ifdef EVP_PKEY_CTRL_SET1_ID
|
||||||
|
case EVP_PKEY_CTRL_SET1_ID:
|
||||||
|
{
|
||||||
|
ASN1_OCTET_STRING *v = mk_octet_string(value, value_n);
|
||||||
|
|
||||||
|
if (v == NULL) {
|
||||||
|
BIO_printf(bio_err,
|
||||||
|
"error: setting distinguishing ID in certificate signing request failed\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
X509_REQ_set0_distinguishing_id(object, v);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return -2; /* typical EVP_PKEY return for "unsupported" */
|
||||||
|
}
|
||||||
|
|
||||||
|
static int do_x509_ctrl_string(int (*ctrl)(void *object, int cmd,
|
||||||
|
void *value, size_t value_n),
|
||||||
|
void *object, const char *value)
|
||||||
|
{
|
||||||
|
int rv = 0;
|
||||||
|
char *stmp, *vtmp = NULL;
|
||||||
|
size_t vtmp_len = 0;
|
||||||
|
int cmd = 0; /* Will get command values that make sense somehow */
|
||||||
|
|
||||||
|
stmp = OPENSSL_strdup(value);
|
||||||
|
if (stmp == NULL)
|
||||||
|
return -1;
|
||||||
|
vtmp = strchr(stmp, ':');
|
||||||
|
if (vtmp != NULL) {
|
||||||
|
*vtmp = 0;
|
||||||
|
vtmp++;
|
||||||
|
vtmp_len = strlen(vtmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(stmp, "distid") == 0) {
|
||||||
|
#ifdef EVP_PKEY_CTRL_SET1_ID
|
||||||
|
cmd = EVP_PKEY_CTRL_SET1_ID; /* ... except we put it in X509 */
|
||||||
|
#endif
|
||||||
|
} else if (strcmp(stmp, "hexdistid") == 0) {
|
||||||
|
long hexid_len = 0;
|
||||||
|
void *hexid = OPENSSL_hexstr2buf((const char *)vtmp, &hexid_len);
|
||||||
|
|
||||||
|
OPENSSL_free(stmp);
|
||||||
|
stmp = vtmp = hexid;
|
||||||
|
vtmp_len = (size_t)hexid_len;
|
||||||
|
#ifdef EVP_PKEY_CTRL_SET1_ID
|
||||||
|
cmd = EVP_PKEY_CTRL_SET1_ID; /* ... except we put it in X509 */
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
rv = ctrl(object, cmd, vtmp, vtmp_len);
|
||||||
|
|
||||||
|
OPENSSL_free(stmp);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
int x509_ctrl_string(X509 *x, const char *value)
|
||||||
|
{
|
||||||
|
return do_x509_ctrl_string(x509_ctrl, x, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
int x509_req_ctrl_string(X509_REQ *x, const char *value)
|
||||||
|
{
|
||||||
|
return do_x509_ctrl_string(x509_req_ctrl, x, value);
|
||||||
|
}
|
||||||
+144
-82
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -57,6 +57,17 @@ static int WIN32_rename(const char *from, const char *to);
|
|||||||
|
|
||||||
#define PASS_SOURCE_SIZE_MAX 4
|
#define PASS_SOURCE_SIZE_MAX 4
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(CONF)
|
||||||
|
DEFINE_STACK_OF(CONF_VALUE)
|
||||||
|
DEFINE_STACK_OF(X509)
|
||||||
|
DEFINE_STACK_OF(X509_CRL)
|
||||||
|
DEFINE_STACK_OF(X509_INFO)
|
||||||
|
DEFINE_STACK_OF(X509_EXTENSION)
|
||||||
|
DEFINE_STACK_OF(X509_POLICY_NODE)
|
||||||
|
DEFINE_STACK_OF(GENERAL_NAME)
|
||||||
|
DEFINE_STACK_OF(DIST_POINT)
|
||||||
|
DEFINE_STACK_OF_STRING()
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
unsigned long flag;
|
unsigned long flag;
|
||||||
@@ -410,7 +421,7 @@ static int load_pkcs12(BIO *in, const char *desc,
|
|||||||
int len, ret = 0;
|
int len, ret = 0;
|
||||||
PKCS12 *p12;
|
PKCS12 *p12;
|
||||||
p12 = d2i_PKCS12_bio(in, NULL);
|
p12 = d2i_PKCS12_bio(in, NULL);
|
||||||
if (p12 == NULL) {
|
if (p12 == NULL && desc != NULL) {
|
||||||
BIO_printf(bio_err, "Error loading PKCS12 file for %s\n", desc);
|
BIO_printf(bio_err, "Error loading PKCS12 file for %s\n", desc);
|
||||||
goto die;
|
goto die;
|
||||||
}
|
}
|
||||||
@@ -422,7 +433,8 @@ static int load_pkcs12(BIO *in, const char *desc,
|
|||||||
pem_cb = (pem_password_cb *)password_callback;
|
pem_cb = (pem_password_cb *)password_callback;
|
||||||
len = pem_cb(tpass, PEM_BUFSIZE, 0, cb_data);
|
len = pem_cb(tpass, PEM_BUFSIZE, 0, cb_data);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
BIO_printf(bio_err, "Passphrase callback error for %s\n", desc);
|
BIO_printf(bio_err, "Passphrase callback error for %s\n",
|
||||||
|
desc != NULL ? desc : "PKCS12 input");
|
||||||
goto die;
|
goto die;
|
||||||
}
|
}
|
||||||
if (len < PEM_BUFSIZE)
|
if (len < PEM_BUFSIZE)
|
||||||
@@ -430,7 +442,7 @@ static int load_pkcs12(BIO *in, const char *desc,
|
|||||||
if (!PKCS12_verify_mac(p12, tpass, len)) {
|
if (!PKCS12_verify_mac(p12, tpass, len)) {
|
||||||
BIO_printf(bio_err,
|
BIO_printf(bio_err,
|
||||||
"Mac verify error (wrong password?) in PKCS12 file for %s\n",
|
"Mac verify error (wrong password?) in PKCS12 file for %s\n",
|
||||||
desc);
|
desc != NULL ? desc : "PKCS12 input");
|
||||||
goto die;
|
goto die;
|
||||||
}
|
}
|
||||||
pass = tpass;
|
pass = tpass;
|
||||||
@@ -441,7 +453,7 @@ static int load_pkcs12(BIO *in, const char *desc,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
X509 *load_cert(const char *file, int format, const char *cert_descrip)
|
X509 *load_cert(const char *file, int format, const char *desc)
|
||||||
{
|
{
|
||||||
X509 *x = NULL;
|
X509 *x = NULL;
|
||||||
BIO *cert;
|
BIO *cert;
|
||||||
@@ -468,22 +480,26 @@ X509 *load_cert(const char *file, int format, const char *cert_descrip)
|
|||||||
x = PEM_read_bio_X509_AUX(cert, NULL,
|
x = PEM_read_bio_X509_AUX(cert, NULL,
|
||||||
(pem_password_cb *)password_callback, NULL);
|
(pem_password_cb *)password_callback, NULL);
|
||||||
} else if (format == FORMAT_PKCS12) {
|
} else if (format == FORMAT_PKCS12) {
|
||||||
if (!load_pkcs12(cert, cert_descrip, NULL, NULL, NULL, &x, NULL))
|
if (!load_pkcs12(cert, desc, NULL, NULL, NULL, &x, NULL))
|
||||||
goto end;
|
goto end;
|
||||||
} else {
|
} else {
|
||||||
BIO_printf(bio_err, "bad input format specified for %s\n", cert_descrip);
|
print_format_error(format,
|
||||||
goto end;
|
#if !defined(OPENSSL_NO_OCSP) && !defined(OPENSSL_NO_SOCK)
|
||||||
|
OPT_FMT_HTTP |
|
||||||
|
#endif
|
||||||
|
OPT_FMT_PEMDER | OPT_FMT_PKCS12);
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
if (x == NULL) {
|
if (x == NULL && desc != NULL) {
|
||||||
BIO_printf(bio_err, "unable to load certificate\n");
|
BIO_printf(bio_err, "Unable to load %s\n", desc);
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
}
|
}
|
||||||
BIO_free(cert);
|
BIO_free(cert);
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
X509_CRL *load_crl(const char *infile, int format)
|
X509_CRL *load_crl(const char *infile, int format, const char *desc)
|
||||||
{
|
{
|
||||||
X509_CRL *x = NULL;
|
X509_CRL *x = NULL;
|
||||||
BIO *in = NULL;
|
BIO *in = NULL;
|
||||||
@@ -502,23 +518,45 @@ X509_CRL *load_crl(const char *infile, int format)
|
|||||||
x = d2i_X509_CRL_bio(in, NULL);
|
x = d2i_X509_CRL_bio(in, NULL);
|
||||||
} else if (format == FORMAT_PEM) {
|
} else if (format == FORMAT_PEM) {
|
||||||
x = PEM_read_bio_X509_CRL(in, NULL, NULL, NULL);
|
x = PEM_read_bio_X509_CRL(in, NULL, NULL, NULL);
|
||||||
} else {
|
} else
|
||||||
BIO_printf(bio_err, "bad input format specified for input crl\n");
|
print_format_error(format, OPT_FMT_PEMDER);
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
if (x == NULL) {
|
|
||||||
BIO_printf(bio_err, "unable to load CRL\n");
|
|
||||||
ERR_print_errors(bio_err);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
if (x == NULL && desc != NULL) {
|
||||||
|
BIO_printf(bio_err, "Unable to load %s\n", desc);
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
}
|
||||||
BIO_free(in);
|
BIO_free(in);
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
X509_REQ *load_csr(const char *file, int format, const char *desc)
|
||||||
|
{
|
||||||
|
X509_REQ *req = NULL;
|
||||||
|
BIO *in;
|
||||||
|
|
||||||
|
in = bio_open_default(file, 'r', format);
|
||||||
|
if (in == NULL)
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
if (format == FORMAT_ASN1)
|
||||||
|
req = d2i_X509_REQ_bio(in, NULL);
|
||||||
|
else if (format == FORMAT_PEM)
|
||||||
|
req = PEM_read_bio_X509_REQ(in, NULL, NULL, NULL);
|
||||||
|
else
|
||||||
|
print_format_error(format, OPT_FMT_PEMDER);
|
||||||
|
|
||||||
|
end:
|
||||||
|
if (req == NULL && desc != NULL) {
|
||||||
|
BIO_printf(bio_err, "Unable to load %s\n", desc);
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
}
|
||||||
|
BIO_free(in);
|
||||||
|
return req;
|
||||||
|
}
|
||||||
|
|
||||||
EVP_PKEY *load_key(const char *file, int format, int maybe_stdin,
|
EVP_PKEY *load_key(const char *file, int format, int maybe_stdin,
|
||||||
const char *pass, ENGINE *e, const char *key_descrip)
|
const char *pass, ENGINE *e, const char *desc)
|
||||||
{
|
{
|
||||||
BIO *key = NULL;
|
BIO *key = NULL;
|
||||||
EVP_PKEY *pkey = NULL;
|
EVP_PKEY *pkey = NULL;
|
||||||
@@ -528,12 +566,12 @@ EVP_PKEY *load_key(const char *file, int format, int maybe_stdin,
|
|||||||
cb_data.prompt_info = file;
|
cb_data.prompt_info = file;
|
||||||
|
|
||||||
if (file == NULL && (!maybe_stdin || format == FORMAT_ENGINE)) {
|
if (file == NULL && (!maybe_stdin || format == FORMAT_ENGINE)) {
|
||||||
BIO_printf(bio_err, "no keyfile specified\n");
|
BIO_printf(bio_err, "No keyfile specified\n");
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
if (format == FORMAT_ENGINE) {
|
if (format == FORMAT_ENGINE) {
|
||||||
if (e == NULL) {
|
if (e == NULL) {
|
||||||
BIO_printf(bio_err, "no engine specified\n");
|
BIO_printf(bio_err, "No engine specified\n");
|
||||||
} else {
|
} else {
|
||||||
#ifndef OPENSSL_NO_ENGINE
|
#ifndef OPENSSL_NO_ENGINE
|
||||||
if (ENGINE_init(e)) {
|
if (ENGINE_init(e)) {
|
||||||
@@ -542,12 +580,12 @@ EVP_PKEY *load_key(const char *file, int format, int maybe_stdin,
|
|||||||
&cb_data);
|
&cb_data);
|
||||||
ENGINE_finish(e);
|
ENGINE_finish(e);
|
||||||
}
|
}
|
||||||
if (pkey == NULL) {
|
if (pkey == NULL && desc != NULL) {
|
||||||
BIO_printf(bio_err, "cannot load %s from engine\n", key_descrip);
|
BIO_printf(bio_err, "Cannot load %s from engine\n", desc);
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
BIO_printf(bio_err, "engines not supported\n");
|
BIO_printf(bio_err, "Engines not supported\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
goto end;
|
goto end;
|
||||||
@@ -565,7 +603,8 @@ EVP_PKEY *load_key(const char *file, int format, int maybe_stdin,
|
|||||||
} else if (format == FORMAT_PEM) {
|
} else if (format == FORMAT_PEM) {
|
||||||
pkey = PEM_read_bio_PrivateKey(key, NULL, wrap_password_callback, &cb_data);
|
pkey = PEM_read_bio_PrivateKey(key, NULL, wrap_password_callback, &cb_data);
|
||||||
} else if (format == FORMAT_PKCS12) {
|
} else if (format == FORMAT_PKCS12) {
|
||||||
if (!load_pkcs12(key, key_descrip, wrap_password_callback, &cb_data,
|
if (!load_pkcs12(key, desc,
|
||||||
|
(pem_password_cb *)password_callback, &cb_data,
|
||||||
&pkey, NULL, NULL))
|
&pkey, NULL, NULL))
|
||||||
goto end;
|
goto end;
|
||||||
#if !defined(OPENSSL_NO_RSA) && !defined(OPENSSL_NO_DSA) && !defined (OPENSSL_NO_RC4)
|
#if !defined(OPENSSL_NO_RSA) && !defined(OPENSSL_NO_DSA) && !defined (OPENSSL_NO_RC4)
|
||||||
@@ -575,20 +614,27 @@ EVP_PKEY *load_key(const char *file, int format, int maybe_stdin,
|
|||||||
pkey = b2i_PVK_bio(key, wrap_password_callback, &cb_data);
|
pkey = b2i_PVK_bio(key, wrap_password_callback, &cb_data);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
BIO_printf(bio_err, "bad input format specified for key file\n");
|
print_format_error(format, OPT_FMT_PEMDER | OPT_FMT_PKCS12
|
||||||
goto end;
|
#if !defined(OPENSSL_NO_RSA) && !defined(OPENSSL_NO_DSA) && !defined (OPENSSL_NO_RC4)
|
||||||
|
| OPT_FMT_MSBLOB | FORMAT_PVK
|
||||||
|
#endif
|
||||||
|
#ifndef OPENSSL_NO_ENGINE
|
||||||
|
| OPT_FMT_ENGINE
|
||||||
|
#endif
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
BIO_free(key);
|
BIO_free(key);
|
||||||
if (pkey == NULL) {
|
if (pkey == NULL && desc != NULL) {
|
||||||
BIO_printf(bio_err, "unable to load %s\n", key_descrip);
|
BIO_printf(bio_err, "Unable to load %s\n", desc);
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
}
|
}
|
||||||
return pkey;
|
return pkey;
|
||||||
}
|
}
|
||||||
|
|
||||||
EVP_PKEY *load_pubkey(const char *file, int format, int maybe_stdin,
|
EVP_PKEY *load_pubkey(const char *file, int format, int maybe_stdin,
|
||||||
const char *pass, ENGINE *e, const char *key_descrip)
|
const char *pass, ENGINE *e, const char *desc)
|
||||||
{
|
{
|
||||||
BIO *key = NULL;
|
BIO *key = NULL;
|
||||||
EVP_PKEY *pkey = NULL;
|
EVP_PKEY *pkey = NULL;
|
||||||
@@ -598,22 +644,22 @@ EVP_PKEY *load_pubkey(const char *file, int format, int maybe_stdin,
|
|||||||
cb_data.prompt_info = file;
|
cb_data.prompt_info = file;
|
||||||
|
|
||||||
if (file == NULL && (!maybe_stdin || format == FORMAT_ENGINE)) {
|
if (file == NULL && (!maybe_stdin || format == FORMAT_ENGINE)) {
|
||||||
BIO_printf(bio_err, "no keyfile specified\n");
|
BIO_printf(bio_err, "No keyfile specified\n");
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
if (format == FORMAT_ENGINE) {
|
if (format == FORMAT_ENGINE) {
|
||||||
if (e == NULL) {
|
if (e == NULL) {
|
||||||
BIO_printf(bio_err, "no engine specified\n");
|
BIO_printf(bio_err, "No engine specified\n");
|
||||||
} else {
|
} else {
|
||||||
#ifndef OPENSSL_NO_ENGINE
|
#ifndef OPENSSL_NO_ENGINE
|
||||||
pkey = ENGINE_load_public_key(e, file, (UI_METHOD *)get_ui_method(),
|
pkey = ENGINE_load_public_key(e, file, (UI_METHOD *)get_ui_method(),
|
||||||
&cb_data);
|
&cb_data);
|
||||||
if (pkey == NULL) {
|
if (pkey == NULL && desc != NULL) {
|
||||||
BIO_printf(bio_err, "cannot load %s from engine\n", key_descrip);
|
BIO_printf(bio_err, "Cannot load %s from engine\n", desc);
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
BIO_printf(bio_err, "engines not supported\n");
|
BIO_printf(bio_err, "Engines not supported\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
goto end;
|
goto end;
|
||||||
@@ -666,11 +712,19 @@ EVP_PKEY *load_pubkey(const char *file, int format, int maybe_stdin,
|
|||||||
} else if (format == FORMAT_MSBLOB) {
|
} else if (format == FORMAT_MSBLOB) {
|
||||||
pkey = b2i_PublicKey_bio(key);
|
pkey = b2i_PublicKey_bio(key);
|
||||||
#endif
|
#endif
|
||||||
|
} else {
|
||||||
|
print_format_error(format, OPT_FMT_PEMDER
|
||||||
|
#if !defined(OPENSSL_NO_RSA) && !defined(OPENSSL_NO_DSA)
|
||||||
|
| OPT_FMT_MSBLOB
|
||||||
|
#endif
|
||||||
|
);
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
BIO_free(key);
|
BIO_free(key);
|
||||||
if (pkey == NULL)
|
if (pkey == NULL && desc != NULL) {
|
||||||
BIO_printf(bio_err, "unable to load %s\n", key_descrip);
|
BIO_printf(bio_err, "Unable to load %s\n", desc);
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
}
|
||||||
return pkey;
|
return pkey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -690,7 +744,7 @@ static int load_certs_crls(const char *file, int format,
|
|||||||
cb_data.prompt_info = file;
|
cb_data.prompt_info = file;
|
||||||
|
|
||||||
if (format != FORMAT_PEM) {
|
if (format != FORMAT_PEM) {
|
||||||
BIO_printf(bio_err, "bad input format specified for %s\n", desc);
|
BIO_printf(bio_err, "Bad input format specified for %s\n", desc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -749,10 +803,12 @@ static int load_certs_crls(const char *file, int format,
|
|||||||
sk_X509_CRL_pop_free(*pcrls, X509_CRL_free);
|
sk_X509_CRL_pop_free(*pcrls, X509_CRL_free);
|
||||||
*pcrls = NULL;
|
*pcrls = NULL;
|
||||||
}
|
}
|
||||||
BIO_printf(bio_err, "unable to load %s\n",
|
if (desc != NULL) {
|
||||||
pcerts ? "certificates" : "CRLs");
|
BIO_printf(bio_err, "Unable to load %s for %s\n",
|
||||||
|
pcerts ? "certificates" : "CRLs", desc);
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -968,7 +1024,7 @@ static int set_table_opts(unsigned long *flags, const char *arg,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_name(BIO *out, const char *title, X509_NAME *nm,
|
void print_name(BIO *out, const char *title, const X509_NAME *nm,
|
||||||
unsigned long lflags)
|
unsigned long lflags)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
@@ -1083,6 +1139,7 @@ X509_STORE *setup_verify(const char *CAfile, int noCAfile,
|
|||||||
ERR_clear_error();
|
ERR_clear_error();
|
||||||
return store;
|
return store;
|
||||||
end:
|
end:
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
X509_STORE_free(store);
|
X509_STORE_free(store);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -1110,13 +1167,13 @@ ENGINE *setup_engine(const char *engine, int debug)
|
|||||||
#ifndef OPENSSL_NO_ENGINE
|
#ifndef OPENSSL_NO_ENGINE
|
||||||
if (engine != NULL) {
|
if (engine != NULL) {
|
||||||
if (strcmp(engine, "auto") == 0) {
|
if (strcmp(engine, "auto") == 0) {
|
||||||
BIO_printf(bio_err, "enabling auto ENGINE support\n");
|
BIO_printf(bio_err, "Enabling auto ENGINE support\n");
|
||||||
ENGINE_register_all_complete();
|
ENGINE_register_all_complete();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if ((e = ENGINE_by_id(engine)) == NULL
|
if ((e = ENGINE_by_id(engine)) == NULL
|
||||||
&& (e = try_load_engine(engine)) == NULL) {
|
&& (e = try_load_engine(engine)) == NULL) {
|
||||||
BIO_printf(bio_err, "invalid engine \"%s\"\n", engine);
|
BIO_printf(bio_err, "Invalid engine \"%s\"\n", engine);
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -1126,13 +1183,13 @@ ENGINE *setup_engine(const char *engine, int debug)
|
|||||||
ENGINE_ctrl_cmd(e, "SET_USER_INTERFACE", 0, (void *)get_ui_method(),
|
ENGINE_ctrl_cmd(e, "SET_USER_INTERFACE", 0, (void *)get_ui_method(),
|
||||||
0, 1);
|
0, 1);
|
||||||
if (!ENGINE_set_default(e, ENGINE_METHOD_ALL)) {
|
if (!ENGINE_set_default(e, ENGINE_METHOD_ALL)) {
|
||||||
BIO_printf(bio_err, "can't use that engine\n");
|
BIO_printf(bio_err, "Cannot use engine \"%s\"\n", ENGINE_get_id(e));
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
ENGINE_free(e);
|
ENGINE_free(e);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
BIO_printf(bio_err, "engine \"%s\" set.\n", ENGINE_get_id(e));
|
BIO_printf(bio_err, "Engine \"%s\" set.\n", ENGINE_get_id(e));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return e;
|
return e;
|
||||||
@@ -1211,14 +1268,13 @@ BIGNUM *load_serial(const char *serialfile, int create, ASN1_INTEGER **retai)
|
|||||||
BIO_printf(bio_err, "Out of memory\n");
|
BIO_printf(bio_err, "Out of memory\n");
|
||||||
} else {
|
} else {
|
||||||
if (!a2i_ASN1_INTEGER(in, ai, buf, 1024)) {
|
if (!a2i_ASN1_INTEGER(in, ai, buf, 1024)) {
|
||||||
BIO_printf(bio_err, "unable to load number from %s\n",
|
BIO_printf(bio_err, "Unable to load number from %s\n",
|
||||||
serialfile);
|
serialfile);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
ret = ASN1_INTEGER_to_BN(ai, NULL);
|
ret = ASN1_INTEGER_to_BN(ai, NULL);
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
BIO_printf(bio_err,
|
BIO_printf(bio_err, "Error converting number from bin to BIGNUM\n");
|
||||||
"error converting number from bin to BIGNUM\n");
|
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1228,6 +1284,7 @@ BIGNUM *load_serial(const char *serialfile, int create, ASN1_INTEGER **retai)
|
|||||||
ai = NULL;
|
ai = NULL;
|
||||||
}
|
}
|
||||||
err:
|
err:
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
BIO_free(in);
|
BIO_free(in);
|
||||||
ASN1_INTEGER_free(ai);
|
ASN1_INTEGER_free(ai);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -1247,7 +1304,7 @@ int save_serial(const char *serialfile, const char *suffix, const BIGNUM *serial
|
|||||||
else
|
else
|
||||||
j = strlen(serialfile) + strlen(suffix) + 1;
|
j = strlen(serialfile) + strlen(suffix) + 1;
|
||||||
if (j >= BSIZE) {
|
if (j >= BSIZE) {
|
||||||
BIO_printf(bio_err, "file name too long\n");
|
BIO_printf(bio_err, "File name too long\n");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1262,7 +1319,6 @@ int save_serial(const char *serialfile, const char *suffix, const BIGNUM *serial
|
|||||||
}
|
}
|
||||||
out = BIO_new_file(buf[0], "w");
|
out = BIO_new_file(buf[0], "w");
|
||||||
if (out == NULL) {
|
if (out == NULL) {
|
||||||
ERR_print_errors(bio_err);
|
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1278,6 +1334,8 @@ int save_serial(const char *serialfile, const char *suffix, const BIGNUM *serial
|
|||||||
ai = NULL;
|
ai = NULL;
|
||||||
}
|
}
|
||||||
err:
|
err:
|
||||||
|
if (!ret)
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
BIO_free_all(out);
|
BIO_free_all(out);
|
||||||
ASN1_INTEGER_free(ai);
|
ASN1_INTEGER_free(ai);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -1294,7 +1352,7 @@ int rotate_serial(const char *serialfile, const char *new_suffix,
|
|||||||
if (i > j)
|
if (i > j)
|
||||||
j = i;
|
j = i;
|
||||||
if (j + 1 >= BSIZE) {
|
if (j + 1 >= BSIZE) {
|
||||||
BIO_printf(bio_err, "file name too long\n");
|
BIO_printf(bio_err, "File name too long\n");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
#ifndef OPENSSL_SYS_VMS
|
#ifndef OPENSSL_SYS_VMS
|
||||||
@@ -1310,19 +1368,20 @@ int rotate_serial(const char *serialfile, const char *new_suffix,
|
|||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
BIO_printf(bio_err,
|
BIO_printf(bio_err,
|
||||||
"unable to rename %s to %s\n", serialfile, buf[1]);
|
"Unable to rename %s to %s\n", serialfile, buf[1]);
|
||||||
perror("reason");
|
perror("reason");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
if (rename(buf[0], serialfile) < 0) {
|
if (rename(buf[0], serialfile) < 0) {
|
||||||
BIO_printf(bio_err,
|
BIO_printf(bio_err,
|
||||||
"unable to rename %s to %s\n", buf[0], serialfile);
|
"Unable to rename %s to %s\n", buf[0], serialfile);
|
||||||
perror("reason");
|
perror("reason");
|
||||||
rename(buf[1], serialfile);
|
rename(buf[1], serialfile);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
err:
|
err:
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1363,17 +1422,14 @@ CA_DB *load_index(const char *dbfile, DB_ATTR *db_attr)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
in = BIO_new_file(dbfile, "r");
|
in = BIO_new_file(dbfile, "r");
|
||||||
if (in == NULL) {
|
if (in == NULL)
|
||||||
ERR_print_errors(bio_err);
|
|
||||||
goto err;
|
goto err;
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_POSIX_IO
|
#ifndef OPENSSL_NO_POSIX_IO
|
||||||
BIO_get_fp(in, &dbfp);
|
BIO_get_fp(in, &dbfp);
|
||||||
if (fstat(fileno(dbfp), &dbst) == -1) {
|
if (fstat(fileno(dbfp), &dbst) == -1) {
|
||||||
ERR_raise_data(ERR_LIB_SYS, errno,
|
ERR_raise_data(ERR_LIB_SYS, errno,
|
||||||
"calling fstat(%s)", dbfile);
|
"calling fstat(%s)", dbfile);
|
||||||
ERR_print_errors(bio_err);
|
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1410,6 +1466,7 @@ CA_DB *load_index(const char *dbfile, DB_ATTR *db_attr)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
NCONF_free(dbattr_conf);
|
NCONF_free(dbattr_conf);
|
||||||
TXT_DB_free(tmpdb);
|
TXT_DB_free(tmpdb);
|
||||||
BIO_free_all(in);
|
BIO_free_all(in);
|
||||||
@@ -1425,20 +1482,23 @@ int index_index(CA_DB *db)
|
|||||||
LHASH_HASH_FN(index_serial),
|
LHASH_HASH_FN(index_serial),
|
||||||
LHASH_COMP_FN(index_serial))) {
|
LHASH_COMP_FN(index_serial))) {
|
||||||
BIO_printf(bio_err,
|
BIO_printf(bio_err,
|
||||||
"error creating serial number index:(%ld,%ld,%ld)\n",
|
"Error creating serial number index:(%ld,%ld,%ld)\n",
|
||||||
db->db->error, db->db->arg1, db->db->arg2);
|
db->db->error, db->db->arg1, db->db->arg2);
|
||||||
return 0;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (db->attributes.unique_subject
|
if (db->attributes.unique_subject
|
||||||
&& !TXT_DB_create_index(db->db, DB_name, index_name_qual,
|
&& !TXT_DB_create_index(db->db, DB_name, index_name_qual,
|
||||||
LHASH_HASH_FN(index_name),
|
LHASH_HASH_FN(index_name),
|
||||||
LHASH_COMP_FN(index_name))) {
|
LHASH_COMP_FN(index_name))) {
|
||||||
BIO_printf(bio_err, "error creating name index:(%ld,%ld,%ld)\n",
|
BIO_printf(bio_err, "Error creating name index:(%ld,%ld,%ld)\n",
|
||||||
db->db->error, db->db->arg1, db->db->arg2);
|
db->db->error, db->db->arg1, db->db->arg2);
|
||||||
return 0;
|
goto err;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
err:
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int save_index(const char *dbfile, const char *suffix, CA_DB *db)
|
int save_index(const char *dbfile, const char *suffix, CA_DB *db)
|
||||||
@@ -1449,7 +1509,7 @@ int save_index(const char *dbfile, const char *suffix, CA_DB *db)
|
|||||||
|
|
||||||
j = strlen(dbfile) + strlen(suffix);
|
j = strlen(dbfile) + strlen(suffix);
|
||||||
if (j + 6 >= BSIZE) {
|
if (j + 6 >= BSIZE) {
|
||||||
BIO_printf(bio_err, "file name too long\n");
|
BIO_printf(bio_err, "File name too long\n");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
#ifndef OPENSSL_SYS_VMS
|
#ifndef OPENSSL_SYS_VMS
|
||||||
@@ -1464,7 +1524,7 @@ int save_index(const char *dbfile, const char *suffix, CA_DB *db)
|
|||||||
out = BIO_new_file(buf[0], "w");
|
out = BIO_new_file(buf[0], "w");
|
||||||
if (out == NULL) {
|
if (out == NULL) {
|
||||||
perror(dbfile);
|
perror(dbfile);
|
||||||
BIO_printf(bio_err, "unable to open '%s'\n", dbfile);
|
BIO_printf(bio_err, "Unable to open '%s'\n", dbfile);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
j = TXT_DB_write(out, db->db);
|
j = TXT_DB_write(out, db->db);
|
||||||
@@ -1475,7 +1535,7 @@ int save_index(const char *dbfile, const char *suffix, CA_DB *db)
|
|||||||
out = BIO_new_file(buf[1], "w");
|
out = BIO_new_file(buf[1], "w");
|
||||||
if (out == NULL) {
|
if (out == NULL) {
|
||||||
perror(buf[2]);
|
perror(buf[2]);
|
||||||
BIO_printf(bio_err, "unable to open '%s'\n", buf[2]);
|
BIO_printf(bio_err, "Unable to open '%s'\n", buf[2]);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
BIO_printf(out, "unique_subject = %s\n",
|
BIO_printf(out, "unique_subject = %s\n",
|
||||||
@@ -1484,6 +1544,7 @@ int save_index(const char *dbfile, const char *suffix, CA_DB *db)
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
err:
|
err:
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1498,7 +1559,7 @@ int rotate_index(const char *dbfile, const char *new_suffix,
|
|||||||
if (i > j)
|
if (i > j)
|
||||||
j = i;
|
j = i;
|
||||||
if (j + 6 >= BSIZE) {
|
if (j + 6 >= BSIZE) {
|
||||||
BIO_printf(bio_err, "file name too long\n");
|
BIO_printf(bio_err, "File name too long\n");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
#ifndef OPENSSL_SYS_VMS
|
#ifndef OPENSSL_SYS_VMS
|
||||||
@@ -1519,12 +1580,12 @@ int rotate_index(const char *dbfile, const char *new_suffix,
|
|||||||
&& errno != ENOTDIR
|
&& errno != ENOTDIR
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
BIO_printf(bio_err, "unable to rename %s to %s\n", dbfile, buf[1]);
|
BIO_printf(bio_err, "Unable to rename %s to %s\n", dbfile, buf[1]);
|
||||||
perror("reason");
|
perror("reason");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
if (rename(buf[0], dbfile) < 0) {
|
if (rename(buf[0], dbfile) < 0) {
|
||||||
BIO_printf(bio_err, "unable to rename %s to %s\n", buf[0], dbfile);
|
BIO_printf(bio_err, "Unable to rename %s to %s\n", buf[0], dbfile);
|
||||||
perror("reason");
|
perror("reason");
|
||||||
rename(buf[1], dbfile);
|
rename(buf[1], dbfile);
|
||||||
goto err;
|
goto err;
|
||||||
@@ -1534,14 +1595,14 @@ int rotate_index(const char *dbfile, const char *new_suffix,
|
|||||||
&& errno != ENOTDIR
|
&& errno != ENOTDIR
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
BIO_printf(bio_err, "unable to rename %s to %s\n", buf[4], buf[3]);
|
BIO_printf(bio_err, "Unable to rename %s to %s\n", buf[4], buf[3]);
|
||||||
perror("reason");
|
perror("reason");
|
||||||
rename(dbfile, buf[0]);
|
rename(dbfile, buf[0]);
|
||||||
rename(buf[1], dbfile);
|
rename(buf[1], dbfile);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
if (rename(buf[2], buf[4]) < 0) {
|
if (rename(buf[2], buf[4]) < 0) {
|
||||||
BIO_printf(bio_err, "unable to rename %s to %s\n", buf[2], buf[4]);
|
BIO_printf(bio_err, "Unable to rename %s to %s\n", buf[2], buf[4]);
|
||||||
perror("reason");
|
perror("reason");
|
||||||
rename(buf[3], buf[4]);
|
rename(buf[3], buf[4]);
|
||||||
rename(dbfile, buf[0]);
|
rename(dbfile, buf[0]);
|
||||||
@@ -1550,6 +1611,7 @@ int rotate_index(const char *dbfile, const char *new_suffix,
|
|||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
err:
|
err:
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1640,7 +1702,7 @@ X509_NAME *parse_name(const char *cp, long chtype, int canmulti)
|
|||||||
}
|
}
|
||||||
if (*cp == '\\' && *++cp == '\0') {
|
if (*cp == '\\' && *++cp == '\0') {
|
||||||
BIO_printf(bio_err,
|
BIO_printf(bio_err,
|
||||||
"%s: escape character at end of string\n",
|
"%s: Escape character at end of string\n",
|
||||||
opt_getprog());
|
opt_getprog());
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@@ -1889,18 +1951,18 @@ static X509_CRL *load_crl_crldp(STACK_OF(DIST_POINT) *crldp)
|
|||||||
DIST_POINT *dp = sk_DIST_POINT_value(crldp, i);
|
DIST_POINT *dp = sk_DIST_POINT_value(crldp, i);
|
||||||
urlptr = get_dp_url(dp);
|
urlptr = get_dp_url(dp);
|
||||||
if (urlptr)
|
if (urlptr)
|
||||||
return load_crl(urlptr, FORMAT_HTTP);
|
return load_crl(urlptr, FORMAT_HTTP, "CRL via CDP");
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Example of downloading CRLs from CRLDP: not usable for real world as it
|
* Example of downloading CRLs from CRLDP:
|
||||||
* always downloads, doesn't support non-blocking I/O and doesn't cache
|
* not usable for real world as it always downloads and doesn't cache anything.
|
||||||
* anything.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static STACK_OF(X509_CRL) *crls_http_cb(X509_STORE_CTX *ctx, X509_NAME *nm)
|
static STACK_OF(X509_CRL) *crls_http_cb(const X509_STORE_CTX *ctx,
|
||||||
|
const X509_NAME *nm)
|
||||||
{
|
{
|
||||||
X509 *x;
|
X509 *x;
|
||||||
STACK_OF(X509_CRL) *crls = NULL;
|
STACK_OF(X509_CRL) *crls = NULL;
|
||||||
@@ -1989,7 +2051,7 @@ BIO *app_http_tls_cb(BIO *hbio, void *arg, int connect, int detail)
|
|||||||
} else if (!connect && !detail) { /* disconnecting after error */
|
} else if (!connect && !detail) { /* disconnecting after error */
|
||||||
const char *hint = tls_error_hint();
|
const char *hint = tls_error_hint();
|
||||||
if (hint != NULL)
|
if (hint != NULL)
|
||||||
ERR_add_error_data(1, hint);
|
ERR_add_error_data(2, " : ", hint);
|
||||||
/*
|
/*
|
||||||
* If we pop sbio and BIO_free() it this may lead to libssl double free.
|
* If we pop sbio and BIO_free() it this may lead to libssl double free.
|
||||||
* Rely on BIO_free_all() done by OSSL_HTTP_transfer() in http_client.c
|
* Rely on BIO_free_all() done by OSSL_HTTP_transfer() in http_client.c
|
||||||
@@ -1999,7 +2061,7 @@ BIO *app_http_tls_cb(BIO *hbio, void *arg, int connect, int detail)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ASN1_VALUE *app_http_get_asn1(const char *url, const char *proxy,
|
ASN1_VALUE *app_http_get_asn1(const char *url, const char *proxy,
|
||||||
const char *proxy_port, SSL_CTX *ssl_ctx,
|
const char *no_proxy, SSL_CTX *ssl_ctx,
|
||||||
const STACK_OF(CONF_VALUE) *headers,
|
const STACK_OF(CONF_VALUE) *headers,
|
||||||
long timeout, const char *expected_content_type,
|
long timeout, const char *expected_content_type,
|
||||||
const ASN1_ITEM *it)
|
const ASN1_ITEM *it)
|
||||||
@@ -2028,7 +2090,7 @@ ASN1_VALUE *app_http_get_asn1(const char *url, const char *proxy,
|
|||||||
info.use_proxy = proxy != NULL;
|
info.use_proxy = proxy != NULL;
|
||||||
info.timeout = timeout;
|
info.timeout = timeout;
|
||||||
info.ssl_ctx = ssl_ctx;
|
info.ssl_ctx = ssl_ctx;
|
||||||
resp = OSSL_HTTP_get_asn1(url, proxy, proxy_port,
|
resp = OSSL_HTTP_get_asn1(url, proxy, no_proxy,
|
||||||
NULL, NULL, app_http_tls_cb, &info,
|
NULL, NULL, app_http_tls_cb, &info,
|
||||||
headers, 0 /* maxline */, 0 /* max_resp_len */,
|
headers, 0 /* maxline */, 0 /* max_resp_len */,
|
||||||
timeout, expected_content_type, it);
|
timeout, expected_content_type, it);
|
||||||
@@ -2041,7 +2103,7 @@ ASN1_VALUE *app_http_get_asn1(const char *url, const char *proxy,
|
|||||||
|
|
||||||
ASN1_VALUE *app_http_post_asn1(const char *host, const char *port,
|
ASN1_VALUE *app_http_post_asn1(const char *host, const char *port,
|
||||||
const char *path, const char *proxy,
|
const char *path, const char *proxy,
|
||||||
const char *proxy_port, SSL_CTX *ssl_ctx,
|
const char *no_proxy, SSL_CTX *ssl_ctx,
|
||||||
const STACK_OF(CONF_VALUE) *headers,
|
const STACK_OF(CONF_VALUE) *headers,
|
||||||
const char *content_type,
|
const char *content_type,
|
||||||
ASN1_VALUE *req, const ASN1_ITEM *req_it,
|
ASN1_VALUE *req, const ASN1_ITEM *req_it,
|
||||||
@@ -2055,7 +2117,7 @@ ASN1_VALUE *app_http_post_asn1(const char *host, const char *port,
|
|||||||
info.timeout = timeout;
|
info.timeout = timeout;
|
||||||
info.ssl_ctx = ssl_ctx;
|
info.ssl_ctx = ssl_ctx;
|
||||||
return OSSL_HTTP_post_asn1(host, port, path, ssl_ctx != NULL,
|
return OSSL_HTTP_post_asn1(host, port, path, ssl_ctx != NULL,
|
||||||
proxy, proxy_port,
|
proxy, no_proxy,
|
||||||
NULL, NULL, app_http_tls_cb, &info,
|
NULL, NULL, app_http_tls_cb, &info,
|
||||||
headers, content_type, req, req_it,
|
headers, content_type, req, req_it,
|
||||||
0 /* maxline */,
|
0 /* maxline */,
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ ENDIF
|
|||||||
|
|
||||||
# Source for libapps
|
# Source for libapps
|
||||||
$LIBAPPSSRC=apps.c apps_ui.c opt.c fmt.c s_cb.c s_socket.c app_rand.c \
|
$LIBAPPSSRC=apps.c apps_ui.c opt.c fmt.c s_cb.c s_socket.c app_rand.c \
|
||||||
columns.c app_params.c names.c app_provider.c
|
columns.c app_params.c names.c app_provider.c app_x509.c
|
||||||
|
|
||||||
IF[{- !$disabled{apps} -}]
|
IF[{- !$disabled{apps} -}]
|
||||||
LIBS{noinst}=../libapps.a
|
LIBS{noinst}=../libapps.a
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
#include <openssl/safestack.h>
|
#include <openssl/safestack.h>
|
||||||
#include "names.h"
|
#include "names.h"
|
||||||
|
|
||||||
|
DEFINE_STACK_OF_CSTRING()
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# define strcasecmp _stricmp
|
# define strcasecmp _stricmp
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+36
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -282,6 +282,41 @@ int opt_format(const char *s, unsigned long flags, int *result)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return string representing the given format. */
|
||||||
|
const char *format2str(int format)
|
||||||
|
{
|
||||||
|
switch (format) {
|
||||||
|
default:
|
||||||
|
return "(undefined)";
|
||||||
|
case FORMAT_PEM:
|
||||||
|
return "PEM";
|
||||||
|
case FORMAT_ASN1:
|
||||||
|
return "DER";
|
||||||
|
case FORMAT_TEXT:
|
||||||
|
return "TEXT";
|
||||||
|
case FORMAT_NSS:
|
||||||
|
return "NSS";
|
||||||
|
case FORMAT_SMIME:
|
||||||
|
return "SMIME";
|
||||||
|
case FORMAT_MSBLOB:
|
||||||
|
return "MSBLOB";
|
||||||
|
case FORMAT_ENGINE:
|
||||||
|
return "ENGINE";
|
||||||
|
case FORMAT_HTTP:
|
||||||
|
return "HTTP";
|
||||||
|
case FORMAT_PKCS12:
|
||||||
|
return "P12";
|
||||||
|
case FORMAT_PVK:
|
||||||
|
return "PVK";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print an error message about unsuitable/unsupported format requested. */
|
||||||
|
void print_format_error(int format, unsigned long flags)
|
||||||
|
{
|
||||||
|
(void)opt_format_error(format2str(format), flags);
|
||||||
|
}
|
||||||
|
|
||||||
/* Parse a cipher name, put it in *EVP_CIPHER; return 0 on failure, else 1. */
|
/* Parse a cipher name, put it in *EVP_CIPHER; return 0 on failure, else 1. */
|
||||||
int opt_cipher(const char *name, const EVP_CIPHER **cipherp)
|
int opt_cipher(const char *name, const EVP_CIPHER **cipherp)
|
||||||
{
|
{
|
||||||
|
|||||||
+7
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -26,6 +26,11 @@
|
|||||||
|
|
||||||
#define COOKIE_SECRET_LENGTH 16
|
#define COOKIE_SECRET_LENGTH 16
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(X509)
|
||||||
|
DEFINE_STACK_OF(X509_CRL)
|
||||||
|
DEFINE_STACK_OF(X509_NAME)
|
||||||
|
DEFINE_STACK_OF_STRING()
|
||||||
|
|
||||||
VERIFY_CB_ARGS verify_args = { -1, 0, X509_V_OK, 0 };
|
VERIFY_CB_ARGS verify_args = { -1, 0, X509_V_OK, 0 };
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_SOCK
|
#ifndef OPENSSL_NO_SOCK
|
||||||
@@ -190,7 +195,7 @@ static STRINT_PAIR cert_type_list[] = {
|
|||||||
{"RSA fixed ECDH", TLS_CT_RSA_FIXED_ECDH},
|
{"RSA fixed ECDH", TLS_CT_RSA_FIXED_ECDH},
|
||||||
{"ECDSA fixed ECDH", TLS_CT_ECDSA_FIXED_ECDH},
|
{"ECDSA fixed ECDH", TLS_CT_ECDSA_FIXED_ECDH},
|
||||||
{"GOST01 Sign", TLS_CT_GOST01_SIGN},
|
{"GOST01 Sign", TLS_CT_GOST01_SIGN},
|
||||||
{"GOST12 Sign", TLS_CT_GOST12_SIGN},
|
{"GOST12 Sign", TLS_CT_GOST12_IANA_SIGN},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -19,6 +19,8 @@
|
|||||||
#include "opt.h"
|
#include "opt.h"
|
||||||
#include "names.h"
|
#include "names.h"
|
||||||
|
|
||||||
|
DEFINE_STACK_OF_CSTRING()
|
||||||
|
|
||||||
static int verbose = 0;
|
static int verbose = 0;
|
||||||
|
|
||||||
static void legacy_cipher_fn(const EVP_CIPHER *c,
|
static void legacy_cipher_fn(const EVP_CIPHER *c,
|
||||||
|
|||||||
+3
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -16,6 +16,8 @@
|
|||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
#include <openssl/params.h>
|
#include <openssl/params.h>
|
||||||
|
|
||||||
|
DEFINE_STACK_OF_STRING()
|
||||||
|
|
||||||
#undef BUFSIZE
|
#undef BUFSIZE
|
||||||
#define BUFSIZE 1024*8
|
#define BUFSIZE 1024*8
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -14,6 +14,8 @@
|
|||||||
#include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(X509)
|
||||||
|
|
||||||
typedef enum OPTION_choice {
|
typedef enum OPTION_choice {
|
||||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||||
OPT_TOSEQ, OPT_IN, OPT_OUT,
|
OPT_TOSEQ, OPT_IN, OPT_OUT,
|
||||||
|
|||||||
+60
-60
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -9,32 +9,34 @@
|
|||||||
|
|
||||||
#include <openssl/opensslconf.h>
|
#include <openssl/opensslconf.h>
|
||||||
|
|
||||||
#ifdef OPENSSL_NO_OCSP
|
#ifdef OPENSSL_SYS_VMS
|
||||||
NON_EMPTY_TRANSLATION_UNIT
|
/* So fd_set and friends get properly defined on OpenVMS */
|
||||||
#else
|
# define _XOPEN_SOURCE_EXTENDED
|
||||||
# ifdef OPENSSL_SYS_VMS
|
#endif
|
||||||
# define _XOPEN_SOURCE_EXTENDED/* So fd_set and friends get properly defined
|
|
||||||
* on OpenVMS */
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# include <stdio.h>
|
#include <stdio.h>
|
||||||
# include <stdlib.h>
|
#include <stdlib.h>
|
||||||
# include <string.h>
|
#include <string.h>
|
||||||
# include <time.h>
|
#include <time.h>
|
||||||
# include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
/* Needs to be included before the openssl headers */
|
/* Needs to be included before the openssl headers */
|
||||||
# include "apps.h"
|
#include "apps.h"
|
||||||
# include "progs.h"
|
#include "progs.h"
|
||||||
# include "internal/sockets.h"
|
#include "internal/sockets.h"
|
||||||
# include <openssl/e_os2.h>
|
#include <openssl/e_os2.h>
|
||||||
# include <openssl/crypto.h>
|
#include <openssl/crypto.h>
|
||||||
# include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
# include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
# include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
# include <openssl/bn.h>
|
#include <openssl/bn.h>
|
||||||
# include <openssl/x509v3.h>
|
#include <openssl/x509v3.h>
|
||||||
# include <openssl/rand.h>
|
#include <openssl/rand.h>
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(OCSP_CERTID)
|
||||||
|
DEFINE_STACK_OF(CONF_VALUE)
|
||||||
|
DEFINE_STACK_OF(X509)
|
||||||
|
DEFINE_STACK_OF_STRING()
|
||||||
|
|
||||||
#ifndef HAVE_FORK
|
#ifndef HAVE_FORK
|
||||||
# if defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_WINDOWS)
|
# if defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_WINDOWS)
|
||||||
@@ -50,7 +52,7 @@ NON_EMPTY_TRANSLATION_UNIT
|
|||||||
# define NO_FORK
|
# define NO_FORK
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# if !defined(NO_FORK) && !defined(OPENSSL_NO_SOCK) \
|
#if !defined(NO_FORK) && !defined(OPENSSL_NO_SOCK) \
|
||||||
&& !defined(OPENSSL_NO_POSIX_IO)
|
&& !defined(OPENSSL_NO_POSIX_IO)
|
||||||
# define OCSP_DAEMON
|
# define OCSP_DAEMON
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
@@ -58,16 +60,16 @@ NON_EMPTY_TRANSLATION_UNIT
|
|||||||
# include <syslog.h>
|
# include <syslog.h>
|
||||||
# include <signal.h>
|
# include <signal.h>
|
||||||
# define MAXERRLEN 1000 /* limit error text sent to syslog to 1000 bytes */
|
# define MAXERRLEN 1000 /* limit error text sent to syslog to 1000 bytes */
|
||||||
# else
|
#else
|
||||||
# undef LOG_INFO
|
# undef LOG_INFO
|
||||||
# undef LOG_WARNING
|
# undef LOG_WARNING
|
||||||
# undef LOG_ERR
|
# undef LOG_ERR
|
||||||
# define LOG_INFO 0
|
# define LOG_INFO 0
|
||||||
# define LOG_WARNING 1
|
# define LOG_WARNING 1
|
||||||
# define LOG_ERR 2
|
# define LOG_ERR 2
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
# if defined(OPENSSL_SYS_VXWORKS)
|
#if defined(OPENSSL_SYS_VXWORKS)
|
||||||
/* not supported */
|
/* not supported */
|
||||||
int setpgid(pid_t pid, pid_t pgid)
|
int setpgid(pid_t pid, pid_t pgid)
|
||||||
{
|
{
|
||||||
@@ -80,9 +82,9 @@ pid_t fork(void)
|
|||||||
errno = ENOSYS;
|
errno = ENOSYS;
|
||||||
return (pid_t) -1;
|
return (pid_t) -1;
|
||||||
}
|
}
|
||||||
# endif
|
#endif
|
||||||
/* Maximum leeway in validity period: default 5 minutes */
|
/* Maximum leeway in validity period: default 5 minutes */
|
||||||
# define MAX_VALIDITY_PERIOD (5 * 60)
|
#define MAX_VALIDITY_PERIOD (5 * 60)
|
||||||
|
|
||||||
static int add_ocsp_cert(OCSP_REQUEST **req, X509 *cert,
|
static int add_ocsp_cert(OCSP_REQUEST **req, X509 *cert,
|
||||||
const EVP_MD *cert_id_md, X509 *issuer,
|
const EVP_MD *cert_id_md, X509 *issuer,
|
||||||
@@ -110,13 +112,13 @@ static void log_message(int level, const char *fmt, ...);
|
|||||||
static char *prog;
|
static char *prog;
|
||||||
static int multi = 0;
|
static int multi = 0;
|
||||||
|
|
||||||
# ifdef OCSP_DAEMON
|
#ifdef OCSP_DAEMON
|
||||||
static int acfd = (int) INVALID_SOCKET;
|
static int acfd = (int) INVALID_SOCKET;
|
||||||
static int index_changed(CA_DB *);
|
static int index_changed(CA_DB *);
|
||||||
static void spawn_loop(void);
|
static void spawn_loop(void);
|
||||||
static int print_syslog(const char *str, size_t len, void *levPtr);
|
static int print_syslog(const char *str, size_t len, void *levPtr);
|
||||||
static void socket_timeout(int signum);
|
static void socket_timeout(int signum);
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
typedef enum OPTION_choice {
|
typedef enum OPTION_choice {
|
||||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||||
@@ -160,9 +162,9 @@ const OPTIONS ocsp_options[] = {
|
|||||||
"Connection timeout (in seconds) to the OCSP responder"},
|
"Connection timeout (in seconds) to the OCSP responder"},
|
||||||
{"resp_no_certs", OPT_RESP_NO_CERTS, '-',
|
{"resp_no_certs", OPT_RESP_NO_CERTS, '-',
|
||||||
"Don't include any certificates in response"},
|
"Don't include any certificates in response"},
|
||||||
# ifdef OCSP_DAEMON
|
#ifdef OCSP_DAEMON
|
||||||
{"multi", OPT_MULTI, 'p', "run multiple responder processes"},
|
{"multi", OPT_MULTI, 'p', "run multiple responder processes"},
|
||||||
# endif
|
#endif
|
||||||
{"no_certs", OPT_NO_CERTS, '-',
|
{"no_certs", OPT_NO_CERTS, '-',
|
||||||
"Don't include any certificates in signed request"},
|
"Don't include any certificates in signed request"},
|
||||||
{"badsig", OPT_BADSIG, '-',
|
{"badsig", OPT_BADSIG, '-',
|
||||||
@@ -538,9 +540,9 @@ int ocsp_main(int argc, char **argv)
|
|||||||
trailing_md = 1;
|
trailing_md = 1;
|
||||||
break;
|
break;
|
||||||
case OPT_MULTI:
|
case OPT_MULTI:
|
||||||
# ifdef OCSP_DAEMON
|
#ifdef OCSP_DAEMON
|
||||||
multi = atoi(opt_arg());
|
multi = atoi(opt_arg());
|
||||||
# endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case OPT_PROV_CASES:
|
case OPT_PROV_CASES:
|
||||||
if (!opt_provider(o))
|
if (!opt_provider(o))
|
||||||
@@ -628,7 +630,7 @@ int ocsp_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef OCSP_DAEMON
|
#ifdef OCSP_DAEMON
|
||||||
if (multi && acbio != NULL)
|
if (multi && acbio != NULL)
|
||||||
spawn_loop();
|
spawn_loop();
|
||||||
if (acbio != NULL && req_timeout > 0)
|
if (acbio != NULL && req_timeout > 0)
|
||||||
@@ -641,7 +643,7 @@ int ocsp_main(int argc, char **argv)
|
|||||||
redo_accept:
|
redo_accept:
|
||||||
|
|
||||||
if (acbio != NULL) {
|
if (acbio != NULL) {
|
||||||
# ifdef OCSP_DAEMON
|
#ifdef OCSP_DAEMON
|
||||||
if (index_changed(rdb)) {
|
if (index_changed(rdb)) {
|
||||||
CA_DB *newrdb = load_index(ridx_filename, NULL);
|
CA_DB *newrdb = load_index(ridx_filename, NULL);
|
||||||
|
|
||||||
@@ -654,7 +656,7 @@ redo_accept:
|
|||||||
ridx_filename);
|
ridx_filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
req = NULL;
|
req = NULL;
|
||||||
if (!do_responder(&req, &cbio, acbio, req_timeout))
|
if (!do_responder(&req, &cbio, acbio, req_timeout))
|
||||||
@@ -724,16 +726,16 @@ redo_accept:
|
|||||||
if (cbio != NULL)
|
if (cbio != NULL)
|
||||||
send_ocsp_response(cbio, resp);
|
send_ocsp_response(cbio, resp);
|
||||||
} else if (host != NULL) {
|
} else if (host != NULL) {
|
||||||
# ifndef OPENSSL_NO_SOCK
|
#ifndef OPENSSL_NO_SOCK
|
||||||
resp = process_responder(req, host, path,
|
resp = process_responder(req, host, path,
|
||||||
port, use_ssl, headers, req_timeout);
|
port, use_ssl, headers, req_timeout);
|
||||||
if (resp == NULL)
|
if (resp == NULL)
|
||||||
goto end;
|
goto end;
|
||||||
# else
|
#else
|
||||||
BIO_printf(bio_err,
|
BIO_printf(bio_err,
|
||||||
"Error creating connect BIO - sockets not supported.\n");
|
"Error creating connect BIO - sockets not supported.\n");
|
||||||
goto end;
|
goto end;
|
||||||
# endif
|
#endif
|
||||||
} else if (respin != NULL) {
|
} else if (respin != NULL) {
|
||||||
derbio = bio_open_default(respin, 'r', FORMAT_ASN1);
|
derbio = bio_open_default(respin, 'r', FORMAT_ASN1);
|
||||||
if (derbio == NULL)
|
if (derbio == NULL)
|
||||||
@@ -877,7 +879,7 @@ log_message(int level, const char *fmt, ...)
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
# ifdef OCSP_DAEMON
|
#ifdef OCSP_DAEMON
|
||||||
if (multi) {
|
if (multi) {
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
if (vsnprintf(buf, sizeof(buf), fmt, ap) > 0) {
|
if (vsnprintf(buf, sizeof(buf), fmt, ap) > 0) {
|
||||||
@@ -886,7 +888,7 @@ log_message(int level, const char *fmt, ...)
|
|||||||
if (level >= LOG_ERR)
|
if (level >= LOG_ERR)
|
||||||
ERR_print_errors_cb(print_syslog, &level);
|
ERR_print_errors_cb(print_syslog, &level);
|
||||||
}
|
}
|
||||||
# endif
|
#endif
|
||||||
if (!multi) {
|
if (!multi) {
|
||||||
BIO_printf(bio_err, "%s: ", prog);
|
BIO_printf(bio_err, "%s: ", prog);
|
||||||
BIO_vprintf(bio_err, fmt, ap);
|
BIO_vprintf(bio_err, fmt, ap);
|
||||||
@@ -895,7 +897,7 @@ log_message(int level, const char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef OCSP_DAEMON
|
#ifdef OCSP_DAEMON
|
||||||
|
|
||||||
static int print_syslog(const char *str, size_t len, void *levPtr)
|
static int print_syslog(const char *str, size_t len, void *levPtr)
|
||||||
{
|
{
|
||||||
@@ -1048,7 +1050,7 @@ static void spawn_loop(void)
|
|||||||
syslog(LOG_INFO, "terminating on signal: %d", termsig);
|
syslog(LOG_INFO, "terminating on signal: %d", termsig);
|
||||||
killall(0, kidpids);
|
killall(0, kidpids);
|
||||||
}
|
}
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
static int add_ocsp_cert(OCSP_REQUEST **req, X509 *cert,
|
static int add_ocsp_cert(OCSP_REQUEST **req, X509 *cert,
|
||||||
const EVP_MD *cert_id_md, X509 *issuer,
|
const EVP_MD *cert_id_md, X509 *issuer,
|
||||||
@@ -1081,7 +1083,7 @@ static int add_ocsp_serial(OCSP_REQUEST **req, char *serial,
|
|||||||
STACK_OF(OCSP_CERTID) *ids)
|
STACK_OF(OCSP_CERTID) *ids)
|
||||||
{
|
{
|
||||||
OCSP_CERTID *id;
|
OCSP_CERTID *id;
|
||||||
X509_NAME *iname;
|
const X509_NAME *iname;
|
||||||
ASN1_BIT_STRING *ikey;
|
ASN1_BIT_STRING *ikey;
|
||||||
ASN1_INTEGER *sno;
|
ASN1_INTEGER *sno;
|
||||||
|
|
||||||
@@ -1338,11 +1340,11 @@ static char **lookup_serial(CA_DB *db, ASN1_INTEGER *ser)
|
|||||||
|
|
||||||
static BIO *init_responder(const char *port)
|
static BIO *init_responder(const char *port)
|
||||||
{
|
{
|
||||||
# ifdef OPENSSL_NO_SOCK
|
#ifdef OPENSSL_NO_SOCK
|
||||||
BIO_printf(bio_err,
|
BIO_printf(bio_err,
|
||||||
"Error setting up accept BIO - sockets not supported.\n");
|
"Error setting up accept BIO - sockets not supported.\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
# else
|
#else
|
||||||
BIO *acbio = NULL, *bufbio = NULL;
|
BIO *acbio = NULL, *bufbio = NULL;
|
||||||
|
|
||||||
bufbio = BIO_new(BIO_f_buffer());
|
bufbio = BIO_new(BIO_f_buffer());
|
||||||
@@ -1369,10 +1371,10 @@ static BIO *init_responder(const char *port)
|
|||||||
BIO_free_all(acbio);
|
BIO_free_all(acbio);
|
||||||
BIO_free(bufbio);
|
BIO_free(bufbio);
|
||||||
return NULL;
|
return NULL;
|
||||||
# endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_SOCK
|
#ifndef OPENSSL_NO_SOCK
|
||||||
/*
|
/*
|
||||||
* Decode %xx URL-decoding in-place. Ignores mal-formed sequences.
|
* Decode %xx URL-decoding in-place. Ignores mal-formed sequences.
|
||||||
*/
|
*/
|
||||||
@@ -1396,22 +1398,22 @@ static int urldecode(char *p)
|
|||||||
*out = '\0';
|
*out = '\0';
|
||||||
return (int)(out - save);
|
return (int)(out - save);
|
||||||
}
|
}
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
# ifdef OCSP_DAEMON
|
#ifdef OCSP_DAEMON
|
||||||
static void socket_timeout(int signum)
|
static void socket_timeout(int signum)
|
||||||
{
|
{
|
||||||
if (acfd != (int)INVALID_SOCKET)
|
if (acfd != (int)INVALID_SOCKET)
|
||||||
(void)shutdown(acfd, SHUT_RD);
|
(void)shutdown(acfd, SHUT_RD);
|
||||||
}
|
}
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio,
|
static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio,
|
||||||
int timeout)
|
int timeout)
|
||||||
{
|
{
|
||||||
# ifdef OPENSSL_NO_SOCK
|
#ifdef OPENSSL_NO_SOCK
|
||||||
return 0;
|
return 0;
|
||||||
# else
|
#else
|
||||||
int len;
|
int len;
|
||||||
OCSP_REQUEST *req = NULL;
|
OCSP_REQUEST *req = NULL;
|
||||||
char inbuf[2048], reqbuf[2048];
|
char inbuf[2048], reqbuf[2048];
|
||||||
@@ -1523,7 +1525,7 @@ out:
|
|||||||
acfd = (int)INVALID_SOCKET;
|
acfd = (int)INVALID_SOCKET;
|
||||||
# endif
|
# endif
|
||||||
return 1;
|
return 1;
|
||||||
# endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int send_ocsp_response(BIO *cbio, OCSP_RESPONSE *resp)
|
static int send_ocsp_response(BIO *cbio, OCSP_RESPONSE *resp)
|
||||||
@@ -1539,7 +1541,7 @@ static int send_ocsp_response(BIO *cbio, OCSP_RESPONSE *resp)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_SOCK
|
#ifndef OPENSSL_NO_SOCK
|
||||||
OCSP_RESPONSE *process_responder(OCSP_REQUEST *req,
|
OCSP_RESPONSE *process_responder(OCSP_REQUEST *req,
|
||||||
const char *host, const char *path,
|
const char *host, const char *path,
|
||||||
const char *port, int use_ssl,
|
const char *port, int use_ssl,
|
||||||
@@ -1571,6 +1573,4 @@ OCSP_RESPONSE *process_responder(OCSP_REQUEST *req,
|
|||||||
SSL_CTX_free(ctx);
|
SSL_CTX_free(ctx);
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
# endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+12
-8
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -47,12 +47,15 @@ BIO *bio_in = NULL;
|
|||||||
BIO *bio_out = NULL;
|
BIO *bio_out = NULL;
|
||||||
BIO *bio_err = NULL;
|
BIO *bio_err = NULL;
|
||||||
|
|
||||||
static void warn_deprecated(const char *pname,
|
static void warn_deprecated(const FUNCTION *fp)
|
||||||
const char *deprecated_alternative)
|
|
||||||
{
|
{
|
||||||
BIO_printf(bio_err, "The command %s is deprecated.", pname);
|
if (fp->deprecated_version != NULL)
|
||||||
if (strcmp(deprecated_alternative, DEPRECATED_NO_ALTERNATIVE) != 0)
|
BIO_printf(bio_err, "The command %s was deprecated in version %s.",
|
||||||
BIO_printf(bio_err, " Use '%s' instead.", deprecated_alternative);
|
fp->name, fp->deprecated_version);
|
||||||
|
else
|
||||||
|
BIO_printf(bio_err, "The command %s is deprecated.", fp->name);
|
||||||
|
if (strcmp(fp->deprecated_alternative, DEPRECATED_NO_ALTERNATIVE) != 0)
|
||||||
|
BIO_printf(bio_err, " Use '%s' instead.", fp->deprecated_alternative);
|
||||||
BIO_printf(bio_err, "\n");
|
BIO_printf(bio_err, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,7 +290,7 @@ int main(int argc, char *argv[])
|
|||||||
if (fp != NULL) {
|
if (fp != NULL) {
|
||||||
argv[0] = pname;
|
argv[0] = pname;
|
||||||
if (fp->deprecated_alternative != NULL)
|
if (fp->deprecated_alternative != NULL)
|
||||||
warn_deprecated(pname, fp->deprecated_alternative);
|
warn_deprecated(fp);
|
||||||
ret = fp->func(argc, argv);
|
ret = fp->func(argc, argv);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
@@ -368,6 +371,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
ret = 1;
|
ret = 1;
|
||||||
end:
|
end:
|
||||||
|
app_providers_cleanup();
|
||||||
OPENSSL_free(default_config_file);
|
OPENSSL_free(default_config_file);
|
||||||
lh_FUNCTION_free(prog);
|
lh_FUNCTION_free(prog);
|
||||||
OPENSSL_free(arg.argv);
|
OPENSSL_free(arg.argv);
|
||||||
@@ -482,7 +486,7 @@ static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
if (fp != NULL) {
|
if (fp != NULL) {
|
||||||
if (fp->deprecated_alternative != NULL)
|
if (fp->deprecated_alternative != NULL)
|
||||||
warn_deprecated(fp->name, fp->deprecated_alternative);
|
warn_deprecated(fp);
|
||||||
return fp->func(argc, argv);
|
return fp->func(argc, argv);
|
||||||
}
|
}
|
||||||
if ((strncmp(argv[0], "no-", 3)) == 0) {
|
if ((strncmp(argv[0], "no-", 3)) == 0) {
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
+29
-28
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -8,25 +8,28 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <openssl/opensslconf.h>
|
#include <openssl/opensslconf.h>
|
||||||
#if defined(OPENSSL_NO_DES)
|
|
||||||
NON_EMPTY_TRANSLATION_UNIT
|
|
||||||
#else
|
|
||||||
|
|
||||||
# include <stdio.h>
|
#include <stdio.h>
|
||||||
# include <stdlib.h>
|
#include <stdlib.h>
|
||||||
# include <string.h>
|
#include <string.h>
|
||||||
# include "apps.h"
|
#include "apps.h"
|
||||||
# include "progs.h"
|
#include "progs.h"
|
||||||
# include <openssl/crypto.h>
|
#include <openssl/crypto.h>
|
||||||
# include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
# include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
# include <openssl/pkcs12.h>
|
#include <openssl/pkcs12.h>
|
||||||
|
|
||||||
# define NOKEYS 0x1
|
DEFINE_STACK_OF(X509)
|
||||||
# define NOCERTS 0x2
|
DEFINE_STACK_OF(PKCS7)
|
||||||
# define INFO 0x4
|
DEFINE_STACK_OF(PKCS12_SAFEBAG)
|
||||||
# define CLCERTS 0x8
|
DEFINE_STACK_OF(X509_ATTRIBUTE)
|
||||||
# define CACERTS 0x10
|
DEFINE_STACK_OF_STRING()
|
||||||
|
|
||||||
|
#define NOKEYS 0x1
|
||||||
|
#define NOCERTS 0x2
|
||||||
|
#define INFO 0x4
|
||||||
|
#define CLCERTS 0x8
|
||||||
|
#define CACERTS 0x10
|
||||||
|
|
||||||
#define PASSWD_BUF_SIZE 2048
|
#define PASSWD_BUF_SIZE 2048
|
||||||
|
|
||||||
@@ -64,9 +67,9 @@ typedef enum OPTION_choice {
|
|||||||
const OPTIONS pkcs12_options[] = {
|
const OPTIONS pkcs12_options[] = {
|
||||||
OPT_SECTION("General"),
|
OPT_SECTION("General"),
|
||||||
{"help", OPT_HELP, '-', "Display this summary"},
|
{"help", OPT_HELP, '-', "Display this summary"},
|
||||||
# ifndef OPENSSL_NO_ENGINE
|
#ifndef OPENSSL_NO_ENGINE
|
||||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
OPT_SECTION("CA"),
|
OPT_SECTION("CA"),
|
||||||
{"CApath", OPT_CAPATH, '/', "PEM-format directory of CA's"},
|
{"CApath", OPT_CAPATH, '/', "PEM-format directory of CA's"},
|
||||||
@@ -112,15 +115,15 @@ const OPTIONS pkcs12_options[] = {
|
|||||||
{"keysig", OPT_KEYSIG, '-', "Set MS key signature type"},
|
{"keysig", OPT_KEYSIG, '-', "Set MS key signature type"},
|
||||||
|
|
||||||
OPT_SECTION("Encryption"),
|
OPT_SECTION("Encryption"),
|
||||||
# ifndef OPENSSL_NO_RC2
|
#ifndef OPENSSL_NO_RC2
|
||||||
{"descert", OPT_DESCERT, '-',
|
{"descert", OPT_DESCERT, '-',
|
||||||
"Encrypt output with 3DES (default RC2-40)"},
|
"Encrypt output with 3DES (default RC2-40)"},
|
||||||
{"certpbe", OPT_CERTPBE, 's',
|
{"certpbe", OPT_CERTPBE, 's',
|
||||||
"Certificate PBE algorithm (default RC2-40)"},
|
"Certificate PBE algorithm (default RC2-40)"},
|
||||||
# else
|
#else
|
||||||
{"descert", OPT_DESCERT, '-', "Encrypt output with 3DES (the default)"},
|
{"descert", OPT_DESCERT, '-', "Encrypt output with 3DES (the default)"},
|
||||||
{"certpbe", OPT_CERTPBE, 's', "Certificate PBE algorithm (default 3DES)"},
|
{"certpbe", OPT_CERTPBE, 's', "Certificate PBE algorithm (default 3DES)"},
|
||||||
# endif
|
#endif
|
||||||
{"iter", OPT_ITER, 'p', "Specify the iteration count for encryption key and MAC"},
|
{"iter", OPT_ITER, 'p', "Specify the iteration count for encryption key and MAC"},
|
||||||
{"noiter", OPT_NOITER, '-', "Don't use encryption key iteration"},
|
{"noiter", OPT_NOITER, '-', "Don't use encryption key iteration"},
|
||||||
{"maciter", OPT_MACITER, '-', "Unused, kept for backwards compatibility"},
|
{"maciter", OPT_MACITER, '-', "Unused, kept for backwards compatibility"},
|
||||||
@@ -141,11 +144,11 @@ int pkcs12_main(int argc, char **argv)
|
|||||||
char pass[PASSWD_BUF_SIZE] = "", macpass[PASSWD_BUF_SIZE] = "";
|
char pass[PASSWD_BUF_SIZE] = "", macpass[PASSWD_BUF_SIZE] = "";
|
||||||
int export_cert = 0, options = 0, chain = 0, twopass = 0, keytype = 0;
|
int export_cert = 0, options = 0, chain = 0, twopass = 0, keytype = 0;
|
||||||
int iter = PKCS12_DEFAULT_ITER, maciter = PKCS12_DEFAULT_ITER;
|
int iter = PKCS12_DEFAULT_ITER, maciter = PKCS12_DEFAULT_ITER;
|
||||||
# ifndef OPENSSL_NO_RC2
|
#ifndef OPENSSL_NO_RC2
|
||||||
int cert_pbe = NID_pbe_WithSHA1And40BitRC2_CBC;
|
int cert_pbe = NID_pbe_WithSHA1And40BitRC2_CBC;
|
||||||
# else
|
#else
|
||||||
int cert_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;
|
int cert_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;
|
||||||
# endif
|
#endif
|
||||||
int key_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;
|
int key_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;
|
||||||
int ret = 1, macver = 1, add_lmk = 0, private = 0;
|
int ret = 1, macver = 1, add_lmk = 0, private = 0;
|
||||||
int noprompt = 0;
|
int noprompt = 0;
|
||||||
@@ -1008,5 +1011,3 @@ static int set_pbe(int *ppbe, const char *str)
|
|||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
+4
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -20,6 +20,9 @@
|
|||||||
#include <openssl/pkcs7.h>
|
#include <openssl/pkcs7.h>
|
||||||
#include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(X509)
|
||||||
|
DEFINE_STACK_OF(X509_CRL)
|
||||||
|
|
||||||
typedef enum OPTION_choice {
|
typedef enum OPTION_choice {
|
||||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||||
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_NOOUT,
|
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_NOOUT,
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
+3
-17
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -15,6 +15,8 @@
|
|||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
DEFINE_STACK_OF_STRING()
|
||||||
|
|
||||||
#define KEY_NONE 0
|
#define KEY_NONE 0
|
||||||
#define KEY_PRIVKEY 1
|
#define KEY_PRIVKEY 1
|
||||||
#define KEY_PUBKEY 2
|
#define KEY_PUBKEY 2
|
||||||
@@ -550,22 +552,6 @@ static EVP_PKEY_CTX *init_ctx(const char *kdfalg, int *pkeysize,
|
|||||||
if (pkey == NULL)
|
if (pkey == NULL)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_EC
|
|
||||||
/* SM2 needs a special treatment */
|
|
||||||
if (EVP_PKEY_id(pkey) == EVP_PKEY_EC) {
|
|
||||||
EC_KEY *eckey = NULL;
|
|
||||||
const EC_GROUP *group = NULL;
|
|
||||||
int nid;
|
|
||||||
|
|
||||||
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))
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
*pkeysize = EVP_PKEY_size(pkey);
|
*pkeysize = EVP_PKEY_size(pkey);
|
||||||
ctx = EVP_PKEY_CTX_new(pkey, impl);
|
ctx = EVP_PKEY_CTX_new(pkey, impl);
|
||||||
if (ppkey != NULL)
|
if (ppkey != NULL)
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2004-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
+30
-17
@@ -1,5 +1,5 @@
|
|||||||
#! /usr/bin/env perl
|
#! /usr/bin/env perl
|
||||||
# Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
# Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
# this file except in compliance with the License. You can obtain a copy
|
# this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -92,35 +92,48 @@ EOF
|
|||||||
|
|
||||||
my %cmd_disabler = (
|
my %cmd_disabler = (
|
||||||
ciphers => "sock",
|
ciphers => "sock",
|
||||||
|
genrsa => "rsa",
|
||||||
|
gendsa => "dsa",
|
||||||
|
dsaparam => "dsa",
|
||||||
|
gendh => "dh",
|
||||||
|
dhparam => "dh",
|
||||||
|
ecparam => "ec",
|
||||||
pkcs12 => "des",
|
pkcs12 => "des",
|
||||||
);
|
);
|
||||||
my %cmd_deprecated = (
|
my %cmd_deprecated = (
|
||||||
rsa => [ "3_0", "pkey", "rsa" ],
|
# The format of this table is:
|
||||||
genrsa => [ "3_0", "genpkey", "rsa" ],
|
# [0] = alternative command to use instead
|
||||||
rsautl => [ "3_0", "pkeyutl", "rsa" ],
|
# [1] = deprecented in this version
|
||||||
dhparam => [ "3_0", "pkeyparam", "dh" ],
|
# [2] = preprocessor conditional for exclusing irrespective of deprecation
|
||||||
dsaparam => [ "3_0", "pkeyparam", "dsa" ],
|
# rsa => [ "pkey", "3_0", "rsa" ],
|
||||||
dsa => [ "3_0", "pkey", "dsa" ],
|
# genrsa => [ "genpkey", "3_0", "rsa" ],
|
||||||
gendsa => [ "3_0", "genpkey", "dsa" ],
|
rsautl => [ "pkeyutl", "3_0", "rsa" ],
|
||||||
ec => [ "3_0", "pkey", "ec" ],
|
# dhparam => [ "pkeyparam", "3_0", "dh" ],
|
||||||
ecparam => [ "3_0", "pkeyparam", "ec" ],
|
# dsaparam => [ "pkeyparam", "3_0", "dsa" ],
|
||||||
|
# dsa => [ "pkey", "3_0", "dsa" ],
|
||||||
|
# gendsa => [ "genpkey", "3_0", "dsa" ],
|
||||||
|
# ec => [ "pkey", "3_0", "ec" ],
|
||||||
|
# ecparam => [ "pkeyparam", "3_0", "ec" ],
|
||||||
);
|
);
|
||||||
|
|
||||||
print "FUNCTION functions[] = {\n";
|
print "FUNCTION functions[] = {\n";
|
||||||
foreach my $cmd ( @ARGV ) {
|
foreach my $cmd ( @ARGV ) {
|
||||||
my $str =
|
my $str =
|
||||||
" {FT_general, \"$cmd\", ${cmd}_main, ${cmd}_options, NULL},\n";
|
" {FT_general, \"$cmd\", ${cmd}_main, ${cmd}_options, NULL, NULL},\n";
|
||||||
if ($cmd =~ /^s_/) {
|
if ($cmd =~ /^s_/) {
|
||||||
print "#ifndef OPENSSL_NO_SOCK\n${str}#endif\n";
|
print "#ifndef OPENSSL_NO_SOCK\n${str}#endif\n";
|
||||||
} elsif (my $deprecated = $cmd_deprecated{$cmd}) {
|
} elsif (my $deprecated = $cmd_deprecated{$cmd}) {
|
||||||
my @dep = @{$deprecated};
|
my @dep = @{$deprecated};
|
||||||
print "#if ";
|
my $daltprg = $dep[0];
|
||||||
if ($dep[2]) {
|
my $dver = $dep[1];
|
||||||
print "!defined(OPENSSL_NO_" . uc($dep[2]) . ") && ";
|
my $dsys = $dep[2];
|
||||||
|
print "#if !defined(OPENSSL_NO_DEPRECATED_" . $dver . ")";
|
||||||
|
if ($dsys) {
|
||||||
|
print " && !defined(OPENSSL_NO_" . uc($dsys) . ")";
|
||||||
}
|
}
|
||||||
print "!defined(OPENSSL_NO_DEPRECATED_" . $dep[0] . ")";
|
$dver =~ s/_/./g;
|
||||||
my $dalt = "\"" . $dep[1] . "\"";
|
my $dalt = "\"" . $daltprg . "\", \"" . $dver . "\"";
|
||||||
$str =~ s/NULL/$dalt/;
|
$str =~ s/NULL, NULL/$dalt/;
|
||||||
print "\n${str}#endif\n";
|
print "\n${str}#endif\n";
|
||||||
} elsif (grep { $cmd eq $_ } @disablables) {
|
} elsif (grep { $cmd eq $_ } @disablables) {
|
||||||
print "#ifndef OPENSSL_NO_" . uc($cmd) . "\n${str}#endif\n";
|
print "#ifndef OPENSSL_NO_" . uc($cmd) . "\n${str}#endif\n";
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
#include <openssl/core.h>
|
#include <openssl/core.h>
|
||||||
#include <openssl/core_numbers.h>
|
#include <openssl/core_numbers.h>
|
||||||
|
|
||||||
|
DEFINE_STACK_OF_CSTRING()
|
||||||
|
|
||||||
typedef enum OPTION_choice {
|
typedef enum OPTION_choice {
|
||||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||||
OPT_V = 100, OPT_VV, OPT_VVV
|
OPT_V = 100, OPT_VV, OPT_VVV
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1998-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1998-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
+14
-4
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
* Copyright (c) 2013-2014 Timo Teräs <timo.teras@gmail.com>
|
* Copyright (c) 2013-2014 Timo Teräs <timo.teras@gmail.com>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
@@ -42,6 +42,8 @@
|
|||||||
# include <openssl/pem.h>
|
# include <openssl/pem.h>
|
||||||
# include <openssl/x509.h>
|
# include <openssl/x509.h>
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(X509_INFO)
|
||||||
|
DEFINE_STACK_OF_STRING()
|
||||||
|
|
||||||
# ifndef PATH_MAX
|
# ifndef PATH_MAX
|
||||||
# define PATH_MAX 4096
|
# define PATH_MAX 4096
|
||||||
@@ -233,7 +235,7 @@ static int do_file(const char *filename, const char *fullpath, enum Hash h)
|
|||||||
{
|
{
|
||||||
STACK_OF (X509_INFO) *inf = NULL;
|
STACK_OF (X509_INFO) *inf = NULL;
|
||||||
X509_INFO *x;
|
X509_INFO *x;
|
||||||
X509_NAME *name = NULL;
|
const X509_NAME *name = NULL;
|
||||||
BIO *b;
|
BIO *b;
|
||||||
const char *ext;
|
const char *ext;
|
||||||
unsigned char digest[EVP_MAX_MD_SIZE];
|
unsigned char digest[EVP_MAX_MD_SIZE];
|
||||||
@@ -274,11 +276,19 @@ static int do_file(const char *filename, const char *fullpath, enum Hash h)
|
|||||||
if (x->x509 != NULL) {
|
if (x->x509 != NULL) {
|
||||||
type = TYPE_CERT;
|
type = TYPE_CERT;
|
||||||
name = X509_get_subject_name(x->x509);
|
name = X509_get_subject_name(x->x509);
|
||||||
X509_digest(x->x509, evpmd, digest, NULL);
|
if (!X509_digest(x->x509, evpmd, digest, NULL)) {
|
||||||
|
BIO_printf(bio_err, "out of memory\n");
|
||||||
|
++errs;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
} else if (x->crl != NULL) {
|
} else if (x->crl != NULL) {
|
||||||
type = TYPE_CRL;
|
type = TYPE_CRL;
|
||||||
name = X509_CRL_get_issuer(x->crl);
|
name = X509_CRL_get_issuer(x->crl);
|
||||||
X509_CRL_digest(x->crl, evpmd, digest, NULL);
|
if (!X509_CRL_digest(x->crl, evpmd, digest, NULL)) {
|
||||||
|
BIO_printf(bio_err, "out of memory\n");
|
||||||
|
++errs;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
++errs;
|
++errs;
|
||||||
goto end;
|
goto end;
|
||||||
|
|||||||
+106
-141
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -32,6 +32,8 @@
|
|||||||
# include <openssl/dsa.h>
|
# include <openssl/dsa.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(CONF_VALUE)
|
||||||
|
DEFINE_STACK_OF_STRING()
|
||||||
|
|
||||||
#define BITS "default_bits"
|
#define BITS "default_bits"
|
||||||
#define KEYFILE "default_keyfile"
|
#define KEYFILE "default_keyfile"
|
||||||
@@ -87,11 +89,11 @@ typedef enum OPTION_choice {
|
|||||||
OPT_INFORM, OPT_OUTFORM, OPT_ENGINE, OPT_KEYGEN_ENGINE, OPT_KEY,
|
OPT_INFORM, OPT_OUTFORM, OPT_ENGINE, OPT_KEYGEN_ENGINE, OPT_KEY,
|
||||||
OPT_PUBKEY, OPT_NEW, OPT_CONFIG, OPT_KEYFORM, OPT_IN, OPT_OUT,
|
OPT_PUBKEY, OPT_NEW, OPT_CONFIG, OPT_KEYFORM, OPT_IN, OPT_OUT,
|
||||||
OPT_KEYOUT, OPT_PASSIN, OPT_PASSOUT, OPT_NEWKEY,
|
OPT_KEYOUT, OPT_PASSIN, OPT_PASSOUT, OPT_NEWKEY,
|
||||||
OPT_PKEYOPT, OPT_SIGOPT, OPT_BATCH, OPT_NEWHDR, OPT_MODULUS,
|
OPT_PKEYOPT, OPT_SIGOPT, OPT_VFYOPT, OPT_BATCH, OPT_NEWHDR, OPT_MODULUS,
|
||||||
OPT_VERIFY, OPT_NODES, OPT_NOOUT, OPT_VERBOSE, OPT_UTF8,
|
OPT_VERIFY, OPT_NODES, OPT_NOOUT, OPT_VERBOSE, OPT_UTF8,
|
||||||
OPT_NAMEOPT, OPT_REQOPT, OPT_SUBJ, OPT_SUBJECT, OPT_TEXT, OPT_X509,
|
OPT_NAMEOPT, OPT_REQOPT, OPT_SUBJ, OPT_SUBJECT, OPT_TEXT, OPT_X509,
|
||||||
OPT_MULTIVALUE_RDN, OPT_DAYS, OPT_SET_SERIAL, OPT_ADDEXT, OPT_EXTENSIONS,
|
OPT_MULTIVALUE_RDN, OPT_DAYS, OPT_SET_SERIAL, OPT_ADDEXT, OPT_EXTENSIONS,
|
||||||
OPT_REQEXTS, OPT_PRECERT, OPT_MD, OPT_SM2ID, OPT_SM2HEXID,
|
OPT_REQEXTS, OPT_PRECERT, OPT_MD,
|
||||||
OPT_SECTION,
|
OPT_SECTION,
|
||||||
OPT_R_ENUM, OPT_PROV_ENUM
|
OPT_R_ENUM, OPT_PROV_ENUM
|
||||||
} OPTION_CHOICE;
|
} OPTION_CHOICE;
|
||||||
@@ -113,7 +115,7 @@ const OPTIONS req_options[] = {
|
|||||||
{"config", OPT_CONFIG, '<', "Request template file"},
|
{"config", OPT_CONFIG, '<', "Request template file"},
|
||||||
{"section", OPT_SECTION, 's', "Config section to use (default \"req\")"},
|
{"section", OPT_SECTION, 's', "Config section to use (default \"req\")"},
|
||||||
{"utf8", OPT_UTF8, '-', "Input characters are UTF8 (default ASCII)"},
|
{"utf8", OPT_UTF8, '-', "Input characters are UTF8 (default ASCII)"},
|
||||||
{"nameopt", OPT_NAMEOPT, 's', "Various certificate name options"},
|
{"nameopt", OPT_NAMEOPT, 's', "Certificate subject/issuer name printing options"},
|
||||||
{"reqopt", OPT_REQOPT, 's', "Various request text options"},
|
{"reqopt", OPT_REQOPT, 's', "Various request text options"},
|
||||||
{"text", OPT_TEXT, '-', "Text form of request"},
|
{"text", OPT_TEXT, '-', "Text form of request"},
|
||||||
{"x509", OPT_X509, '-',
|
{"x509", OPT_X509, '-',
|
||||||
@@ -143,13 +145,8 @@ const OPTIONS req_options[] = {
|
|||||||
{"newkey", OPT_NEWKEY, 's', "Specify as type:bits"},
|
{"newkey", OPT_NEWKEY, 's', "Specify as type:bits"},
|
||||||
{"pkeyopt", OPT_PKEYOPT, 's', "Public key options as opt:value"},
|
{"pkeyopt", OPT_PKEYOPT, 's', "Public key options as opt:value"},
|
||||||
{"sigopt", OPT_SIGOPT, 's', "Signature parameter in n:v form"},
|
{"sigopt", OPT_SIGOPT, 's', "Signature parameter in n:v form"},
|
||||||
|
{"vfyopt", OPT_VFYOPT, 's', "Verification parameter in n:v form"},
|
||||||
{"", OPT_MD, '-', "Any supported digest"},
|
{"", OPT_MD, '-', "Any supported digest"},
|
||||||
#ifndef OPENSSL_NO_SM2
|
|
||||||
{"sm2-id", OPT_SM2ID, 's',
|
|
||||||
"Specify an ID string to verify an SM2 certificate request"},
|
|
||||||
{"sm2-hex-id", OPT_SM2HEXID, 's',
|
|
||||||
"Specify a hex ID string to verify an SM2 certificate request"},
|
|
||||||
#endif
|
|
||||||
|
|
||||||
OPT_SECTION("Output"),
|
OPT_SECTION("Output"),
|
||||||
{"out", OPT_OUT, '>', "Output file"},
|
{"out", OPT_OUT, '>', "Output file"},
|
||||||
@@ -233,11 +230,11 @@ static int duplicated(LHASH_OF(OPENSSL_STRING) *addexts, char *kv)
|
|||||||
int req_main(int argc, char **argv)
|
int req_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
ASN1_INTEGER *serial = NULL;
|
ASN1_INTEGER *serial = NULL;
|
||||||
BIO *in = NULL, *out = NULL;
|
BIO *out = NULL;
|
||||||
ENGINE *e = NULL, *gen_eng = NULL;
|
ENGINE *e = NULL, *gen_eng = NULL;
|
||||||
EVP_PKEY *pkey = NULL;
|
EVP_PKEY *pkey = NULL;
|
||||||
EVP_PKEY_CTX *genctx = NULL;
|
EVP_PKEY_CTX *genctx = NULL;
|
||||||
STACK_OF(OPENSSL_STRING) *pkeyopts = NULL, *sigopts = NULL;
|
STACK_OF(OPENSSL_STRING) *pkeyopts = NULL, *sigopts = NULL, *vfyopts = NULL;
|
||||||
LHASH_OF(OPENSSL_STRING) *addexts = NULL;
|
LHASH_OF(OPENSSL_STRING) *addexts = NULL;
|
||||||
X509 *x509ss = NULL;
|
X509 *x509ss = NULL;
|
||||||
X509_REQ *req = NULL;
|
X509_REQ *req = NULL;
|
||||||
@@ -260,9 +257,6 @@ int req_main(int argc, char **argv)
|
|||||||
int nodes = 0, newhdr = 0, subject = 0, pubkey = 0, precert = 0;
|
int nodes = 0, newhdr = 0, subject = 0, pubkey = 0, precert = 0;
|
||||||
long newkey = -1;
|
long newkey = -1;
|
||||||
unsigned long chtype = MBSTRING_ASC, reqflag = 0;
|
unsigned long chtype = MBSTRING_ASC, reqflag = 0;
|
||||||
unsigned char *sm2_id = NULL;
|
|
||||||
size_t sm2_idlen = 0;
|
|
||||||
int sm2_free = 0;
|
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_DES
|
#ifndef OPENSSL_NO_DES
|
||||||
cipher = EVP_des_ede3_cbc();
|
cipher = EVP_des_ede3_cbc();
|
||||||
@@ -359,6 +353,12 @@ int req_main(int argc, char **argv)
|
|||||||
if (!sigopts || !sk_OPENSSL_STRING_push(sigopts, opt_arg()))
|
if (!sigopts || !sk_OPENSSL_STRING_push(sigopts, opt_arg()))
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
break;
|
break;
|
||||||
|
case OPT_VFYOPT:
|
||||||
|
if (!vfyopts)
|
||||||
|
vfyopts = sk_OPENSSL_STRING_new_null();
|
||||||
|
if (!vfyopts || !sk_OPENSSL_STRING_push(vfyopts, opt_arg()))
|
||||||
|
goto opthelp;
|
||||||
|
break;
|
||||||
case OPT_BATCH:
|
case OPT_BATCH:
|
||||||
batch = 1;
|
batch = 1;
|
||||||
break;
|
break;
|
||||||
@@ -446,29 +446,6 @@ int req_main(int argc, char **argv)
|
|||||||
goto opthelp;
|
goto opthelp;
|
||||||
digest = md_alg;
|
digest = md_alg;
|
||||||
break;
|
break;
|
||||||
case OPT_SM2ID:
|
|
||||||
if (sm2_id != NULL) {
|
|
||||||
BIO_printf(bio_err,
|
|
||||||
"Use one of the options 'sm2-hex-id' or 'sm2-id'\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
sm2_id = (unsigned char *)opt_arg();
|
|
||||||
sm2_idlen = strlen((const char *)sm2_id);
|
|
||||||
break;
|
|
||||||
case OPT_SM2HEXID:
|
|
||||||
if (sm2_id != NULL) {
|
|
||||||
BIO_printf(bio_err,
|
|
||||||
"Use one of the options 'sm2-hex-id' or 'sm2-id'\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
/* try to parse the input as hex string first */
|
|
||||||
sm2_free = 1;
|
|
||||||
sm2_id = OPENSSL_hexstr2buf(opt_arg(), (long *)&sm2_idlen);
|
|
||||||
if (sm2_id == NULL) {
|
|
||||||
BIO_printf(bio_err, "Invalid hex string input\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
argc = opt_num_rest();
|
argc = opt_num_rest();
|
||||||
@@ -492,7 +469,7 @@ int req_main(int argc, char **argv)
|
|||||||
BIO_printf(bio_err, "Using configuration from %s\n", template);
|
BIO_printf(bio_err, "Using configuration from %s\n", template);
|
||||||
if ((req_conf = app_load_config(template)) == NULL)
|
if ((req_conf = app_load_config(template)) == NULL)
|
||||||
goto end;
|
goto end;
|
||||||
if (addext_bio) {
|
if (addext_bio != NULL) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
BIO_printf(bio_err,
|
BIO_printf(bio_err,
|
||||||
"Using additional configuration from command line\n");
|
"Using additional configuration from command line\n");
|
||||||
@@ -613,13 +590,10 @@ int req_main(int argc, char **argv)
|
|||||||
|
|
||||||
if (keyfile != NULL) {
|
if (keyfile != NULL) {
|
||||||
pkey = load_key(keyfile, keyform, 0, passin, e, "Private Key");
|
pkey = load_key(keyfile, keyform, 0, passin, e, "Private Key");
|
||||||
if (pkey == NULL) {
|
if (pkey == NULL)
|
||||||
/* load_key() has already printed an appropriate message */
|
|
||||||
goto end;
|
goto end;
|
||||||
} else {
|
|
||||||
app_RAND_load_conf(req_conf, section);
|
app_RAND_load_conf(req_conf, section);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (newreq && (pkey == NULL)) {
|
if (newreq && (pkey == NULL)) {
|
||||||
app_RAND_load_conf(req_conf, section);
|
app_RAND_load_conf(req_conf, section);
|
||||||
@@ -738,18 +712,9 @@ int req_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!newreq) {
|
if (!newreq) {
|
||||||
in = bio_open_default(infile, 'r', informat);
|
req = load_csr(infile, informat, "X509 request");
|
||||||
if (in == NULL)
|
if (req == NULL)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
if (informat == FORMAT_ASN1)
|
|
||||||
req = d2i_X509_REQ_bio(in, NULL);
|
|
||||||
else
|
|
||||||
req = PEM_read_bio_X509_REQ(in, NULL, NULL, NULL);
|
|
||||||
if (req == NULL) {
|
|
||||||
BIO_printf(bio_err, "unable to load X509 request\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newreq || x509) {
|
if (newreq || x509) {
|
||||||
@@ -901,27 +866,7 @@ int req_main(int argc, char **argv)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sm2_id != NULL) {
|
i = do_X509_REQ_verify(req, tpubkey, vfyopts);
|
||||||
#ifndef OPENSSL_NO_SM2
|
|
||||||
ASN1_OCTET_STRING *v;
|
|
||||||
|
|
||||||
v = ASN1_OCTET_STRING_new();
|
|
||||||
if (v == NULL) {
|
|
||||||
BIO_printf(bio_err, "error: SM2 ID allocation failed\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ASN1_OCTET_STRING_set(v, sm2_id, sm2_idlen)) {
|
|
||||||
BIO_printf(bio_err, "error: setting SM2 ID failed\n");
|
|
||||||
ASN1_OCTET_STRING_free(v);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
X509_REQ_set0_sm2_id(req, v);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
i = X509_REQ_verify(req, tpubkey);
|
|
||||||
|
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
goto end;
|
goto end;
|
||||||
@@ -1029,20 +974,18 @@ int req_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
ret = 0;
|
ret = 0;
|
||||||
end:
|
end:
|
||||||
if (sm2_free)
|
|
||||||
OPENSSL_free(sm2_id);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
}
|
}
|
||||||
NCONF_free(req_conf);
|
NCONF_free(req_conf);
|
||||||
NCONF_free(addext_conf);
|
NCONF_free(addext_conf);
|
||||||
BIO_free(addext_bio);
|
BIO_free(addext_bio);
|
||||||
BIO_free(in);
|
|
||||||
BIO_free_all(out);
|
BIO_free_all(out);
|
||||||
EVP_PKEY_free(pkey);
|
EVP_PKEY_free(pkey);
|
||||||
EVP_PKEY_CTX_free(genctx);
|
EVP_PKEY_CTX_free(genctx);
|
||||||
sk_OPENSSL_STRING_free(pkeyopts);
|
sk_OPENSSL_STRING_free(pkeyopts);
|
||||||
sk_OPENSSL_STRING_free(sigopts);
|
sk_OPENSSL_STRING_free(sigopts);
|
||||||
|
sk_OPENSSL_STRING_free(vfyopts);
|
||||||
lh_OPENSSL_STRING_doall(addexts, exts_cleanup);
|
lh_OPENSSL_STRING_doall(addexts, exts_cleanup);
|
||||||
lh_OPENSSL_STRING_free(addexts);
|
lh_OPENSSL_STRING_free(addexts);
|
||||||
#ifndef OPENSSL_NO_ENGINE
|
#ifndef OPENSSL_NO_ENGINE
|
||||||
@@ -1153,8 +1096,7 @@ static int prompt_info(X509_REQ *req,
|
|||||||
char *type, *value;
|
char *type, *value;
|
||||||
const char *def;
|
const char *def;
|
||||||
CONF_VALUE *v;
|
CONF_VALUE *v;
|
||||||
X509_NAME *subj;
|
X509_NAME *subj = X509_REQ_get_subject_name(req);
|
||||||
subj = X509_REQ_get_subject_name(req);
|
|
||||||
|
|
||||||
if (!batch) {
|
if (!batch) {
|
||||||
BIO_printf(bio_err,
|
BIO_printf(bio_err,
|
||||||
@@ -1239,8 +1181,7 @@ static int prompt_info(X509_REQ *req,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (X509_NAME_entry_count(subj) == 0) {
|
if (X509_NAME_entry_count(subj) == 0) {
|
||||||
BIO_printf(bio_err,
|
BIO_printf(bio_err, "error, no objects specified in config file\n");
|
||||||
"error, no objects specified in config file\n");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1685,32 +1626,71 @@ static int genpkey_cb(EVP_PKEY_CTX *ctx)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int do_pkey_ctx_init(EVP_PKEY_CTX *pkctx, STACK_OF(OPENSSL_STRING) *opts)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (opts == NULL)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
for (i = 0; i < sk_OPENSSL_STRING_num(opts); i++) {
|
||||||
|
char *opt = sk_OPENSSL_STRING_value(opts, i);
|
||||||
|
if (pkey_ctrl_string(pkctx, opt) <= 0) {
|
||||||
|
BIO_printf(bio_err, "parameter error \"%s\"\n", opt);
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int do_x509_init(X509 *x, STACK_OF(OPENSSL_STRING) *opts)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (opts == NULL)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
for (i = 0; i < sk_OPENSSL_STRING_num(opts); i++) {
|
||||||
|
char *opt = sk_OPENSSL_STRING_value(opts, i);
|
||||||
|
if (x509_ctrl_string(x, opt) <= 0) {
|
||||||
|
BIO_printf(bio_err, "parameter error \"%s\"\n", opt);
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int do_x509_req_init(X509_REQ *x, STACK_OF(OPENSSL_STRING) *opts)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (opts == NULL)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
for (i = 0; i < sk_OPENSSL_STRING_num(opts); i++) {
|
||||||
|
char *opt = sk_OPENSSL_STRING_value(opts, i);
|
||||||
|
if (x509_req_ctrl_string(x, opt) <= 0) {
|
||||||
|
BIO_printf(bio_err, "parameter error \"%s\"\n", opt);
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int do_sign_init(EVP_MD_CTX *ctx, EVP_PKEY *pkey,
|
static int do_sign_init(EVP_MD_CTX *ctx, EVP_PKEY *pkey,
|
||||||
const EVP_MD *md, STACK_OF(OPENSSL_STRING) *sigopts)
|
const EVP_MD *md, STACK_OF(OPENSSL_STRING) *sigopts)
|
||||||
{
|
{
|
||||||
EVP_PKEY_CTX *pkctx = NULL;
|
EVP_PKEY_CTX *pkctx = NULL;
|
||||||
EVP_PKEY_CTX *pctx = NULL;
|
int def_nid;
|
||||||
int i, def_nid, ret = 0;
|
|
||||||
|
|
||||||
if (ctx == NULL)
|
if (ctx == NULL)
|
||||||
goto err;
|
return 0;
|
||||||
if (EVP_PKEY_id(pkey) == EVP_PKEY_SM2) {
|
|
||||||
pctx = EVP_PKEY_CTX_new(pkey, NULL);
|
|
||||||
if (pctx == NULL) {
|
|
||||||
BIO_printf(bio_err, "memory allocation failure.\n");
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
/* set SM2 ID from sig options before calling the real init routine */
|
|
||||||
for (i = 0; i < sk_OPENSSL_STRING_num(sigopts); i++) {
|
|
||||||
char *sigopt = sk_OPENSSL_STRING_value(sigopts, i);
|
|
||||||
if (pkey_ctrl_string(pctx, sigopt) <= 0) {
|
|
||||||
BIO_printf(bio_err, "parameter error \"%s\"\n", sigopt);
|
|
||||||
ERR_print_errors(bio_err);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EVP_MD_CTX_set_pkey_ctx(ctx, pctx);
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* EVP_PKEY_get_default_digest_nid() returns 2 if the digest is mandatory
|
* EVP_PKEY_get_default_digest_nid() returns 2 if the digest is mandatory
|
||||||
* for this algorithm.
|
* for this algorithm.
|
||||||
@@ -1720,36 +1700,8 @@ static int do_sign_init(EVP_MD_CTX *ctx, EVP_PKEY *pkey,
|
|||||||
/* The signing algorithm requires there to be no digest */
|
/* The signing algorithm requires there to be no digest */
|
||||||
md = NULL;
|
md = NULL;
|
||||||
}
|
}
|
||||||
if (!EVP_DigestSignInit(ctx, &pkctx, md, NULL, pkey))
|
return EVP_DigestSignInit(ctx, &pkctx, md, NULL, pkey)
|
||||||
goto err;
|
&& do_pkey_ctx_init(pkctx, sigopts);
|
||||||
for (i = 0; i < sk_OPENSSL_STRING_num(sigopts); i++) {
|
|
||||||
char *sigopt = sk_OPENSSL_STRING_value(sigopts, i);
|
|
||||||
if (pkey_ctrl_string(pkctx, sigopt) <= 0) {
|
|
||||||
BIO_printf(bio_err, "parameter error \"%s\"\n", sigopt);
|
|
||||||
ERR_print_errors(bio_err);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = 1;
|
|
||||||
err:
|
|
||||||
if (!ret)
|
|
||||||
EVP_PKEY_CTX_free(pctx);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void do_sign_cleanup(EVP_MD_CTX *ctx, EVP_PKEY *pkey)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* With SM2, do_sign_init() attached an EVP_PKEY_CTX to the EVP_MD_CTX,
|
|
||||||
* and we have to free it explicitly.
|
|
||||||
*/
|
|
||||||
if (EVP_PKEY_id(pkey) == EVP_PKEY_SM2) {
|
|
||||||
EVP_PKEY_CTX *pctx = EVP_MD_CTX_pkey_ctx(ctx);
|
|
||||||
|
|
||||||
EVP_MD_CTX_set_pkey_ctx(ctx, NULL);
|
|
||||||
EVP_PKEY_CTX_free(pctx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int do_X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md,
|
int do_X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md,
|
||||||
@@ -1758,10 +1710,8 @@ int do_X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md,
|
|||||||
int rv = 0;
|
int rv = 0;
|
||||||
EVP_MD_CTX *mctx = EVP_MD_CTX_new();
|
EVP_MD_CTX *mctx = EVP_MD_CTX_new();
|
||||||
|
|
||||||
if (do_sign_init(mctx, pkey, md, sigopts) > 0) {
|
if (do_sign_init(mctx, pkey, md, sigopts) > 0)
|
||||||
rv = (X509_sign_ctx(x, mctx) > 0);
|
rv = (X509_sign_ctx(x, mctx) > 0);
|
||||||
do_sign_cleanup(mctx, pkey);
|
|
||||||
}
|
|
||||||
EVP_MD_CTX_free(mctx);
|
EVP_MD_CTX_free(mctx);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
@@ -1772,24 +1722,39 @@ int do_X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md,
|
|||||||
int rv = 0;
|
int rv = 0;
|
||||||
EVP_MD_CTX *mctx = EVP_MD_CTX_new();
|
EVP_MD_CTX *mctx = EVP_MD_CTX_new();
|
||||||
|
|
||||||
if (do_sign_init(mctx, pkey, md, sigopts) > 0) {
|
if (do_sign_init(mctx, pkey, md, sigopts) > 0)
|
||||||
rv = (X509_REQ_sign_ctx(x, mctx) > 0);
|
rv = (X509_REQ_sign_ctx(x, mctx) > 0);
|
||||||
do_sign_cleanup(mctx, pkey);
|
|
||||||
}
|
|
||||||
EVP_MD_CTX_free(mctx);
|
EVP_MD_CTX_free(mctx);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int do_X509_verify(X509 *x, EVP_PKEY *pkey, STACK_OF(OPENSSL_STRING) *vfyopts)
|
||||||
|
{
|
||||||
|
int rv = 0;
|
||||||
|
|
||||||
|
if (do_x509_init(x, vfyopts) > 0)
|
||||||
|
rv = (X509_verify(x, pkey) > 0);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
int do_X509_REQ_verify(X509_REQ *x, EVP_PKEY *pkey,
|
||||||
|
STACK_OF(OPENSSL_STRING) *vfyopts)
|
||||||
|
{
|
||||||
|
int rv = 0;
|
||||||
|
|
||||||
|
if (do_x509_req_init(x, vfyopts) > 0)
|
||||||
|
rv = (X509_REQ_verify(x, pkey) > 0);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
int do_X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md,
|
int do_X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md,
|
||||||
STACK_OF(OPENSSL_STRING) *sigopts)
|
STACK_OF(OPENSSL_STRING) *sigopts)
|
||||||
{
|
{
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
EVP_MD_CTX *mctx = EVP_MD_CTX_new();
|
EVP_MD_CTX *mctx = EVP_MD_CTX_new();
|
||||||
|
|
||||||
if (do_sign_init(mctx, pkey, md, sigopts) > 0) {
|
if (do_sign_init(mctx, pkey, md, sigopts) > 0)
|
||||||
rv = (X509_CRL_sign_ctx(x, mctx) > 0);
|
rv = (X509_CRL_sign_ctx(x, mctx) > 0);
|
||||||
do_sign_cleanup(mctx, pkey);
|
|
||||||
}
|
|
||||||
EVP_MD_CTX_free(mctx);
|
EVP_MD_CTX_free(mctx);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
+40
-35
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -8,23 +8,20 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <openssl/opensslconf.h>
|
#include <openssl/opensslconf.h>
|
||||||
#ifdef OPENSSL_NO_RSA
|
|
||||||
NON_EMPTY_TRANSLATION_UNIT
|
|
||||||
#else
|
|
||||||
|
|
||||||
# include <stdio.h>
|
#include <stdio.h>
|
||||||
# include <stdlib.h>
|
#include <stdlib.h>
|
||||||
# include <string.h>
|
#include <string.h>
|
||||||
# include <time.h>
|
#include <time.h>
|
||||||
# include "apps.h"
|
#include "apps.h"
|
||||||
# include "progs.h"
|
#include "progs.h"
|
||||||
# include <openssl/bio.h>
|
#include <openssl/bio.h>
|
||||||
# include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
# include <openssl/rsa.h>
|
#include <openssl/rsa.h>
|
||||||
# include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
# include <openssl/x509.h>
|
#include <openssl/x509.h>
|
||||||
# include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
# include <openssl/bn.h>
|
#include <openssl/bn.h>
|
||||||
|
|
||||||
typedef enum OPTION_choice {
|
typedef enum OPTION_choice {
|
||||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||||
@@ -42,9 +39,9 @@ const OPTIONS rsa_options[] = {
|
|||||||
{"help", OPT_HELP, '-', "Display this summary"},
|
{"help", OPT_HELP, '-', "Display this summary"},
|
||||||
{"check", OPT_CHECK, '-', "Verify key consistency"},
|
{"check", OPT_CHECK, '-', "Verify key consistency"},
|
||||||
{"", OPT_CIPHER, '-', "Any supported cipher"},
|
{"", OPT_CIPHER, '-', "Any supported cipher"},
|
||||||
# ifndef OPENSSL_NO_ENGINE
|
#ifndef OPENSSL_NO_ENGINE
|
||||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
OPT_SECTION("Input"),
|
OPT_SECTION("Input"),
|
||||||
{"in", OPT_IN, 's', "Input file"},
|
{"in", OPT_IN, 's', "Input file"},
|
||||||
@@ -63,14 +60,14 @@ const OPTIONS rsa_options[] = {
|
|||||||
{"text", OPT_TEXT, '-', "Print the key in text"},
|
{"text", OPT_TEXT, '-', "Print the key in text"},
|
||||||
{"modulus", OPT_MODULUS, '-', "Print the RSA key modulus"},
|
{"modulus", OPT_MODULUS, '-', "Print the RSA key modulus"},
|
||||||
|
|
||||||
# if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4)
|
#if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4)
|
||||||
OPT_SECTION("PVK"),
|
OPT_SECTION("PVK"),
|
||||||
{"pvk-strong", OPT_PVK_STRONG, '-', "Enable 'Strong' PVK encoding level (default)"},
|
{"pvk-strong", OPT_PVK_STRONG, '-', "Enable 'Strong' PVK encoding level (default)"},
|
||||||
{"pvk-weak", OPT_PVK_WEAK, '-', "Enable 'Weak' PVK encoding level"},
|
{"pvk-weak", OPT_PVK_WEAK, '-', "Enable 'Weak' PVK encoding level"},
|
||||||
{"pvk-none", OPT_PVK_NONE, '-', "Don't enforce PVK encoding"},
|
{"pvk-none", OPT_PVK_NONE, '-', "Don't enforce PVK encoding"},
|
||||||
# endif
|
|
||||||
|
|
||||||
OPT_PROV_OPTIONS,
|
OPT_PROV_OPTIONS,
|
||||||
|
#endif
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -79,15 +76,17 @@ int rsa_main(int argc, char **argv)
|
|||||||
ENGINE *e = NULL;
|
ENGINE *e = NULL;
|
||||||
BIO *out = NULL;
|
BIO *out = NULL;
|
||||||
RSA *rsa = NULL;
|
RSA *rsa = NULL;
|
||||||
|
EVP_PKEY *pkey = NULL;
|
||||||
|
EVP_PKEY_CTX *pctx;
|
||||||
const EVP_CIPHER *enc = NULL;
|
const EVP_CIPHER *enc = NULL;
|
||||||
char *infile = NULL, *outfile = NULL, *prog;
|
char *infile = NULL, *outfile = NULL, *prog;
|
||||||
char *passin = NULL, *passout = NULL, *passinarg = NULL, *passoutarg = NULL;
|
char *passin = NULL, *passout = NULL, *passinarg = NULL, *passoutarg = NULL;
|
||||||
int i, private = 0;
|
int i, private = 0;
|
||||||
int informat = FORMAT_PEM, outformat = FORMAT_PEM, text = 0, check = 0;
|
int informat = FORMAT_PEM, outformat = FORMAT_PEM, text = 0, check = 0;
|
||||||
int noout = 0, modulus = 0, pubin = 0, pubout = 0, ret = 1;
|
int noout = 0, modulus = 0, pubin = 0, pubout = 0, ret = 1;
|
||||||
# if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4)
|
#if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4)
|
||||||
int pvk_encr = 2;
|
int pvk_encr = 2;
|
||||||
# endif
|
#endif
|
||||||
OPTION_CHOICE o;
|
OPTION_CHOICE o;
|
||||||
|
|
||||||
prog = opt_init(argc, argv, rsa_options);
|
prog = opt_init(argc, argv, rsa_options);
|
||||||
@@ -140,9 +139,9 @@ int rsa_main(int argc, char **argv)
|
|||||||
case OPT_PVK_STRONG: /* pvk_encr:= 2 */
|
case OPT_PVK_STRONG: /* pvk_encr:= 2 */
|
||||||
case OPT_PVK_WEAK: /* pvk_encr:= 1 */
|
case OPT_PVK_WEAK: /* pvk_encr:= 1 */
|
||||||
case OPT_PVK_NONE: /* pvk_encr:= 0 */
|
case OPT_PVK_NONE: /* pvk_encr:= 0 */
|
||||||
# if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4)
|
#if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4)
|
||||||
pvk_encr = (o - OPT_PVK_NONE);
|
pvk_encr = (o - OPT_PVK_NONE);
|
||||||
# endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case OPT_NOOUT:
|
case OPT_NOOUT:
|
||||||
noout = 1;
|
noout = 1;
|
||||||
@@ -181,11 +180,9 @@ int rsa_main(int argc, char **argv)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
EVP_PKEY *pkey;
|
|
||||||
|
|
||||||
if (pubin) {
|
if (pubin) {
|
||||||
int tmpformat = -1;
|
int tmpformat = -1;
|
||||||
|
|
||||||
if (pubin == 2) {
|
if (pubin == 2) {
|
||||||
if (informat == FORMAT_PEM)
|
if (informat == FORMAT_PEM)
|
||||||
tmpformat = FORMAT_PEMRSA;
|
tmpformat = FORMAT_PEMRSA;
|
||||||
@@ -202,8 +199,6 @@ int rsa_main(int argc, char **argv)
|
|||||||
|
|
||||||
if (pkey != NULL)
|
if (pkey != NULL)
|
||||||
rsa = EVP_PKEY_get1_RSA(pkey);
|
rsa = EVP_PKEY_get1_RSA(pkey);
|
||||||
EVP_PKEY_free(pkey);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rsa == NULL) {
|
if (rsa == NULL) {
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
@@ -216,7 +211,8 @@ int rsa_main(int argc, char **argv)
|
|||||||
|
|
||||||
if (text) {
|
if (text) {
|
||||||
assert(pubin || private);
|
assert(pubin || private);
|
||||||
if (!RSA_print(out, rsa, 0)) {
|
if ((pubin && EVP_PKEY_print_public(out, pkey, 0, NULL) <= 0)
|
||||||
|
|| (!pubin && EVP_PKEY_print_private(out, pkey, 0, NULL) <= 0)) {
|
||||||
perror(outfile);
|
perror(outfile);
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
goto end;
|
goto end;
|
||||||
@@ -232,7 +228,16 @@ int rsa_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (check) {
|
if (check) {
|
||||||
int r = RSA_check_key_ex(rsa, NULL);
|
int r;
|
||||||
|
|
||||||
|
pctx = EVP_PKEY_CTX_new_from_pkey(NULL, pkey, NULL);
|
||||||
|
if (pctx == NULL) {
|
||||||
|
BIO_printf(out, "RSA unable to create PKEY context\n");
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
r = EVP_PKEY_check(pctx);
|
||||||
|
EVP_PKEY_CTX_free(pctx);
|
||||||
|
|
||||||
if (r == 1) {
|
if (r == 1) {
|
||||||
BIO_printf(out, "RSA key ok\n");
|
BIO_printf(out, "RSA key ok\n");
|
||||||
@@ -278,7 +283,7 @@ int rsa_main(int argc, char **argv)
|
|||||||
i = PEM_write_bio_RSAPrivateKey(out, rsa,
|
i = PEM_write_bio_RSAPrivateKey(out, rsa,
|
||||||
enc, NULL, 0, NULL, passout);
|
enc, NULL, 0, NULL, passout);
|
||||||
}
|
}
|
||||||
# ifndef OPENSSL_NO_DSA
|
#ifndef OPENSSL_NO_DSA
|
||||||
} else if (outformat == FORMAT_MSBLOB || outformat == FORMAT_PVK) {
|
} else if (outformat == FORMAT_MSBLOB || outformat == FORMAT_PVK) {
|
||||||
EVP_PKEY *pk;
|
EVP_PKEY *pk;
|
||||||
pk = EVP_PKEY_new();
|
pk = EVP_PKEY_new();
|
||||||
@@ -307,7 +312,7 @@ int rsa_main(int argc, char **argv)
|
|||||||
i = i2b_PrivateKey_bio(out, pk);
|
i = i2b_PrivateKey_bio(out, pk);
|
||||||
}
|
}
|
||||||
EVP_PKEY_free(pk);
|
EVP_PKEY_free(pk);
|
||||||
# endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
BIO_printf(bio_err, "bad output format specified for outfile\n");
|
BIO_printf(bio_err, "bad output format specified for outfile\n");
|
||||||
goto end;
|
goto end;
|
||||||
@@ -321,9 +326,9 @@ int rsa_main(int argc, char **argv)
|
|||||||
end:
|
end:
|
||||||
release_engine(e);
|
release_engine(e);
|
||||||
BIO_free_all(out);
|
BIO_free_all(out);
|
||||||
|
EVP_PKEY_free(pkey);
|
||||||
RSA_free(rsa);
|
RSA_free(rsa);
|
||||||
OPENSSL_free(passin);
|
OPENSSL_free(passin);
|
||||||
OPENSSL_free(passout);
|
OPENSSL_free(passout);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
+16
-20
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -8,25 +8,22 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <openssl/opensslconf.h>
|
#include <openssl/opensslconf.h>
|
||||||
#ifdef OPENSSL_NO_RSA
|
|
||||||
NON_EMPTY_TRANSLATION_UNIT
|
|
||||||
#else
|
|
||||||
|
|
||||||
# include "apps.h"
|
#include "apps.h"
|
||||||
# include "progs.h"
|
#include "progs.h"
|
||||||
# include <string.h>
|
#include <string.h>
|
||||||
# include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
# include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
# include <openssl/rsa.h>
|
#include <openssl/rsa.h>
|
||||||
|
|
||||||
# define RSA_SIGN 1
|
#define RSA_SIGN 1
|
||||||
# define RSA_VERIFY 2
|
#define RSA_VERIFY 2
|
||||||
# define RSA_ENCRYPT 3
|
#define RSA_ENCRYPT 3
|
||||||
# define RSA_DECRYPT 4
|
#define RSA_DECRYPT 4
|
||||||
|
|
||||||
# define KEY_PRIVKEY 1
|
#define KEY_PRIVKEY 1
|
||||||
# define KEY_PUBKEY 2
|
#define KEY_PUBKEY 2
|
||||||
# define KEY_CERT 3
|
#define KEY_CERT 3
|
||||||
|
|
||||||
typedef enum OPTION_choice {
|
typedef enum OPTION_choice {
|
||||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||||
@@ -44,9 +41,9 @@ const OPTIONS rsautl_options[] = {
|
|||||||
{"verify", OPT_VERIFY, '-', "Verify with public key"},
|
{"verify", OPT_VERIFY, '-', "Verify with public key"},
|
||||||
{"encrypt", OPT_ENCRYPT, '-', "Encrypt with public key"},
|
{"encrypt", OPT_ENCRYPT, '-', "Encrypt with public key"},
|
||||||
{"decrypt", OPT_DECRYPT, '-', "Decrypt with private key"},
|
{"decrypt", OPT_DECRYPT, '-', "Decrypt with private key"},
|
||||||
# ifndef OPENSSL_NO_ENGINE
|
#ifndef OPENSSL_NO_ENGINE
|
||||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
OPT_SECTION("Input"),
|
OPT_SECTION("Input"),
|
||||||
{"in", OPT_IN, '<', "Input file"},
|
{"in", OPT_IN, '<', "Input file"},
|
||||||
@@ -290,4 +287,3 @@ int rsautl_main(int argc, char **argv)
|
|||||||
OPENSSL_free(passin);
|
OPENSSL_free(passin);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
+21
-22
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
* Copyright 2005 Nokia. All rights reserved.
|
* Copyright 2005 Nokia. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
@@ -56,6 +56,12 @@ typedef unsigned int u_int;
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(X509)
|
||||||
|
DEFINE_STACK_OF(X509_CRL)
|
||||||
|
DEFINE_STACK_OF(X509_NAME)
|
||||||
|
DEFINE_STACK_OF(SCT)
|
||||||
|
DEFINE_STACK_OF_STRING()
|
||||||
|
|
||||||
#undef BUFSIZZ
|
#undef BUFSIZZ
|
||||||
#define BUFSIZZ 1024*8
|
#define BUFSIZZ 1024*8
|
||||||
#define S_CLIENT_IRC_READ_TIMEOUT 8
|
#define S_CLIENT_IRC_READ_TIMEOUT 8
|
||||||
@@ -649,14 +655,17 @@ const OPTIONS s_client_options[] = {
|
|||||||
{"fallback_scsv", OPT_FALLBACKSCSV, '-', "Send the fallback SCSV"},
|
{"fallback_scsv", OPT_FALLBACKSCSV, '-', "Send the fallback SCSV"},
|
||||||
|
|
||||||
OPT_SECTION("Identity"),
|
OPT_SECTION("Identity"),
|
||||||
{"verify", OPT_VERIFY, 'p', "Turn on peer certificate verification"},
|
{"cert", OPT_CERT, '<', "Client certificate file to use"},
|
||||||
{"cert", OPT_CERT, '<', "Certificate file to use, PEM format assumed"},
|
|
||||||
{"certform", OPT_CERTFORM, 'F',
|
{"certform", OPT_CERTFORM, 'F',
|
||||||
"Certificate format (PEM or DER) PEM default"},
|
"Client certificate file format (PEM or DER) PEM default"},
|
||||||
{"nameopt", OPT_NAMEOPT, 's', "Various certificate name options"},
|
{"cert_chain", OPT_CERT_CHAIN, '<',
|
||||||
{"key", OPT_KEY, 's', "Private key file to use, if not in -cert file"},
|
"Client certificate chain file (in PEM format)"},
|
||||||
|
{"build_chain", OPT_BUILD_CHAIN, '-', "Build client certificate chain"},
|
||||||
|
{"key", OPT_KEY, 's', "Private key file to use; default is: -cert file"},
|
||||||
{"keyform", OPT_KEYFORM, 'E', "Key format (PEM, DER or engine) PEM default"},
|
{"keyform", OPT_KEYFORM, 'E', "Key format (PEM, DER or engine) PEM default"},
|
||||||
{"pass", OPT_PASS, 's', "Private key file pass phrase source"},
|
{"pass", OPT_PASS, 's', "Private key file pass phrase source"},
|
||||||
|
{"verify", OPT_VERIFY, 'p', "Turn on peer certificate verification"},
|
||||||
|
{"nameopt", OPT_NAMEOPT, 's', "Certificate subject/issuer name printing options"},
|
||||||
{"CApath", OPT_CAPATH, '/', "PEM format directory of CA's"},
|
{"CApath", OPT_CAPATH, '/', "PEM format directory of CA's"},
|
||||||
{"CAfile", OPT_CAFILE, '<', "PEM format file of CA's"},
|
{"CAfile", OPT_CAFILE, '<', "PEM format file of CA's"},
|
||||||
{"CAstore", OPT_CASTORE, ':', "URI to store of CA's"},
|
{"CAstore", OPT_CASTORE, ':', "URI to store of CA's"},
|
||||||
@@ -801,8 +810,8 @@ const OPTIONS s_client_options[] = {
|
|||||||
{"verify_return_error", OPT_VERIFY_RET_ERROR, '-',
|
{"verify_return_error", OPT_VERIFY_RET_ERROR, '-',
|
||||||
"Close connection on verification error"},
|
"Close connection on verification error"},
|
||||||
{"verify_quiet", OPT_VERIFY_QUIET, '-', "Restrict verify output to errors"},
|
{"verify_quiet", OPT_VERIFY_QUIET, '-', "Restrict verify output to errors"},
|
||||||
{"cert_chain", OPT_CERT_CHAIN, '<',
|
{"chainCAfile", OPT_CHAINCAFILE, '<',
|
||||||
"Certificate chain file (in PEM format)"},
|
"CA file for certificate chain (PEM format)"},
|
||||||
{"chainCApath", OPT_CHAINCAPATH, '/',
|
{"chainCApath", OPT_CHAINCAPATH, '/',
|
||||||
"Use dir as certificate store path to build CA certificate chain"},
|
"Use dir as certificate store path to build CA certificate chain"},
|
||||||
{"chainCAstore", OPT_CHAINCASTORE, ':',
|
{"chainCAstore", OPT_CHAINCASTORE, ':',
|
||||||
@@ -813,9 +822,6 @@ const OPTIONS s_client_options[] = {
|
|||||||
"Use dir as certificate store path to verify CA certificate"},
|
"Use dir as certificate store path to verify CA certificate"},
|
||||||
{"verifyCAstore", OPT_VERIFYCASTORE, ':',
|
{"verifyCAstore", OPT_VERIFYCASTORE, ':',
|
||||||
"CA store URI for certificate verification"},
|
"CA store URI for certificate verification"},
|
||||||
{"build_chain", OPT_BUILD_CHAIN, '-', "Build certificate chain"},
|
|
||||||
{"chainCAfile", OPT_CHAINCAFILE, '<',
|
|
||||||
"CA file for certificate chain (PEM format)"},
|
|
||||||
OPT_X_OPTIONS,
|
OPT_X_OPTIONS,
|
||||||
OPT_PROV_OPTIONS,
|
OPT_PROV_OPTIONS,
|
||||||
|
|
||||||
@@ -1708,19 +1714,15 @@ int s_client_main(int argc, char **argv)
|
|||||||
if (key_file != NULL) {
|
if (key_file != NULL) {
|
||||||
key = load_key(key_file, key_format, 0, pass, e,
|
key = load_key(key_file, key_format, 0, pass, e,
|
||||||
"client certificate private key file");
|
"client certificate private key file");
|
||||||
if (key == NULL) {
|
if (key == NULL)
|
||||||
ERR_print_errors(bio_err);
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (cert_file != NULL) {
|
if (cert_file != NULL) {
|
||||||
cert = load_cert(cert_file, cert_format, "client certificate file");
|
cert = load_cert(cert_file, cert_format, "client certificate file");
|
||||||
if (cert == NULL) {
|
if (cert == NULL)
|
||||||
ERR_print_errors(bio_err);
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (chain_file != NULL) {
|
if (chain_file != NULL) {
|
||||||
if (!load_certs(chain_file, &chain, FORMAT_PEM, NULL,
|
if (!load_certs(chain_file, &chain, FORMAT_PEM, NULL,
|
||||||
@@ -1730,12 +1732,9 @@ int s_client_main(int argc, char **argv)
|
|||||||
|
|
||||||
if (crl_file != NULL) {
|
if (crl_file != NULL) {
|
||||||
X509_CRL *crl;
|
X509_CRL *crl;
|
||||||
crl = load_crl(crl_file, crl_format);
|
crl = load_crl(crl_file, crl_format, "CRL");
|
||||||
if (crl == NULL) {
|
if (crl == NULL)
|
||||||
BIO_puts(bio_err, "Error loading CRL\n");
|
|
||||||
ERR_print_errors(bio_err);
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
|
||||||
crls = sk_X509_CRL_new_null();
|
crls = sk_X509_CRL_new_null();
|
||||||
if (crls == NULL || !sk_X509_CRL_push(crls, crl)) {
|
if (crls == NULL || !sk_X509_CRL_push(crls, crl)) {
|
||||||
BIO_puts(bio_err, "Error adding CRL\n");
|
BIO_puts(bio_err, "Error adding CRL\n");
|
||||||
|
|||||||
+110
-52
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
|
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
|
||||||
* Copyright 2005 Nokia. All rights reserved.
|
* Copyright 2005 Nokia. All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -60,6 +60,12 @@ typedef unsigned int u_int;
|
|||||||
#endif
|
#endif
|
||||||
#include "internal/sockets.h"
|
#include "internal/sockets.h"
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(X509_EXTENSION)
|
||||||
|
DEFINE_STACK_OF(X509_CRL)
|
||||||
|
DEFINE_STACK_OF(X509)
|
||||||
|
DEFINE_STACK_OF(SSL_CIPHER)
|
||||||
|
DEFINE_STACK_OF_STRING()
|
||||||
|
|
||||||
static int not_resumable_sess_cb(SSL *s, int is_forward_secure);
|
static int not_resumable_sess_cb(SSL *s, int is_forward_secure);
|
||||||
static int sv_body(int s, int stype, int prot, unsigned char *context);
|
static int sv_body(int s, int stype, int prot, unsigned char *context);
|
||||||
static int www_body(int s, int stype, int prot, unsigned char *context);
|
static int www_body(int s, int stype, int prot, unsigned char *context);
|
||||||
@@ -103,6 +109,8 @@ static int keymatexportlen = 20;
|
|||||||
|
|
||||||
static int async = 0;
|
static int async = 0;
|
||||||
|
|
||||||
|
static int use_sendfile = 0;
|
||||||
|
|
||||||
static const char *session_id_prefix = NULL;
|
static const char *session_id_prefix = NULL;
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_DTLS
|
#ifndef OPENSSL_NO_DTLS
|
||||||
@@ -707,7 +715,7 @@ static int alpn_cb(SSL *s, const unsigned char **out, unsigned char *outlen,
|
|||||||
if (SSL_select_next_proto
|
if (SSL_select_next_proto
|
||||||
((unsigned char **)out, outlen, alpn_ctx->data, alpn_ctx->len, in,
|
((unsigned char **)out, outlen, alpn_ctx->data, alpn_ctx->len, in,
|
||||||
inlen) != OPENSSL_NPN_NEGOTIATED) {
|
inlen) != OPENSSL_NPN_NEGOTIATED) {
|
||||||
return SSL_TLSEXT_ERR_NOACK;
|
return SSL_TLSEXT_ERR_ALERT_FATAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!s_quiet) {
|
if (!s_quiet) {
|
||||||
@@ -749,7 +757,7 @@ typedef enum OPTION_choice {
|
|||||||
OPT_SSL3, OPT_TLS1_3, OPT_TLS1_2, OPT_TLS1_1, OPT_TLS1, OPT_DTLS, OPT_DTLS1,
|
OPT_SSL3, OPT_TLS1_3, OPT_TLS1_2, OPT_TLS1_1, OPT_TLS1, OPT_DTLS, OPT_DTLS1,
|
||||||
OPT_DTLS1_2, OPT_SCTP, OPT_TIMEOUT, OPT_MTU, OPT_LISTEN, OPT_STATELESS,
|
OPT_DTLS1_2, OPT_SCTP, OPT_TIMEOUT, OPT_MTU, OPT_LISTEN, OPT_STATELESS,
|
||||||
OPT_ID_PREFIX, OPT_SERVERNAME, OPT_SERVERNAME_FATAL,
|
OPT_ID_PREFIX, OPT_SERVERNAME, OPT_SERVERNAME_FATAL,
|
||||||
OPT_CERT2, OPT_KEY2, OPT_NEXTPROTONEG, OPT_ALPN,
|
OPT_CERT2, OPT_KEY2, OPT_NEXTPROTONEG, OPT_ALPN, OPT_SENDFILE,
|
||||||
OPT_SRTP_PROFILES, OPT_KEYMATEXPORT, OPT_KEYMATEXPORTLEN,
|
OPT_SRTP_PROFILES, OPT_KEYMATEXPORT, OPT_KEYMATEXPORTLEN,
|
||||||
OPT_KEYLOG_FILE, OPT_MAX_EARLY, OPT_RECV_MAX_EARLY, OPT_EARLY_DATA,
|
OPT_KEYLOG_FILE, OPT_MAX_EARLY, OPT_RECV_MAX_EARLY, OPT_EARLY_DATA,
|
||||||
OPT_S_NUM_TICKETS, OPT_ANTI_REPLAY, OPT_NO_ANTI_REPLAY, OPT_SCTP_LABEL_BUG,
|
OPT_S_NUM_TICKETS, OPT_ANTI_REPLAY, OPT_NO_ANTI_REPLAY, OPT_SCTP_LABEL_BUG,
|
||||||
@@ -800,31 +808,36 @@ const OPTIONS s_server_options[] = {
|
|||||||
{"verify", OPT_VERIFY, 'n', "Turn on peer certificate verification"},
|
{"verify", OPT_VERIFY, 'n', "Turn on peer certificate verification"},
|
||||||
{"Verify", OPT_UPPER_V_VERIFY, 'n',
|
{"Verify", OPT_UPPER_V_VERIFY, 'n',
|
||||||
"Turn on peer certificate verification, must have a cert"},
|
"Turn on peer certificate verification, must have a cert"},
|
||||||
{"cert", OPT_CERT, '<', "Certificate file to use; default is " TEST_CERT},
|
{"nameopt", OPT_NAMEOPT, 's', "Certificate subject/issuer name printing options"},
|
||||||
|
{"cert", OPT_CERT, '<', "Server certificate file to use; default is " TEST_CERT},
|
||||||
{"cert2", OPT_CERT2, '<',
|
{"cert2", OPT_CERT2, '<',
|
||||||
"Certificate file to use for servername; default is" TEST_CERT2},
|
"Certificate file to use for servername; default is" TEST_CERT2},
|
||||||
{"key2", OPT_KEY2, '<',
|
{"certform", OPT_CERTFORM, 'F',
|
||||||
"-Private Key file to use for servername if not in -cert2"},
|
"Server certificate file format (PEM or DER) PEM default"},
|
||||||
{"nameopt", OPT_NAMEOPT, 's', "Various certificate name options"},
|
{"cert_chain", OPT_CERT_CHAIN, '<',
|
||||||
|
"Server certificate chain file in PEM format"},
|
||||||
|
{"build_chain", OPT_BUILD_CHAIN, '-', "Build server certificate chain"},
|
||||||
{"serverinfo", OPT_SERVERINFO, 's',
|
{"serverinfo", OPT_SERVERINFO, 's',
|
||||||
"PEM serverinfo file for certificate"},
|
"PEM serverinfo file for certificate"},
|
||||||
{"certform", OPT_CERTFORM, 'F',
|
|
||||||
"Certificate format (PEM or DER) PEM default"},
|
|
||||||
{"key", OPT_KEY, 's',
|
{"key", OPT_KEY, 's',
|
||||||
"Private Key if not in -cert; default is " TEST_CERT},
|
"Private key file to use; default is -cert file or else" TEST_CERT},
|
||||||
|
{"key2", OPT_KEY2, '<',
|
||||||
|
"-Private Key file to use for servername if not in -cert2"},
|
||||||
{"keyform", OPT_KEYFORM, 'f',
|
{"keyform", OPT_KEYFORM, 'f',
|
||||||
"Key format (PEM, DER or ENGINE) PEM default"},
|
"Key format (PEM, DER or ENGINE) PEM default"},
|
||||||
{"pass", OPT_PASS, 's', "Private key file pass phrase source"},
|
{"pass", OPT_PASS, 's', "Private key file pass phrase source"},
|
||||||
{"dcert", OPT_DCERT, '<',
|
{"dcert", OPT_DCERT, '<',
|
||||||
"Second certificate file to use (usually for DSA)"},
|
"Second server certificate file to use (usually for DSA)"},
|
||||||
{"dhparam", OPT_DHPARAM, '<', "DH parameters file to use"},
|
|
||||||
{"dcertform", OPT_DCERTFORM, 'F',
|
{"dcertform", OPT_DCERTFORM, 'F',
|
||||||
"Second certificate format (PEM or DER) PEM default"},
|
"Second server certificate file format (PEM or DER) PEM default"},
|
||||||
|
{"dcert_chain", OPT_DCERT_CHAIN, '<',
|
||||||
|
"second server certificate chain file in PEM format"},
|
||||||
{"dkey", OPT_DKEY, '<',
|
{"dkey", OPT_DKEY, '<',
|
||||||
"Second private key file to use (usually for DSA)"},
|
"Second private key file to use (usually for DSA)"},
|
||||||
{"dkeyform", OPT_DKEYFORM, 'F',
|
{"dkeyform", OPT_DKEYFORM, 'F',
|
||||||
"Second key format (PEM, DER or ENGINE) PEM default"},
|
"Second key file format (PEM, DER or ENGINE) PEM default"},
|
||||||
{"dpass", OPT_DPASS, 's', "Second private key file pass phrase source"},
|
{"dpass", OPT_DPASS, 's', "Second private key file pass phrase source"},
|
||||||
|
{"dhparam", OPT_DHPARAM, '<', "DH parameters file to use"},
|
||||||
{"servername", OPT_SERVERNAME, 's',
|
{"servername", OPT_SERVERNAME, 's',
|
||||||
"Servername for HostName TLS extension"},
|
"Servername for HostName TLS extension"},
|
||||||
{"servername_fatal", OPT_SERVERNAME_FATAL, '-',
|
{"servername_fatal", OPT_SERVERNAME_FATAL, '-',
|
||||||
@@ -848,12 +861,17 @@ const OPTIONS s_server_options[] = {
|
|||||||
{"keymatexportlen", OPT_KEYMATEXPORTLEN, 'p',
|
{"keymatexportlen", OPT_KEYMATEXPORTLEN, 'p',
|
||||||
"Export len bytes of keying material (default 20)"},
|
"Export len bytes of keying material (default 20)"},
|
||||||
{"CRL", OPT_CRL, '<', "CRL file to use"},
|
{"CRL", OPT_CRL, '<', "CRL file to use"},
|
||||||
|
{"CRLform", OPT_CRLFORM, 'F', "CRL file format (PEM or DER); default PEM"},
|
||||||
{"crl_download", OPT_CRL_DOWNLOAD, '-',
|
{"crl_download", OPT_CRL_DOWNLOAD, '-',
|
||||||
"Download CRL from distribution points"},
|
"Download CRLs from distribution points in certificate CDP entries"},
|
||||||
|
{"chainCAfile", OPT_CHAINCAFILE, '<',
|
||||||
|
"CA file for certificate chain (PEM format)"},
|
||||||
{"chainCApath", OPT_CHAINCAPATH, '/',
|
{"chainCApath", OPT_CHAINCAPATH, '/',
|
||||||
"use dir as certificate store path to build CA certificate chain"},
|
"use dir as certificate store path to build CA certificate chain"},
|
||||||
{"chainCAstore", OPT_CHAINCASTORE, ':',
|
{"chainCAstore", OPT_CHAINCASTORE, ':',
|
||||||
"use URI as certificate store to build CA certificate chain"},
|
"use URI as certificate store to build CA certificate chain"},
|
||||||
|
{"verifyCAfile", OPT_VERIFYCAFILE, '<',
|
||||||
|
"CA file for certificate verification (PEM format)"},
|
||||||
{"verifyCApath", OPT_VERIFYCAPATH, '/',
|
{"verifyCApath", OPT_VERIFYCAPATH, '/',
|
||||||
"use dir as certificate store path to verify CA certificate"},
|
"use dir as certificate store path to verify CA certificate"},
|
||||||
{"verifyCAstore", OPT_VERIFYCASTORE, ':',
|
{"verifyCAstore", OPT_VERIFYCASTORE, ':',
|
||||||
@@ -861,13 +879,10 @@ const OPTIONS s_server_options[] = {
|
|||||||
{"no_cache", OPT_NO_CACHE, '-', "Disable session cache"},
|
{"no_cache", OPT_NO_CACHE, '-', "Disable session cache"},
|
||||||
{"ext_cache", OPT_EXT_CACHE, '-',
|
{"ext_cache", OPT_EXT_CACHE, '-',
|
||||||
"Disable internal cache, setup and use external cache"},
|
"Disable internal cache, setup and use external cache"},
|
||||||
{"CRLform", OPT_CRLFORM, 'F', "CRL format (PEM or DER) PEM is default"},
|
|
||||||
{"verify_return_error", OPT_VERIFY_RET_ERROR, '-',
|
{"verify_return_error", OPT_VERIFY_RET_ERROR, '-',
|
||||||
"Close connection on verification error"},
|
"Close connection on verification error"},
|
||||||
{"verify_quiet", OPT_VERIFY_QUIET, '-',
|
{"verify_quiet", OPT_VERIFY_QUIET, '-',
|
||||||
"No verify output except verify errors"},
|
"No verify output except verify errors"},
|
||||||
{"verifyCAfile", OPT_VERIFYCAFILE, '<',
|
|
||||||
"CA file for certificate verification (PEM format)"},
|
|
||||||
{"ign_eof", OPT_IGN_EOF, '-', "ignore input eof (default when -quiet)"},
|
{"ign_eof", OPT_IGN_EOF, '-', "ignore input eof (default when -quiet)"},
|
||||||
{"no_ign_eof", OPT_NO_IGN_EOF, '-', "Do not ignore input eof"},
|
{"no_ign_eof", OPT_NO_IGN_EOF, '-', "Do not ignore input eof"},
|
||||||
|
|
||||||
@@ -981,17 +996,13 @@ const OPTIONS s_server_options[] = {
|
|||||||
#endif
|
#endif
|
||||||
{"alpn", OPT_ALPN, 's',
|
{"alpn", OPT_ALPN, 's',
|
||||||
"Set the advertised protocols for the ALPN extension (comma-separated list)"},
|
"Set the advertised protocols for the ALPN extension (comma-separated list)"},
|
||||||
|
#ifndef OPENSSL_NO_KTLS
|
||||||
|
{"sendfile", OPT_SENDFILE, '-', "Use sendfile to response file with -WWW"},
|
||||||
|
#endif
|
||||||
|
|
||||||
OPT_R_OPTIONS,
|
OPT_R_OPTIONS,
|
||||||
OPT_S_OPTIONS,
|
OPT_S_OPTIONS,
|
||||||
OPT_V_OPTIONS,
|
OPT_V_OPTIONS,
|
||||||
{"cert_chain", OPT_CERT_CHAIN, '<',
|
|
||||||
"certificate chain file in PEM format"},
|
|
||||||
{"dcert_chain", OPT_DCERT_CHAIN, '<',
|
|
||||||
"second certificate chain file in PEM format"},
|
|
||||||
{"build_chain", OPT_BUILD_CHAIN, '-', "Build certificate chain"},
|
|
||||||
{"chainCAfile", OPT_CHAINCAFILE, '<',
|
|
||||||
"CA file for certificate chain (PEM format)"},
|
|
||||||
OPT_X_OPTIONS,
|
OPT_X_OPTIONS,
|
||||||
OPT_PROV_OPTIONS,
|
OPT_PROV_OPTIONS,
|
||||||
{NULL}
|
{NULL}
|
||||||
@@ -1095,6 +1106,7 @@ int s_server_main(int argc, char *argv[])
|
|||||||
s_quiet = 0;
|
s_quiet = 0;
|
||||||
s_brief = 0;
|
s_brief = 0;
|
||||||
async = 0;
|
async = 0;
|
||||||
|
use_sendfile = 0;
|
||||||
|
|
||||||
cctx = SSL_CONF_CTX_new();
|
cctx = SSL_CONF_CTX_new();
|
||||||
vpm = X509_VERIFY_PARAM_new();
|
vpm = X509_VERIFY_PARAM_new();
|
||||||
@@ -1238,7 +1250,7 @@ int s_server_main(int argc, char *argv[])
|
|||||||
s_key_file = opt_arg();
|
s_key_file = opt_arg();
|
||||||
break;
|
break;
|
||||||
case OPT_KEYFORM:
|
case OPT_KEYFORM:
|
||||||
if (!opt_format(opt_arg(), OPT_FMT_ANY, &s_key_format))
|
if (!opt_format(opt_arg(), OPT_FMT_PDE, &s_key_format))
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
break;
|
break;
|
||||||
case OPT_PASS:
|
case OPT_PASS:
|
||||||
@@ -1260,7 +1272,7 @@ int s_server_main(int argc, char *argv[])
|
|||||||
s_dcert_file = opt_arg();
|
s_dcert_file = opt_arg();
|
||||||
break;
|
break;
|
||||||
case OPT_DKEYFORM:
|
case OPT_DKEYFORM:
|
||||||
if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &s_dkey_format))
|
if (!opt_format(opt_arg(), OPT_FMT_PDE, &s_dkey_format))
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
break;
|
break;
|
||||||
case OPT_DPASS:
|
case OPT_DPASS:
|
||||||
@@ -1643,6 +1655,11 @@ int s_server_main(int argc, char *argv[])
|
|||||||
case OPT_HTTP_SERVER_BINMODE:
|
case OPT_HTTP_SERVER_BINMODE:
|
||||||
http_server_binmode = 1;
|
http_server_binmode = 1;
|
||||||
break;
|
break;
|
||||||
|
case OPT_SENDFILE:
|
||||||
|
#ifndef OPENSSL_NO_KTLS
|
||||||
|
use_sendfile = 1;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
argc = opt_num_rest();
|
argc = opt_num_rest();
|
||||||
@@ -1695,6 +1712,13 @@ int s_server_main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef OPENSSL_NO_KTLS
|
||||||
|
if (use_sendfile && www <= 1) {
|
||||||
|
BIO_printf(bio_err, "Can't use -sendfile without -WWW or -HTTP\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!app_passwd(passarg, dpassarg, &pass, &dpass)) {
|
if (!app_passwd(passarg, dpassarg, &pass, &dpass)) {
|
||||||
BIO_printf(bio_err, "Error getting password\n");
|
BIO_printf(bio_err, "Error getting password\n");
|
||||||
goto end;
|
goto end;
|
||||||
@@ -1712,18 +1736,14 @@ int s_server_main(int argc, char *argv[])
|
|||||||
if (nocert == 0) {
|
if (nocert == 0) {
|
||||||
s_key = load_key(s_key_file, s_key_format, 0, pass, engine,
|
s_key = load_key(s_key_file, s_key_format, 0, pass, engine,
|
||||||
"server certificate private key file");
|
"server certificate private key file");
|
||||||
if (s_key == NULL) {
|
if (s_key == NULL)
|
||||||
ERR_print_errors(bio_err);
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
|
||||||
|
|
||||||
s_cert = load_cert(s_cert_file, s_cert_format,
|
s_cert = load_cert(s_cert_file, s_cert_format,
|
||||||
"server certificate file");
|
"server certificate file");
|
||||||
|
|
||||||
if (s_cert == NULL) {
|
if (s_cert == NULL)
|
||||||
ERR_print_errors(bio_err);
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
|
||||||
if (s_chain_file != NULL) {
|
if (s_chain_file != NULL) {
|
||||||
if (!load_certs(s_chain_file, &s_chain, FORMAT_PEM, NULL,
|
if (!load_certs(s_chain_file, &s_chain, FORMAT_PEM, NULL,
|
||||||
"server certificate chain"))
|
"server certificate chain"))
|
||||||
@@ -1733,20 +1753,16 @@ int s_server_main(int argc, char *argv[])
|
|||||||
if (tlsextcbp.servername != NULL) {
|
if (tlsextcbp.servername != NULL) {
|
||||||
s_key2 = load_key(s_key_file2, s_key_format, 0, pass, engine,
|
s_key2 = load_key(s_key_file2, s_key_format, 0, pass, engine,
|
||||||
"second server certificate private key file");
|
"second server certificate private key file");
|
||||||
if (s_key2 == NULL) {
|
if (s_key2 == NULL)
|
||||||
ERR_print_errors(bio_err);
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
|
||||||
|
|
||||||
s_cert2 = load_cert(s_cert_file2, s_cert_format,
|
s_cert2 = load_cert(s_cert_file2, s_cert_format,
|
||||||
"second server certificate file");
|
"second server certificate file");
|
||||||
|
|
||||||
if (s_cert2 == NULL) {
|
if (s_cert2 == NULL)
|
||||||
ERR_print_errors(bio_err);
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#if !defined(OPENSSL_NO_NEXTPROTONEG)
|
#if !defined(OPENSSL_NO_NEXTPROTONEG)
|
||||||
if (next_proto_neg_in) {
|
if (next_proto_neg_in) {
|
||||||
next_proto.data = next_protos_parse(&next_proto.len, next_proto_neg_in);
|
next_proto.data = next_protos_parse(&next_proto.len, next_proto_neg_in);
|
||||||
@@ -1763,12 +1779,9 @@ int s_server_main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (crl_file != NULL) {
|
if (crl_file != NULL) {
|
||||||
X509_CRL *crl;
|
X509_CRL *crl;
|
||||||
crl = load_crl(crl_file, crl_format);
|
crl = load_crl(crl_file, crl_format, "CRL");
|
||||||
if (crl == NULL) {
|
if (crl == NULL)
|
||||||
BIO_puts(bio_err, "Error loading CRL\n");
|
|
||||||
ERR_print_errors(bio_err);
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
|
||||||
crls = sk_X509_CRL_new_null();
|
crls = sk_X509_CRL_new_null();
|
||||||
if (crls == NULL || !sk_X509_CRL_push(crls, crl)) {
|
if (crls == NULL || !sk_X509_CRL_push(crls, crl)) {
|
||||||
BIO_puts(bio_err, "Error adding CRL\n");
|
BIO_puts(bio_err, "Error adding CRL\n");
|
||||||
@@ -1785,10 +1798,8 @@ int s_server_main(int argc, char *argv[])
|
|||||||
|
|
||||||
s_dkey = load_key(s_dkey_file, s_dkey_format,
|
s_dkey = load_key(s_dkey_file, s_dkey_format,
|
||||||
0, dpass, engine, "second certificate private key file");
|
0, dpass, engine, "second certificate private key file");
|
||||||
if (s_dkey == NULL) {
|
if (s_dkey == NULL)
|
||||||
ERR_print_errors(bio_err);
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
|
||||||
|
|
||||||
s_dcert = load_cert(s_dcert_file, s_dcert_format,
|
s_dcert = load_cert(s_dcert_file, s_dcert_format,
|
||||||
"second server certificate file");
|
"second server certificate file");
|
||||||
@@ -1958,7 +1969,7 @@ int s_server_main(int argc, char *argv[])
|
|||||||
BIO_printf(bio_s_out, "Setting secondary ctx parameters\n");
|
BIO_printf(bio_s_out, "Setting secondary ctx parameters\n");
|
||||||
|
|
||||||
if (sdebug)
|
if (sdebug)
|
||||||
ssl_ctx_security_debug(ctx, sdebug);
|
ssl_ctx_security_debug(ctx2, sdebug);
|
||||||
|
|
||||||
if (session_id_prefix) {
|
if (session_id_prefix) {
|
||||||
if (strlen(session_id_prefix) >= 32)
|
if (strlen(session_id_prefix) >= 32)
|
||||||
@@ -2093,11 +2104,17 @@ int s_server_main(int argc, char *argv[])
|
|||||||
SSL_CTX_set_psk_server_callback(ctx, psk_server_cb);
|
SSL_CTX_set_psk_server_callback(ctx, psk_server_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (psk_identity_hint != NULL) {
|
||||||
|
if (min_version == TLS1_3_VERSION) {
|
||||||
|
BIO_printf(bio_s_out, "PSK warning: there is NO identity hint in TLSv1.3\n");
|
||||||
|
} else {
|
||||||
if (!SSL_CTX_use_psk_identity_hint(ctx, psk_identity_hint)) {
|
if (!SSL_CTX_use_psk_identity_hint(ctx, psk_identity_hint)) {
|
||||||
BIO_printf(bio_err, "error setting PSK identity hint to context\n");
|
BIO_printf(bio_err, "error setting PSK identity hint to context\n");
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (psksessf != NULL) {
|
if (psksessf != NULL) {
|
||||||
BIO *stmp = BIO_new_file(psksessf, "r");
|
BIO *stmp = BIO_new_file(psksessf, "r");
|
||||||
@@ -3330,6 +3347,47 @@ static int www_body(int s, int stype, int prot, unsigned char *context)
|
|||||||
"HTTP/1.0 200 ok\r\nContent-type: text/plain\r\n\r\n");
|
"HTTP/1.0 200 ok\r\nContent-type: text/plain\r\n\r\n");
|
||||||
}
|
}
|
||||||
/* send the file */
|
/* send the file */
|
||||||
|
#ifndef OPENSSL_NO_KTLS
|
||||||
|
if (use_sendfile) {
|
||||||
|
FILE *fp = NULL;
|
||||||
|
int fd;
|
||||||
|
struct stat st;
|
||||||
|
off_t offset = 0;
|
||||||
|
size_t filesize;
|
||||||
|
|
||||||
|
BIO_get_fp(file, &fp);
|
||||||
|
fd = fileno(fp);
|
||||||
|
if (fstat(fd, &st) < 0) {
|
||||||
|
BIO_printf(io, "Error fstat '%s'\r\n", p);
|
||||||
|
ERR_print_errors(io);
|
||||||
|
goto write_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
filesize = st.st_size;
|
||||||
|
if (((int)BIO_flush(io)) < 0)
|
||||||
|
goto write_error;
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
i = SSL_sendfile(con, fd, offset, filesize, 0);
|
||||||
|
if (i < 0) {
|
||||||
|
BIO_printf(io, "Error SSL_sendfile '%s'\r\n", p);
|
||||||
|
ERR_print_errors(io);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
offset += i;
|
||||||
|
filesize -= i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filesize <= 0) {
|
||||||
|
if (!s_quiet)
|
||||||
|
BIO_printf(bio_err, "KTLS SENDFILE '%s' OK\n", p);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
for (;;) {
|
for (;;) {
|
||||||
i = BIO_read(file, buf, bufsize);
|
i = BIO_read(file, buf, bufsize);
|
||||||
if (i <= 0)
|
if (i <= 0)
|
||||||
@@ -3348,16 +3406,15 @@ static int www_body(int s, int stype, int prot, unsigned char *context)
|
|||||||
for (j = 0; j < i;) {
|
for (j = 0; j < i;) {
|
||||||
#ifdef RENEG
|
#ifdef RENEG
|
||||||
static count = 0;
|
static count = 0;
|
||||||
if (++count == 13) {
|
if (++count == 13)
|
||||||
SSL_renegotiate(con);
|
SSL_renegotiate(con);
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
k = BIO_write(io, &(buf[j]), i - j);
|
k = BIO_write(io, &(buf[j]), i - j);
|
||||||
if (k <= 0) {
|
if (k <= 0) {
|
||||||
if (!BIO_should_retry(io)
|
if (!BIO_should_retry(io)
|
||||||
&& !SSL_waiting_for_async(con))
|
&& !SSL_waiting_for_async(con)) {
|
||||||
goto write_error;
|
goto write_error;
|
||||||
else {
|
} else {
|
||||||
BIO_printf(bio_s_out, "rwrite W BLOCK\n");
|
BIO_printf(bio_s_out, "rwrite W BLOCK\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -3365,6 +3422,7 @@ static int www_body(int s, int stype, int prot, unsigned char *context)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
write_error:
|
write_error:
|
||||||
BIO_free(file);
|
BIO_free(file);
|
||||||
break;
|
break;
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -86,7 +86,7 @@ const OPTIONS s_time_options[] = {
|
|||||||
{"www", OPT_WWW, 's', "Fetch specified page from the site"},
|
{"www", OPT_WWW, 's', "Fetch specified page from the site"},
|
||||||
|
|
||||||
OPT_SECTION("Certificate"),
|
OPT_SECTION("Certificate"),
|
||||||
{"nameopt", OPT_NAMEOPT, 's', "Various certificate name options"},
|
{"nameopt", OPT_NAMEOPT, 's', "Certificate subject/issuer name printing options"},
|
||||||
{"cert", OPT_CERT, '<', "Cert file to use, PEM format assumed"},
|
{"cert", OPT_CERT, '<', "Cert file to use, PEM format assumed"},
|
||||||
{"key", OPT_KEY, '<', "File with key, PEM; default is -cert file"},
|
{"key", OPT_KEY, '<', "File with key, PEM; default is -cert file"},
|
||||||
{"cafile", OPT_CAFILE, '<', "PEM format file of CA's"},
|
{"cafile", OPT_CAFILE, '<', "PEM format file of CA's"},
|
||||||
|
|||||||
+4
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -19,6 +19,9 @@
|
|||||||
#include <openssl/x509_vfy.h>
|
#include <openssl/x509_vfy.h>
|
||||||
#include <openssl/x509v3.h>
|
#include <openssl/x509v3.h>
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(X509)
|
||||||
|
DEFINE_STACK_OF_STRING()
|
||||||
|
|
||||||
static int save_certs(char *signerfile, STACK_OF(X509) *signers);
|
static int save_certs(char *signerfile, STACK_OF(X509) *signers);
|
||||||
static int smime_cb(int ok, X509_STORE_CTX *ctx);
|
static int smime_cb(int ok, X509_STORE_CTX *ctx);
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
|
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
@@ -3465,7 +3465,7 @@ int speed_main(int argc, char **argv)
|
|||||||
d = Time_F(STOP);
|
d = Time_F(STOP);
|
||||||
|
|
||||||
BIO_printf(bio_err,
|
BIO_printf(bio_err,
|
||||||
mr ? "+R8:%ld:%u:%s:%.2f\n" :
|
mr ? "+R10:%ld:%u:%s:%.2f\n" :
|
||||||
"%ld %u bits %s signs in %.2fs \n",
|
"%ld %u bits %s signs in %.2fs \n",
|
||||||
count, sm2_curves[testnum].bits,
|
count, sm2_curves[testnum].bits,
|
||||||
sm2_curves[testnum].name, d);
|
sm2_curves[testnum].name, d);
|
||||||
@@ -3494,7 +3494,7 @@ int speed_main(int argc, char **argv)
|
|||||||
count = run_benchmark(async_jobs, SM2_verify_loop, loopargs);
|
count = run_benchmark(async_jobs, SM2_verify_loop, loopargs);
|
||||||
d = Time_F(STOP);
|
d = Time_F(STOP);
|
||||||
BIO_printf(bio_err,
|
BIO_printf(bio_err,
|
||||||
mr ? "+R9:%ld:%u:%s:%.2f\n"
|
mr ? "+R11:%ld:%u:%s:%.2f\n"
|
||||||
: "%ld %u bits %s verify in %.2fs\n",
|
: "%ld %u bits %s verify in %.2fs\n",
|
||||||
count, sm2_curves[testnum].bits,
|
count, sm2_curves[testnum].bits,
|
||||||
sm2_curves[testnum].name, d);
|
sm2_curves[testnum].name, d);
|
||||||
@@ -3676,7 +3676,7 @@ int speed_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mr)
|
if (mr)
|
||||||
printf("+F6:%u:%u:%s:%f:%f\n",
|
printf("+F7:%u:%u:%s:%f:%f\n",
|
||||||
k, sm2_curves[k].bits, sm2_curves[k].name,
|
k, sm2_curves[k].bits, sm2_curves[k].name,
|
||||||
sm2_results[k][0], sm2_results[k][1]);
|
sm2_results[k][0], sm2_results[k][1]);
|
||||||
else
|
else
|
||||||
@@ -3969,6 +3969,7 @@ static int do_multi(int multi, int size_num)
|
|||||||
p = buf + 4;
|
p = buf + 4;
|
||||||
k = atoi(sstrsep(&p, sep));
|
k = atoi(sstrsep(&p, sep));
|
||||||
sstrsep(&p, sep);
|
sstrsep(&p, sep);
|
||||||
|
sstrsep(&p, sep);
|
||||||
|
|
||||||
d = atof(sstrsep(&p, sep));
|
d = atof(sstrsep(&p, sep));
|
||||||
sm2_results[k][0] += d;
|
sm2_results[k][0] += d;
|
||||||
|
|||||||
+10
-3
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -145,8 +145,15 @@ int spkac_main(int argc, char **argv)
|
|||||||
if (challenge != NULL)
|
if (challenge != NULL)
|
||||||
ASN1_STRING_set(spki->spkac->challenge,
|
ASN1_STRING_set(spki->spkac->challenge,
|
||||||
challenge, (int)strlen(challenge));
|
challenge, (int)strlen(challenge));
|
||||||
NETSCAPE_SPKI_set_pubkey(spki, pkey);
|
if (!NETSCAPE_SPKI_set_pubkey(spki, pkey)) {
|
||||||
NETSCAPE_SPKI_sign(spki, pkey, EVP_md5());
|
BIO_printf(bio_err, "Error setting public key\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
i = NETSCAPE_SPKI_sign(spki, pkey, EVP_md5());
|
||||||
|
if (i <= 0) {
|
||||||
|
BIO_printf(bio_err, "Error signing SPKAC\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
spkstr = NETSCAPE_SPKI_b64_encode(spki);
|
spkstr = NETSCAPE_SPKI_b64_encode(spki);
|
||||||
if (spkstr == NULL)
|
if (spkstr == NULL)
|
||||||
goto end;
|
goto end;
|
||||||
|
|||||||
+18
-22
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2004-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
* Copyright (c) 2004, EdelKey Project. All Rights Reserved.
|
* Copyright (c) 2004, EdelKey Project. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
@@ -12,28 +12,25 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <openssl/opensslconf.h>
|
#include <openssl/opensslconf.h>
|
||||||
#ifdef OPENSSL_NO_SRP
|
|
||||||
NON_EMPTY_TRANSLATION_UNIT
|
|
||||||
#else
|
|
||||||
|
|
||||||
# include <stdio.h>
|
#include <stdio.h>
|
||||||
# include <stdlib.h>
|
#include <stdlib.h>
|
||||||
# include <string.h>
|
#include <string.h>
|
||||||
# include <openssl/conf.h>
|
#include <openssl/conf.h>
|
||||||
# include <openssl/bio.h>
|
#include <openssl/bio.h>
|
||||||
# include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
# include <openssl/txt_db.h>
|
#include <openssl/txt_db.h>
|
||||||
# include <openssl/buffer.h>
|
#include <openssl/buffer.h>
|
||||||
# include <openssl/srp.h>
|
#include <openssl/srp.h>
|
||||||
# include "apps.h"
|
#include "apps.h"
|
||||||
# include "progs.h"
|
#include "progs.h"
|
||||||
|
|
||||||
# define BASE_SECTION "srp"
|
#define BASE_SECTION "srp"
|
||||||
# define CONFIG_FILE "openssl.cnf"
|
#define CONFIG_FILE "openssl.cnf"
|
||||||
|
|
||||||
|
|
||||||
# define ENV_DATABASE "srpvfile"
|
#define ENV_DATABASE "srpvfile"
|
||||||
# define ENV_DEFAULT_SRP "default_srp"
|
#define ENV_DEFAULT_SRP "default_srp"
|
||||||
|
|
||||||
static int get_index(CA_DB *db, char *id, char type)
|
static int get_index(CA_DB *db, char *id, char type)
|
||||||
{
|
{
|
||||||
@@ -204,9 +201,9 @@ const OPTIONS srp_options[] = {
|
|||||||
{"verbose", OPT_VERBOSE, '-', "Talk a lot while doing things"},
|
{"verbose", OPT_VERBOSE, '-', "Talk a lot while doing things"},
|
||||||
{"config", OPT_CONFIG, '<', "A config file"},
|
{"config", OPT_CONFIG, '<', "A config file"},
|
||||||
{"name", OPT_NAME, 's', "The particular srp definition to use"},
|
{"name", OPT_NAME, 's', "The particular srp definition to use"},
|
||||||
# ifndef OPENSSL_NO_ENGINE
|
#ifndef OPENSSL_NO_ENGINE
|
||||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
OPT_SECTION("Action"),
|
OPT_SECTION("Action"),
|
||||||
{"add", OPT_ADD, '-', "Add a user and srp verifier"},
|
{"add", OPT_ADD, '-', "Add a user and srp verifier"},
|
||||||
@@ -625,4 +622,3 @@ int srp_main(int argc, char **argv)
|
|||||||
release_engine(e);
|
release_engine(e);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -8,29 +8,26 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <openssl/opensslconf.h>
|
#include <openssl/opensslconf.h>
|
||||||
#ifdef OPENSSL_NO_TS
|
#include <stdio.h>
|
||||||
NON_EMPTY_TRANSLATION_UNIT
|
#include <stdlib.h>
|
||||||
#else
|
#include <string.h>
|
||||||
# include <stdio.h>
|
#include "apps.h"
|
||||||
# include <stdlib.h>
|
#include "progs.h"
|
||||||
# include <string.h>
|
#include <openssl/bio.h>
|
||||||
# include "apps.h"
|
#include <openssl/err.h>
|
||||||
# include "progs.h"
|
#include <openssl/pem.h>
|
||||||
# include <openssl/bio.h>
|
#include <openssl/rand.h>
|
||||||
# include <openssl/err.h>
|
#include <openssl/ts.h>
|
||||||
# include <openssl/pem.h>
|
#include <openssl/bn.h>
|
||||||
# include <openssl/rand.h>
|
|
||||||
# include <openssl/ts.h>
|
|
||||||
# include <openssl/bn.h>
|
|
||||||
|
|
||||||
/* Request nonce length, in bits (must be a multiple of 8). */
|
/* Request nonce length, in bits (must be a multiple of 8). */
|
||||||
# define NONCE_LENGTH 64
|
#define NONCE_LENGTH 64
|
||||||
|
|
||||||
/* Name of config entry that defines the OID file. */
|
/* Name of config entry that defines the OID file. */
|
||||||
# define ENV_OID_FILE "oid_file"
|
#define ENV_OID_FILE "oid_file"
|
||||||
|
|
||||||
/* Is |EXACTLY_ONE| of three pointers set? */
|
/* Is |EXACTLY_ONE| of three pointers set? */
|
||||||
# define EXACTLY_ONE(a, b, c) \
|
#define EXACTLY_ONE(a, b, c) \
|
||||||
(( a && !b && !c) || \
|
(( a && !b && !c) || \
|
||||||
( b && !a && !c) || \
|
( b && !a && !c) || \
|
||||||
( c && !a && !b))
|
( c && !a && !b))
|
||||||
@@ -94,14 +91,14 @@ const OPTIONS ts_options[] = {
|
|||||||
{"help", OPT_HELP, '-', "Display this summary"},
|
{"help", OPT_HELP, '-', "Display this summary"},
|
||||||
{"config", OPT_CONFIG, '<', "Configuration file"},
|
{"config", OPT_CONFIG, '<', "Configuration file"},
|
||||||
{"section", OPT_SECTION, 's', "Section to use within config file"},
|
{"section", OPT_SECTION, 's', "Section to use within config file"},
|
||||||
# ifndef OPENSSL_NO_ENGINE
|
#ifndef OPENSSL_NO_ENGINE
|
||||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||||
# endif
|
#endif
|
||||||
{"inkey", OPT_INKEY, 's', "File with private key for reply"},
|
{"inkey", OPT_INKEY, 's', "File with private key for reply"},
|
||||||
{"signer", OPT_SIGNER, 's', "Signer certificate file"},
|
{"signer", OPT_SIGNER, 's', "Signer certificate file"},
|
||||||
{"chain", OPT_CHAIN, '<', "File with signer CA chain"},
|
{"chain", OPT_CHAIN, '<', "File with signer CA chain"},
|
||||||
{"CApath", OPT_CAPATH, '/', "Path to trusted CA files"},
|
|
||||||
{"CAfile", OPT_CAFILE, '<', "File with trusted CA certs"},
|
{"CAfile", OPT_CAFILE, '<', "File with trusted CA certs"},
|
||||||
|
{"CApath", OPT_CAPATH, '/', "Path to trusted CA files"},
|
||||||
{"CAstore", OPT_CASTORE, ':', "URI to trusted CA store"},
|
{"CAstore", OPT_CASTORE, ':', "URI to trusted CA store"},
|
||||||
{"untrusted", OPT_UNTRUSTED, '<', "File with untrusted certs"},
|
{"untrusted", OPT_UNTRUSTED, '<', "File with untrusted certs"},
|
||||||
{"token_in", OPT_TOKEN_IN, '-', "Input is a PKCS#7 file"},
|
{"token_in", OPT_TOKEN_IN, '-', "Input is a PKCS#7 file"},
|
||||||
@@ -146,11 +143,11 @@ static char* opt_helplist[] = {
|
|||||||
" [-signer tsa_cert.pem] [-inkey private_key.pem]",
|
" [-signer tsa_cert.pem] [-inkey private_key.pem]",
|
||||||
" [-chain certs_file.pem] [-tspolicy oid]",
|
" [-chain certs_file.pem] [-tspolicy oid]",
|
||||||
" [-in file] [-token_in] [-out file] [-token_out]",
|
" [-in file] [-token_in] [-out file] [-token_out]",
|
||||||
# ifndef OPENSSL_NO_ENGINE
|
#ifndef OPENSSL_NO_ENGINE
|
||||||
" [-text] [-engine id]",
|
" [-text] [-engine id]",
|
||||||
# else
|
#else
|
||||||
" [-text]",
|
" [-text]",
|
||||||
# endif
|
#endif
|
||||||
"",
|
"",
|
||||||
" openssl ts -verify -CApath dir -CAfile file.pem -CAstore uri",
|
" openssl ts -verify -CApath dir -CAfile file.pem -CAstore uri",
|
||||||
" -untrusted file.pem [-data file] [-digest hexstring]",
|
" -untrusted file.pem [-data file] [-digest hexstring]",
|
||||||
@@ -699,10 +696,10 @@ static TS_RESP *create_response(CONF *conf, const char *section, const char *eng
|
|||||||
goto end;
|
goto end;
|
||||||
if (!TS_CONF_set_serial(conf, section, serial_cb, resp_ctx))
|
if (!TS_CONF_set_serial(conf, section, serial_cb, resp_ctx))
|
||||||
goto end;
|
goto end;
|
||||||
# ifndef OPENSSL_NO_ENGINE
|
#ifndef OPENSSL_NO_ENGINE
|
||||||
if (!TS_CONF_set_crypto_device(conf, section, engine))
|
if (!TS_CONF_set_crypto_device(conf, section, engine))
|
||||||
goto end;
|
goto end;
|
||||||
# endif
|
#endif
|
||||||
if (!TS_CONF_set_signer_cert(conf, section, signer, resp_ctx))
|
if (!TS_CONF_set_signer_cert(conf, section, signer, resp_ctx))
|
||||||
goto end;
|
goto end;
|
||||||
if (!TS_CONF_set_certs(conf, section, chain, resp_ctx))
|
if (!TS_CONF_set_certs(conf, section, chain, resp_ctx))
|
||||||
@@ -1013,4 +1010,3 @@ static int verify_cb(int ok, X509_STORE_CTX *ctx)
|
|||||||
{
|
{
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
#endif /* ndef OPENSSL_NO_TS */
|
|
||||||
+36
-65
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -18,11 +18,15 @@
|
|||||||
#include <openssl/x509v3.h>
|
#include <openssl/x509v3.h>
|
||||||
#include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(X509)
|
||||||
|
DEFINE_STACK_OF(X509_CRL)
|
||||||
|
DEFINE_STACK_OF_STRING()
|
||||||
|
|
||||||
static int cb(int ok, X509_STORE_CTX *ctx);
|
static int cb(int ok, X509_STORE_CTX *ctx);
|
||||||
static int check(X509_STORE *ctx, const char *file,
|
static int check(X509_STORE *ctx, const char *file,
|
||||||
STACK_OF(X509) *uchain, STACK_OF(X509) *tchain,
|
STACK_OF(X509) *uchain, STACK_OF(X509) *tchain,
|
||||||
STACK_OF(X509_CRL) *crls, int show_chain,
|
STACK_OF(X509_CRL) *crls, int show_chain,
|
||||||
unsigned char *sm2id, size_t sm2idlen);
|
STACK_OF(OPENSSL_STRING) *opts);
|
||||||
static int v_verbose = 0, vflags = 0;
|
static int v_verbose = 0, vflags = 0;
|
||||||
|
|
||||||
typedef enum OPTION_choice {
|
typedef enum OPTION_choice {
|
||||||
@@ -30,8 +34,8 @@ typedef enum OPTION_choice {
|
|||||||
OPT_ENGINE, OPT_CAPATH, OPT_CAFILE, OPT_CASTORE,
|
OPT_ENGINE, OPT_CAPATH, OPT_CAFILE, OPT_CASTORE,
|
||||||
OPT_NOCAPATH, OPT_NOCAFILE, OPT_NOCASTORE,
|
OPT_NOCAPATH, OPT_NOCAFILE, OPT_NOCASTORE,
|
||||||
OPT_UNTRUSTED, OPT_TRUSTED, OPT_CRLFILE, OPT_CRL_DOWNLOAD, OPT_SHOW_CHAIN,
|
OPT_UNTRUSTED, OPT_TRUSTED, OPT_CRLFILE, OPT_CRL_DOWNLOAD, OPT_SHOW_CHAIN,
|
||||||
OPT_V_ENUM, OPT_NAMEOPT,
|
OPT_V_ENUM, OPT_NAMEOPT, OPT_VFYOPT,
|
||||||
OPT_VERBOSE, OPT_SM2ID, OPT_SM2HEXID,
|
OPT_VERBOSE,
|
||||||
OPT_PROV_ENUM
|
OPT_PROV_ENUM
|
||||||
} OPTION_CHOICE;
|
} OPTION_CHOICE;
|
||||||
|
|
||||||
@@ -45,34 +49,29 @@ const OPTIONS verify_options[] = {
|
|||||||
#endif
|
#endif
|
||||||
{"verbose", OPT_VERBOSE, '-',
|
{"verbose", OPT_VERBOSE, '-',
|
||||||
"Print extra information about the operations being performed."},
|
"Print extra information about the operations being performed."},
|
||||||
{"nameopt", OPT_NAMEOPT, 's', "Various certificate name options"},
|
{"nameopt", OPT_NAMEOPT, 's', "Certificate subject/issuer name printing options"},
|
||||||
|
|
||||||
OPT_SECTION("Certificate chain"),
|
OPT_SECTION("Certificate chain"),
|
||||||
{"CApath", OPT_CAPATH, '/', "A directory of trusted certificates"},
|
{"trusted", OPT_TRUSTED, '<', "A file of trusted certificates"},
|
||||||
{"CAfile", OPT_CAFILE, '<', "A file of trusted certificates"},
|
{"CAfile", OPT_CAFILE, '<', "A file of trusted certificates"},
|
||||||
|
{"CApath", OPT_CAPATH, '/', "A directory of files with trusted certificates"},
|
||||||
{"CAstore", OPT_CASTORE, ':', "URI to a store of trusted certificates"},
|
{"CAstore", OPT_CASTORE, ':', "URI to a store of trusted certificates"},
|
||||||
{"no-CAfile", OPT_NOCAFILE, '-',
|
{"no-CAfile", OPT_NOCAFILE, '-',
|
||||||
"Do not load the default certificates file"},
|
"Do not load the default trusted certificates file"},
|
||||||
{"no-CApath", OPT_NOCAPATH, '-',
|
{"no-CApath", OPT_NOCAPATH, '-',
|
||||||
"Do not load certificates from the default certificates directory"},
|
"Do not load trusted certificates from the default directory"},
|
||||||
{"no-CAstore", OPT_NOCAPATH, '-',
|
{"no-CAstore", OPT_NOCAPATH, '-',
|
||||||
"Do not load certificates from the default certificates store"},
|
"Do not load trusted certificates from the default certificates store"},
|
||||||
{"untrusted", OPT_UNTRUSTED, '<', "A file of untrusted certificates"},
|
{"untrusted", OPT_UNTRUSTED, '<', "A file of untrusted certificates"},
|
||||||
{"trusted", OPT_TRUSTED, '<', "A file of trusted certificates"},
|
|
||||||
{"CRLfile", OPT_CRLFILE, '<',
|
{"CRLfile", OPT_CRLFILE, '<',
|
||||||
"File containing one or more CRL's (in PEM format) to load"},
|
"File containing one or more CRL's (in PEM format) to load"},
|
||||||
{"crl_download", OPT_CRL_DOWNLOAD, '-',
|
{"crl_download", OPT_CRL_DOWNLOAD, '-',
|
||||||
"Attempt to download CRL information for this certificate"},
|
"Try downloading CRL information for certificates via their CDP entries"},
|
||||||
{"show_chain", OPT_SHOW_CHAIN, '-',
|
{"show_chain", OPT_SHOW_CHAIN, '-',
|
||||||
"Display information about the certificate chain"},
|
"Display information about the certificate chain"},
|
||||||
|
|
||||||
OPT_V_OPTIONS,
|
OPT_V_OPTIONS,
|
||||||
#ifndef OPENSSL_NO_SM2
|
{"vfyopt", OPT_VFYOPT, 's', "Verification parameter in n:v form"},
|
||||||
{"sm2-id", OPT_SM2ID, 's',
|
|
||||||
"Specify an ID string to verify an SM2 certificate"},
|
|
||||||
{"sm2-hex-id", OPT_SM2HEXID, 's',
|
|
||||||
"Specify a hex ID string to verify an SM2 certificate"},
|
|
||||||
#endif
|
|
||||||
|
|
||||||
OPT_PROV_OPTIONS,
|
OPT_PROV_OPTIONS,
|
||||||
|
|
||||||
@@ -86,15 +85,13 @@ int verify_main(int argc, char **argv)
|
|||||||
ENGINE *e = NULL;
|
ENGINE *e = NULL;
|
||||||
STACK_OF(X509) *untrusted = NULL, *trusted = NULL;
|
STACK_OF(X509) *untrusted = NULL, *trusted = NULL;
|
||||||
STACK_OF(X509_CRL) *crls = NULL;
|
STACK_OF(X509_CRL) *crls = NULL;
|
||||||
|
STACK_OF(OPENSSL_STRING) *vfyopts = NULL;
|
||||||
X509_STORE *store = NULL;
|
X509_STORE *store = NULL;
|
||||||
X509_VERIFY_PARAM *vpm = NULL;
|
X509_VERIFY_PARAM *vpm = NULL;
|
||||||
const char *prog, *CApath = NULL, *CAfile = NULL, *CAstore = NULL;
|
const char *prog, *CApath = NULL, *CAfile = NULL, *CAstore = NULL;
|
||||||
int noCApath = 0, noCAfile = 0, noCAstore = 0;
|
int noCApath = 0, noCAfile = 0, noCAstore = 0;
|
||||||
int vpmtouched = 0, crl_download = 0, show_chain = 0, i = 0, ret = 1;
|
int vpmtouched = 0, crl_download = 0, show_chain = 0, i = 0, ret = 1;
|
||||||
OPTION_CHOICE o;
|
OPTION_CHOICE o;
|
||||||
unsigned char *sm2_id = NULL;
|
|
||||||
size_t sm2_idlen = 0;
|
|
||||||
int sm2_free = 0;
|
|
||||||
|
|
||||||
if ((vpm = X509_VERIFY_PARAM_new()) == NULL)
|
if ((vpm = X509_VERIFY_PARAM_new()) == NULL)
|
||||||
goto end;
|
goto end;
|
||||||
@@ -104,6 +101,7 @@ int verify_main(int argc, char **argv)
|
|||||||
switch (o) {
|
switch (o) {
|
||||||
case OPT_EOF:
|
case OPT_EOF:
|
||||||
case OPT_ERR:
|
case OPT_ERR:
|
||||||
|
opthelp:
|
||||||
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
||||||
goto end;
|
goto end;
|
||||||
case OPT_HELP:
|
case OPT_HELP:
|
||||||
@@ -186,32 +184,15 @@ int verify_main(int argc, char **argv)
|
|||||||
if (!set_nameopt(opt_arg()))
|
if (!set_nameopt(opt_arg()))
|
||||||
goto end;
|
goto end;
|
||||||
break;
|
break;
|
||||||
|
case OPT_VFYOPT:
|
||||||
|
if (!vfyopts)
|
||||||
|
vfyopts = sk_OPENSSL_STRING_new_null();
|
||||||
|
if (!vfyopts || !sk_OPENSSL_STRING_push(vfyopts, opt_arg()))
|
||||||
|
goto opthelp;
|
||||||
|
break;
|
||||||
case OPT_VERBOSE:
|
case OPT_VERBOSE:
|
||||||
v_verbose = 1;
|
v_verbose = 1;
|
||||||
break;
|
break;
|
||||||
case OPT_SM2ID:
|
|
||||||
if (sm2_id != NULL) {
|
|
||||||
BIO_printf(bio_err,
|
|
||||||
"Use one of the options 'sm2-hex-id' or 'sm2-id' \n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
sm2_id = (unsigned char *)opt_arg();
|
|
||||||
sm2_idlen = strlen((const char *)sm2_id);
|
|
||||||
break;
|
|
||||||
case OPT_SM2HEXID:
|
|
||||||
if (sm2_id != NULL) {
|
|
||||||
BIO_printf(bio_err,
|
|
||||||
"Use one of the options 'sm2-hex-id' or 'sm2-id' \n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
/* try to parse the input as hex string first */
|
|
||||||
sm2_free = 1;
|
|
||||||
sm2_id = OPENSSL_hexstr2buf(opt_arg(), (long *)&sm2_idlen);
|
|
||||||
if (sm2_id == NULL) {
|
|
||||||
BIO_printf(bio_err, "Invalid hex string input\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OPT_PROV_CASES:
|
case OPT_PROV_CASES:
|
||||||
if (!opt_provider(o))
|
if (!opt_provider(o))
|
||||||
goto end;
|
goto end;
|
||||||
@@ -244,23 +225,22 @@ int verify_main(int argc, char **argv)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
if (argc < 1) {
|
if (argc < 1) {
|
||||||
if (check(store, NULL, untrusted, trusted, crls, show_chain,
|
if (check(store, NULL, untrusted, trusted, crls, show_chain,
|
||||||
sm2_id, sm2_idlen) != 1)
|
vfyopts) != 1)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < argc; i++)
|
for (i = 0; i < argc; i++)
|
||||||
if (check(store, argv[i], untrusted, trusted, crls,
|
if (check(store, argv[i], untrusted, trusted, crls, show_chain,
|
||||||
show_chain, sm2_id, sm2_idlen) != 1)
|
vfyopts) != 1)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
if (sm2_free)
|
|
||||||
OPENSSL_free(sm2_id);
|
|
||||||
X509_VERIFY_PARAM_free(vpm);
|
X509_VERIFY_PARAM_free(vpm);
|
||||||
X509_STORE_free(store);
|
X509_STORE_free(store);
|
||||||
sk_X509_pop_free(untrusted, X509_free);
|
sk_X509_pop_free(untrusted, X509_free);
|
||||||
sk_X509_pop_free(trusted, X509_free);
|
sk_X509_pop_free(trusted, X509_free);
|
||||||
sk_X509_CRL_pop_free(crls, X509_CRL_free);
|
sk_X509_CRL_pop_free(crls, X509_CRL_free);
|
||||||
|
sk_OPENSSL_STRING_free(vfyopts);
|
||||||
release_engine(e);
|
release_engine(e);
|
||||||
return (ret < 0 ? 2 : ret);
|
return (ret < 0 ? 2 : ret);
|
||||||
}
|
}
|
||||||
@@ -268,7 +248,7 @@ int verify_main(int argc, char **argv)
|
|||||||
static int check(X509_STORE *ctx, const char *file,
|
static int check(X509_STORE *ctx, const char *file,
|
||||||
STACK_OF(X509) *uchain, STACK_OF(X509) *tchain,
|
STACK_OF(X509) *uchain, STACK_OF(X509) *tchain,
|
||||||
STACK_OF(X509_CRL) *crls, int show_chain,
|
STACK_OF(X509_CRL) *crls, int show_chain,
|
||||||
unsigned char *sm2id, size_t sm2idlen)
|
STACK_OF(OPENSSL_STRING) *opts)
|
||||||
{
|
{
|
||||||
X509 *x = NULL;
|
X509 *x = NULL;
|
||||||
int i = 0, ret = 0;
|
int i = 0, ret = 0;
|
||||||
@@ -280,24 +260,15 @@ static int check(X509_STORE *ctx, const char *file,
|
|||||||
if (x == NULL)
|
if (x == NULL)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
if (sm2id != NULL) {
|
if (opts != NULL) {
|
||||||
#ifndef OPENSSL_NO_SM2
|
for (i = 0; i < sk_OPENSSL_STRING_num(opts); i++) {
|
||||||
ASN1_OCTET_STRING *v;
|
char *opt = sk_OPENSSL_STRING_value(opts, i);
|
||||||
|
if (x509_ctrl_string(x, opt) <= 0) {
|
||||||
v = ASN1_OCTET_STRING_new();
|
BIO_printf(bio_err, "parameter error \"%s\"\n", opt);
|
||||||
if (v == NULL) {
|
ERR_print_errors(bio_err);
|
||||||
BIO_printf(bio_err, "error: SM2 ID allocation failed\n");
|
return 0;
|
||||||
goto end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ASN1_OCTET_STRING_set(v, sm2id, sm2idlen)) {
|
|
||||||
BIO_printf(bio_err, "error: setting SM2 ID failed\n");
|
|
||||||
ASN1_OCTET_STRING_free(v);
|
|
||||||
goto end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
X509_set0_sm2_id(x, v);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
csc = X509_STORE_CTX_new();
|
csc = X509_STORE_CTX_new();
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
+28
-21
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -28,12 +28,18 @@
|
|||||||
# include <openssl/dsa.h>
|
# include <openssl/dsa.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
DEFINE_STACK_OF(ASN1_OBJECT)
|
||||||
|
DEFINE_STACK_OF(X509_EXTENSION)
|
||||||
|
DEFINE_STACK_OF_STRING()
|
||||||
|
|
||||||
#undef POSTFIX
|
#undef POSTFIX
|
||||||
#define POSTFIX ".srl"
|
#define POSTFIX ".srl"
|
||||||
#define DEF_DAYS 30
|
#define DEF_DAYS 30
|
||||||
|
|
||||||
static int callb(int ok, X509_STORE_CTX *ctx);
|
static int callb(int ok, X509_STORE_CTX *ctx);
|
||||||
static int sign(X509 *x, EVP_PKEY *pkey, EVP_PKEY *fkey, int days, int clrext,
|
static int sign(X509 *x, EVP_PKEY *pkey, EVP_PKEY *fkey,
|
||||||
|
STACK_OF(OPENSSL_STRING) *sigopts,
|
||||||
|
int days, int clrext,
|
||||||
const EVP_MD *digest, CONF *conf, const char *section,
|
const EVP_MD *digest, CONF *conf, const char *section,
|
||||||
int preserve_dates);
|
int preserve_dates);
|
||||||
static int x509_certify(X509_STORE *ctx, const char *CAfile, const EVP_MD *digest,
|
static int x509_certify(X509_STORE *ctx, const char *CAfile, const EVP_MD *digest,
|
||||||
@@ -48,7 +54,7 @@ static int print_x509v3_exts(BIO *bio, X509 *x, const char *exts);
|
|||||||
typedef enum OPTION_choice {
|
typedef enum OPTION_choice {
|
||||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||||
OPT_INFORM, OPT_OUTFORM, OPT_KEYFORM, OPT_REQ, OPT_CAFORM,
|
OPT_INFORM, OPT_OUTFORM, OPT_KEYFORM, OPT_REQ, OPT_CAFORM,
|
||||||
OPT_CAKEYFORM, OPT_SIGOPT, OPT_DAYS, OPT_PASSIN, OPT_EXTFILE,
|
OPT_CAKEYFORM, OPT_VFYOPT, OPT_SIGOPT, OPT_DAYS, OPT_PASSIN, OPT_EXTFILE,
|
||||||
OPT_EXTENSIONS, OPT_IN, OPT_OUT, OPT_SIGNKEY, OPT_CA, OPT_CAKEY,
|
OPT_EXTENSIONS, OPT_IN, OPT_OUT, OPT_SIGNKEY, OPT_CA, OPT_CAKEY,
|
||||||
OPT_CASERIAL, OPT_SET_SERIAL, OPT_NEW, OPT_FORCE_PUBKEY, OPT_SUBJ,
|
OPT_CASERIAL, OPT_SET_SERIAL, OPT_NEW, OPT_FORCE_PUBKEY, OPT_SUBJ,
|
||||||
OPT_ADDTRUST, OPT_ADDREJECT, OPT_SETALIAS, OPT_CERTOPT, OPT_NAMEOPT,
|
OPT_ADDTRUST, OPT_ADDREJECT, OPT_SETALIAS, OPT_CERTOPT, OPT_NAMEOPT,
|
||||||
@@ -80,6 +86,7 @@ const OPTIONS x509_options[] = {
|
|||||||
{"out", OPT_OUT, '>', "Output file - default stdout"},
|
{"out", OPT_OUT, '>', "Output file - default stdout"},
|
||||||
{"keyform", OPT_KEYFORM, 'E', "Private key format - default PEM"},
|
{"keyform", OPT_KEYFORM, 'E', "Private key format - default PEM"},
|
||||||
{"req", OPT_REQ, '-', "Input is a certificate request, sign and output"},
|
{"req", OPT_REQ, '-', "Input is a certificate request, sign and output"},
|
||||||
|
{"vfyopt", OPT_VFYOPT, 's', "Verification parameter in n:v form"},
|
||||||
|
|
||||||
OPT_SECTION("Output"),
|
OPT_SECTION("Output"),
|
||||||
{"serial", OPT_SERIAL, '-', "Print serial number value"},
|
{"serial", OPT_SERIAL, '-', "Print serial number value"},
|
||||||
@@ -114,7 +121,7 @@ const OPTIONS x509_options[] = {
|
|||||||
{"issuer_hash_old", OPT_ISSUER_HASH_OLD, '-',
|
{"issuer_hash_old", OPT_ISSUER_HASH_OLD, '-',
|
||||||
"Print old-style (MD5) subject hash value"},
|
"Print old-style (MD5) subject hash value"},
|
||||||
#endif
|
#endif
|
||||||
{"nameopt", OPT_NAMEOPT, 's', "Various certificate name options"},
|
{"nameopt", OPT_NAMEOPT, 's', "Certificate subject/issuer name printing options"},
|
||||||
|
|
||||||
OPT_SECTION("Certificate"),
|
OPT_SECTION("Certificate"),
|
||||||
{"startdate", OPT_STARTDATE, '-', "Set notBefore field"},
|
{"startdate", OPT_STARTDATE, '-', "Set notBefore field"},
|
||||||
@@ -174,7 +181,7 @@ int x509_main(int argc, char **argv)
|
|||||||
const unsigned long chtype = MBSTRING_ASC;
|
const unsigned long chtype = MBSTRING_ASC;
|
||||||
const int multirdn = 0;
|
const int multirdn = 0;
|
||||||
STACK_OF(ASN1_OBJECT) *trust = NULL, *reject = NULL;
|
STACK_OF(ASN1_OBJECT) *trust = NULL, *reject = NULL;
|
||||||
STACK_OF(OPENSSL_STRING) *sigopts = NULL;
|
STACK_OF(OPENSSL_STRING) *sigopts = NULL, *vfyopts = NULL;
|
||||||
X509 *x = NULL, *xca = NULL;
|
X509 *x = NULL, *xca = NULL;
|
||||||
X509_REQ *req = NULL, *rq = NULL;
|
X509_REQ *req = NULL, *rq = NULL;
|
||||||
X509_STORE *ctx = NULL;
|
X509_STORE *ctx = NULL;
|
||||||
@@ -256,6 +263,12 @@ int x509_main(int argc, char **argv)
|
|||||||
if (!sigopts || !sk_OPENSSL_STRING_push(sigopts, opt_arg()))
|
if (!sigopts || !sk_OPENSSL_STRING_push(sigopts, opt_arg()))
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
break;
|
break;
|
||||||
|
case OPT_VFYOPT:
|
||||||
|
if (!vfyopts)
|
||||||
|
vfyopts = sk_OPENSSL_STRING_new_null();
|
||||||
|
if (!vfyopts || !sk_OPENSSL_STRING_push(vfyopts, opt_arg()))
|
||||||
|
goto opthelp;
|
||||||
|
break;
|
||||||
case OPT_DAYS:
|
case OPT_DAYS:
|
||||||
if (preserve_dates)
|
if (preserve_dates)
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
@@ -559,24 +572,16 @@ int x509_main(int argc, char **argv)
|
|||||||
|
|
||||||
if (reqfile) {
|
if (reqfile) {
|
||||||
EVP_PKEY *pkey;
|
EVP_PKEY *pkey;
|
||||||
BIO *in;
|
|
||||||
|
|
||||||
in = bio_open_default(infile, 'r', informat);
|
req = load_csr(infile, informat, "certificate request input");
|
||||||
if (in == NULL)
|
if (req == NULL)
|
||||||
goto end;
|
goto end;
|
||||||
req = PEM_read_bio_X509_REQ(in, NULL, NULL, NULL);
|
|
||||||
BIO_free(in);
|
|
||||||
|
|
||||||
if (req == NULL) {
|
|
||||||
ERR_print_errors(bio_err);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((pkey = X509_REQ_get0_pubkey(req)) == NULL) {
|
if ((pkey = X509_REQ_get0_pubkey(req)) == NULL) {
|
||||||
BIO_printf(bio_err, "error unpacking public key\n");
|
BIO_printf(bio_err, "error unpacking public key\n");
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
i = X509_REQ_verify(req, pkey);
|
i = do_X509_REQ_verify(req, pkey, vfyopts);
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
BIO_printf(bio_err, "Request self-signature verification error\n");
|
BIO_printf(bio_err, "Request self-signature verification error\n");
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
@@ -848,8 +853,8 @@ int x509_main(int argc, char **argv)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sign(x, Upkey, fkey, days, clrext, digest, extconf,
|
if (!sign(x, Upkey, fkey, sigopts, days, clrext, digest,
|
||||||
extsect, preserve_dates))
|
extconf, extsect, preserve_dates))
|
||||||
goto end;
|
goto end;
|
||||||
} else if (CA_flag == i) {
|
} else if (CA_flag == i) {
|
||||||
BIO_printf(bio_err, "Getting CA Private Key\n");
|
BIO_printf(bio_err, "Getting CA Private Key\n");
|
||||||
@@ -949,6 +954,7 @@ int x509_main(int argc, char **argv)
|
|||||||
EVP_PKEY_free(CApkey);
|
EVP_PKEY_free(CApkey);
|
||||||
EVP_PKEY_free(fkey);
|
EVP_PKEY_free(fkey);
|
||||||
sk_OPENSSL_STRING_free(sigopts);
|
sk_OPENSSL_STRING_free(sigopts);
|
||||||
|
sk_OPENSSL_STRING_free(vfyopts);
|
||||||
X509_REQ_free(rq);
|
X509_REQ_free(rq);
|
||||||
ASN1_INTEGER_free(sno);
|
ASN1_INTEGER_free(sno);
|
||||||
sk_ASN1_OBJECT_pop_free(trust, ASN1_OBJECT_free);
|
sk_ASN1_OBJECT_pop_free(trust, ASN1_OBJECT_free);
|
||||||
@@ -1106,11 +1112,12 @@ static int callb(int ok, X509_STORE_CTX *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* self-issue; self-sign unless a forced public key (fkey) is given */
|
/* self-issue; self-sign unless a forced public key (fkey) is given */
|
||||||
static int sign(X509 *x, EVP_PKEY *pkey, EVP_PKEY *fkey, int days, int clrext,
|
static int sign(X509 *x, EVP_PKEY *pkey, EVP_PKEY *fkey,
|
||||||
|
STACK_OF(OPENSSL_STRING) *sigopts,
|
||||||
|
int days, int clrext,
|
||||||
const EVP_MD *digest, CONF *conf, const char *section,
|
const EVP_MD *digest, CONF *conf, const char *section,
|
||||||
int preserve_dates)
|
int preserve_dates)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!X509_set_issuer_name(x, X509_get_subject_name(x)))
|
if (!X509_set_issuer_name(x, X509_get_subject_name(x)))
|
||||||
goto err;
|
goto err;
|
||||||
if (!preserve_dates && !set_cert_times(x, NULL, NULL, days))
|
if (!preserve_dates && !set_cert_times(x, NULL, NULL, days))
|
||||||
@@ -1129,7 +1136,7 @@ static int sign(X509 *x, EVP_PKEY *pkey, EVP_PKEY *fkey, int days, int clrext,
|
|||||||
if (!X509V3_EXT_add_nconf(conf, &ctx, section, x))
|
if (!X509V3_EXT_add_nconf(conf, &ctx, section, x))
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
if (!X509_sign(x, pkey, digest))
|
if (!do_X509_sign(x, pkey, digest, sigopts))
|
||||||
goto err;
|
goto err;
|
||||||
return 1;
|
return 1;
|
||||||
err:
|
err:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Copyright 1998-2018 The OpenSSL Project Authors. All Rights Reserved.
|
# Copyright 1998-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
# this file except in compliance with the License. You can obtain a copy
|
# this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
@@ -15,10 +15,6 @@
|
|||||||
|
|
||||||
#include "internal/cryptlib.h"
|
#include "internal/cryptlib.h"
|
||||||
|
|
||||||
#ifdef OPENSSL_NO_DEPRECATED_3_0
|
|
||||||
NON_EMPTY_TRANSLATION_UNIT
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <openssl/aes.h>
|
#include <openssl/aes.h>
|
||||||
#include "aes_local.h"
|
#include "aes_local.h"
|
||||||
|
|
||||||
@@ -301,4 +297,3 @@ void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
|
* Copyright 2008-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
* this file except in compliance with the License. You can obtain a copy
|
* this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#! /usr/bin/env perl
|
#! /usr/bin/env perl
|
||||||
# Copyright 2004-2016 The OpenSSL Project Authors. All Rights Reserved.
|
# Copyright 2004-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
# this file except in compliance with the License. You can obtain a copy
|
# this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#! /usr/bin/env perl
|
#! /usr/bin/env perl
|
||||||
# Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved.
|
# Copyright 2007-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
# this file except in compliance with the License. You can obtain a copy
|
# this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#! /usr/bin/env perl
|
#! /usr/bin/env perl
|
||||||
# Copyright 2012-2016 The OpenSSL Project Authors. All Rights Reserved.
|
# Copyright 2012-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
# this file except in compliance with the License. You can obtain a copy
|
# this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#! /usr/bin/env perl
|
#! /usr/bin/env perl
|
||||||
# Copyright 2010-2019 The OpenSSL Project Authors. All Rights Reserved.
|
# Copyright 2010-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
# this file except in compliance with the License. You can obtain a copy
|
# this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#! /usr/bin/env perl
|
#! /usr/bin/env perl
|
||||||
# Copyright 2009-2018 The OpenSSL Project Authors. All Rights Reserved.
|
# Copyright 2009-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
# this file except in compliance with the License. You can obtain a copy
|
# this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#! /usr/bin/env perl
|
#! /usr/bin/env perl
|
||||||
# Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved.
|
# Copyright 2007-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
# this file except in compliance with the License. You can obtain a copy
|
# this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#! /usr/bin/env perl
|
#! /usr/bin/env perl
|
||||||
# Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved.
|
# Copyright 2007-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
# this file except in compliance with the License. You can obtain a copy
|
# this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#! /usr/bin/env perl
|
#! /usr/bin/env perl
|
||||||
# Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved.
|
# Copyright 2005-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
# this file except in compliance with the License. You can obtain a copy
|
# this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#! /usr/bin/env perl
|
#! /usr/bin/env perl
|
||||||
# Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved.
|
# Copyright 2005-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
# this file except in compliance with the License. You can obtain a copy
|
# this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#! /usr/bin/env perl
|
#! /usr/bin/env perl
|
||||||
# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
# Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
# this file except in compliance with the License. You can obtain a copy
|
# this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#! /usr/bin/env perl
|
#! /usr/bin/env perl
|
||||||
# Copyright 2013-2016 The OpenSSL Project Authors. All Rights Reserved.
|
# Copyright 2013-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||||
# this file except in compliance with the License. You can obtain a copy
|
# this file except in compliance with the License. You can obtain a copy
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user