mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
deps: upgrade openssl sources to quictls/openssl-3.0.1+quic
This updates all sources in deps/openssl/openssl by:
$ git clone git@github.com:quictls/openssl.git
$ cd openssl
$ cd ../node/deps/openssl
$ rm -rf openssl
$ cp -R ../openssl openssl
$ rm -rf openssl/.git* openssl/.travis*
$ git add --all openssl
$ git commit openssl
PR-URL: https://github.com/nodejs/node/pull/41177
Refs: https://github.com/quictls/openssl/pull/69
Refs: https://mta.openssl.org/pipermail/openssl-announce/2021-December/000212.html
Reviewed-By: Danielle Adams <adamzdanielle@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is>
This commit is contained in:
1 parent
da8baf4bbb
commit
0b2103419f
509 files changed
+6387
-2412
No files matched your search
Vendored
+90
@@ -34,6 +34,80 @@ breaking changes, and mappings for the large list of deprecated functions.
|
||||
|
||||
*Todd Short*
|
||||
|
||||
### Changes between 3.0.0 and 3.0.1 [14 Dec 2021]
|
||||
|
||||
* Fixed invalid handling of X509_verify_cert() internal errors in libssl
|
||||
Internally libssl in OpenSSL calls X509_verify_cert() on the client side to
|
||||
verify a certificate supplied by a server. That function may return a
|
||||
negative return value to indicate an internal error (for example out of
|
||||
memory). Such a negative return value is mishandled by OpenSSL and will cause
|
||||
an IO function (such as SSL_connect() or SSL_do_handshake()) to not indicate
|
||||
success and a subsequent call to SSL_get_error() to return the value
|
||||
SSL_ERROR_WANT_RETRY_VERIFY. This return value is only supposed to be
|
||||
returned by OpenSSL if the application has previously called
|
||||
SSL_CTX_set_cert_verify_callback(). Since most applications do not do this
|
||||
the SSL_ERROR_WANT_RETRY_VERIFY return value from SSL_get_error() will be
|
||||
totally unexpected and applications may not behave correctly as a result. The
|
||||
exact behaviour will depend on the application but it could result in
|
||||
crashes, infinite loops or other similar incorrect responses.
|
||||
|
||||
This issue is made more serious in combination with a separate bug in OpenSSL
|
||||
3.0 that will cause X509_verify_cert() to indicate an internal error when
|
||||
processing a certificate chain. This will occur where a certificate does not
|
||||
include the Subject Alternative Name extension but where a Certificate
|
||||
Authority has enforced name constraints. This issue can occur even with valid
|
||||
chains.
|
||||
([CVE-2021-4044])
|
||||
|
||||
*Matt Caswell*
|
||||
|
||||
* Corrected a few file name and file reference bugs in the build,
|
||||
installation and setup scripts, which lead to installation verification
|
||||
failures. Slightly enhanced the installation verification script.
|
||||
|
||||
*Richard Levitte*
|
||||
|
||||
* Fixed EVP_PKEY_eq() to make it possible to use it with strictly private
|
||||
keys.
|
||||
|
||||
*Richard Levitte*
|
||||
|
||||
* Fixed PVK encoder to properly query for the passphrase.
|
||||
|
||||
*Tomáš Mráz*
|
||||
|
||||
* Multiple fixes in the OSSL_HTTP API functions.
|
||||
|
||||
*David von Oheimb*
|
||||
|
||||
* Allow sign extension in OSSL_PARAM_allocate_from_text() for the
|
||||
OSSL_PARAM_INTEGER data type and return error on negative numbers
|
||||
used with the OSSL_PARAM_UNSIGNED_INTEGER data type. Make
|
||||
OSSL_PARAM_BLD_push_BN{,_pad}() return an error on negative numbers.
|
||||
|
||||
*Richard Levitte*
|
||||
|
||||
* Allow copying uninitialized digest contexts with EVP_MD_CTX_copy_ex.
|
||||
|
||||
*Tomáš Mráz*
|
||||
|
||||
* Fixed detection of ARMv7 and ARM64 CPU features on FreeBSD.
|
||||
|
||||
*Allan Jude*
|
||||
|
||||
* Multiple threading fixes.
|
||||
|
||||
*Matt Caswell*
|
||||
|
||||
* Added NULL digest implementation to keep compatibility with 1.1.1 version.
|
||||
|
||||
*Tomáš Mráz*
|
||||
|
||||
* Allow fetching an operation from the provider that owns an unexportable key
|
||||
as a fallback if that is still allowed by the property query.
|
||||
|
||||
*Richard Levitte*
|
||||
|
||||
### Changes between 1.1.1 and 3.0.0 [7 sep 2021]
|
||||
|
||||
* TLS_MAX_VERSION, DTLS_MAX_VERSION and DTLS_MIN_VERSION constants are now
|
||||
@@ -1459,6 +1533,22 @@ breaking changes, and mappings for the large list of deprecated functions.
|
||||
OpenSSL 1.1.1
|
||||
-------------
|
||||
|
||||
### Changes between 1.1.1l and 1.1.1m [xx XXX xxxx]
|
||||
|
||||
* Avoid loading of a dynamic engine twice.
|
||||
|
||||
*Bernd Edlinger*
|
||||
|
||||
* Prioritise DANE TLSA issuer certs over peer certs
|
||||
|
||||
*Viktor Dukhovni*
|
||||
|
||||
* Fixed random API for MacOS prior to 10.12
|
||||
|
||||
These MacOS versions don't support the CommonCrypto APIs
|
||||
|
||||
*Lenny Primak*
|
||||
|
||||
### Changes between 1.1.1k and 1.1.1l [24 Aug 2021]
|
||||
|
||||
* Fixed an SM2 Decryption Buffer Overflow.
|
||||
|
||||
@@ -857,6 +857,7 @@ my %targets = (
|
||||
inherit_from => [ "linux-x86" ],
|
||||
CC => "clang",
|
||||
CXX => "clang++",
|
||||
ex_libs => add(threads("-latomic")),
|
||||
},
|
||||
"linux-x86_64" => {
|
||||
inherit_from => [ "linux-generic64" ],
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ my %targets = (
|
||||
template => 1,
|
||||
inherit_from => [ "darwin-common" ],
|
||||
sys_id => "iOS",
|
||||
disable => [ "engine", "async" ],
|
||||
disable => [ "shared", "async" ],
|
||||
},
|
||||
"ios-xcrun" => {
|
||||
inherit_from => [ "ios-common" ],
|
||||
|
||||
+22
-14
@@ -9,7 +9,7 @@
|
||||
(our $osslprefix_q = platform->osslprefix()) =~ s/\$/\\\$/;
|
||||
|
||||
our $sover_dirname = platform->shlib_version_as_filename();
|
||||
our $osslver = sprintf "%02d%02d", split(/\./, $config{version});
|
||||
our $osslver = sprintf "%02d", split(/\./, $config{version});
|
||||
|
||||
our $sourcedir = $config{sourcedir};
|
||||
our $builddir = $config{builddir};
|
||||
@@ -110,9 +110,9 @@
|
||||
@cnf_defines,
|
||||
'OPENSSLDIR="""$(OPENSSLDIR_C)"""',
|
||||
'ENGINESDIR="""$(ENGINESDIR_C)"""',
|
||||
'MODULESDIR="""$(MODULESDIR_C)"""',
|
||||
#'$(DEFINES)'
|
||||
'MODULESDIR="""$(MODULESDIR_C)"""'
|
||||
)
|
||||
. '$(DEFINES)'
|
||||
. "'extradefines'";
|
||||
our $lib_asflags =
|
||||
join(' ', $target{lib_asflags} || (), @{$config{lib_asflags}},
|
||||
@@ -144,8 +144,8 @@
|
||||
join(',', @{$target{dso_defines}}, @{$target{module_defines}},
|
||||
@{$config{dso_defines}}, @{$config{module_defines}},
|
||||
@cnf_defines,
|
||||
#'$(DEFINES)'
|
||||
)
|
||||
. '$(DEFINES)'
|
||||
. "'extradefines'";
|
||||
our $dso_asflags =
|
||||
join(' ', $target{dso_asflags} || (), $target{module_asflags} || (),
|
||||
@@ -180,8 +180,8 @@
|
||||
join(',', @{$target{bin_defines}},
|
||||
@{$config{bin_defines}},
|
||||
@cnf_defines,
|
||||
#'$(DEFINES)'
|
||||
)
|
||||
. '$(DEFINES)'
|
||||
. "'extradefines'";
|
||||
our $bin_asflags =
|
||||
join(' ', $target{bin_asflags} || (),
|
||||
@@ -267,6 +267,7 @@ VERBOSE=$(V)
|
||||
VERBOSE_FAILURE=$(VF)
|
||||
|
||||
VERSION={- "$config{full_version}" -}
|
||||
VERSION_NUMBER={- "$config{version}" -}
|
||||
MAJOR={- $config{major} -}
|
||||
MINOR={- $config{minor} -}
|
||||
SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
|
||||
@@ -355,7 +356,7 @@ OPENSSLDIR_C={- platform->osslprefix() -}DATAROOT:[000000]
|
||||
# Where installed ENGINE modules reside, for C
|
||||
ENGINESDIR_C={- platform->osslprefix() -}ENGINES{- $sover_dirname.$target{pointer_size} -}:
|
||||
# Where modules reside, for C
|
||||
MODULESDIR_C={- platform->osslprefix() -}MODULES{- $sover_dirname.$target{pointer_size} -}:
|
||||
MODULESDIR_C={- platform->osslprefix() -}MODULES{- $target{pointer_size} -}:
|
||||
|
||||
##### User defined commands and flags ################################
|
||||
|
||||
@@ -428,7 +429,9 @@ NODEBUG=@
|
||||
$(NODEBUG) ! them, so we create it instead. This is an unfortunate
|
||||
$(NODEBUG) ! necessity.
|
||||
$(NODEBUG) !
|
||||
$(NODEBUG) DEFINE openssl "{- sourcedir('include/openssl') -}
|
||||
$(NODEBUG) openssl_inc1 = F$PARSE("[.include.openssl]","A.;",,,"syntax_only") - "A.;"
|
||||
$(NODEBUG) openssl_inc2 = F$PARSE("sourcetop:[include.openssl]","A.;",,,"SYNTAX_ONLY") - "A.;"
|
||||
$(NODEBUG) DEFINE openssl 'openssl_inc1','openssl_inc2'
|
||||
$(NODEBUG) !
|
||||
$(NODEBUG) ! Figure out the architecture
|
||||
$(NODEBUG) !
|
||||
@@ -441,9 +444,10 @@ NODEBUG=@
|
||||
|
||||
.LAST :
|
||||
$(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEASSIGN ".uc($_) } @shlibs) || "!" -}
|
||||
$(NODEBUG) DEASSIGN openssl
|
||||
$(NODEBUG) DEASSIGN ossl_dataroot
|
||||
$(NODEBUG) DEASSIGN ossl_installroot
|
||||
$(NODEBUG) DEASSIGN openssl
|
||||
$(NODEBUG) DEASSIGN ossl_sourceroot
|
||||
.DEFAULT :
|
||||
@ ! MMS cannot handle no actions...
|
||||
|
||||
@@ -569,8 +573,10 @@ uninstall_docs : uninstall_html_docs
|
||||
{- output_off() if $disabled{fips}; "" -}
|
||||
install_fips : build_sw $(INSTALL_FIPSMODULECONF)
|
||||
@ WRITE SYS$OUTPUT "*** Installing FIPS module"
|
||||
- CREATE/DIR ossl_installroot:[MODULES{- $target{pointer_size} -}.'arch']
|
||||
- CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[000000]
|
||||
COPY/PROT=W:RE $(INSTALL_FIPSMODULES) -
|
||||
ossl_installroot:[MODULES{- $sover_dirname.$target{pointer_size} -}.'arch']$(FIPSMODULENAME)
|
||||
ossl_installroot:[MODULES{- $target{pointer_size} -}.'arch']$(FIPSMODULENAME)
|
||||
@ WRITE SYS$OUTPUT "*** Installing FIPS module configuration"
|
||||
COPY/PROT=W:RE $(INSTALL_FIPSMODULECONF) OSSL_DATAROOT:[000000]
|
||||
|
||||
@@ -578,7 +584,7 @@ uninstall_fips :
|
||||
@ WRITE SYS$OUTPUT "*** Uninstalling FIPS module configuration"
|
||||
DELETE OSSL_DATAROOT:[000000]fipsmodule.cnf;*
|
||||
@ WRITE SYS$OUTPUT "*** Uninstalling FIPS module"
|
||||
DELETE ossl_installroot:[MODULES{- $sover_dirname.$target{pointer_size} -}.'arch']$(FIPSMODULENAME);*
|
||||
DELETE ossl_installroot:[MODULES{- $target{pointer_size} -}.'arch']$(FIPSMODULENAME);*
|
||||
{- output_on() if $disabled{fips}; "" -}
|
||||
|
||||
install_ssldirs : check_INSTALLTOP
|
||||
@@ -607,7 +613,9 @@ install_dev : check_INSTALLTOP install_runtime_libs
|
||||
@ WRITE SYS$OUTPUT "*** Installing development files"
|
||||
@ ! Install header files
|
||||
- CREATE/DIR ossl_installroot:[include.openssl]
|
||||
COPY/PROT=W:R openssl:*.h ossl_installroot:[include.openssl]
|
||||
COPY/PROT=W:R ossl_sourceroot:[include.openssl]*.h -
|
||||
ossl_installroot:[include.openssl]
|
||||
COPY/PROT=W:R [.include.openssl]*.h ossl_installroot:[include.openssl]
|
||||
@ ! Install static (development) libraries
|
||||
- CREATE/DIR ossl_installroot:[LIB.'arch']
|
||||
{- join("\n ",
|
||||
@@ -626,9 +634,9 @@ install_engines : check_INSTALLTOP install_runtime_libs build_modules
|
||||
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']
|
||||
- CREATE/DIR ossl_installroot:[MODULES{- $target{pointer_size} -}.'arch']
|
||||
{- join("\n ",
|
||||
map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[MODULES$sover_dirname$target{pointer_size}.'arch']" }
|
||||
map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[MODULES$target{pointer_size}.'arch']" }
|
||||
@install_modules) -}
|
||||
@ {- output_on() unless scalar @install_modules; "" -} !
|
||||
|
||||
@@ -904,7 +912,7 @@ EOF
|
||||
#
|
||||
my $target = platform->def($args{src});
|
||||
my $mkdef = sourcefile('util', 'mkdef.pl');
|
||||
my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
|
||||
my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION_NUMBER)' : '';
|
||||
my $ord_name =
|
||||
$args{generator}->[1] || basename($args{product}, '.EXE');
|
||||
my $case_insensitive =
|
||||
|
||||
+15
-3
@@ -63,9 +63,21 @@ sub sharedname_simple {
|
||||
}
|
||||
|
||||
sub sharedlib_simple {
|
||||
return undef if $_[0]->shlibext() eq $_[0]->shlibextsimple();
|
||||
return platform::BASE::__concat($_[0]->sharedname_simple($_[1]),
|
||||
$_[0]->shlibextsimple());
|
||||
# This function returns the simplified shared library name (no version
|
||||
# or variant in the shared library file name) if the simple variants of
|
||||
# the base name or the suffix differ from the full variants of the same.
|
||||
|
||||
# Note: if $_[1] isn't a shared library name, then $_[0]->sharedname()
|
||||
# and $_[0]->sharedname_simple() will return undef. This needs being
|
||||
# accounted for.
|
||||
my $name = $_[0]->sharedname($_[1]);
|
||||
my $simplename = $_[0]->sharedname_simple($_[1]);
|
||||
my $ext = $_[0]->shlibext();
|
||||
my $simpleext = $_[0]->shlibextsimple();
|
||||
|
||||
return undef unless defined $simplename && defined $name;
|
||||
return undef if ($name eq $simplename && $ext eq $simpleext);
|
||||
return platform::BASE::__concat($simplename, $simpleext);
|
||||
}
|
||||
|
||||
sub sharedlib_import {
|
||||
|
||||
+11
-9
@@ -67,6 +67,7 @@ BLDDIR={- $config{builddir} -}
|
||||
FIPSKEY={- $config{FIPSKEY} -}
|
||||
|
||||
VERSION={- "$config{full_version}" -}
|
||||
VERSION_NUMBER={- "$config{version}" -}
|
||||
MAJOR={- $config{major} -}
|
||||
MINOR={- $config{minor} -}
|
||||
SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
|
||||
@@ -618,6 +619,7 @@ uninstall_docs: uninstall_man_docs uninstall_html_docs
|
||||
install_fips: build_sw $(INSTALL_FIPSMODULECONF)
|
||||
@[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
|
||||
@$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MODULESDIR)
|
||||
@$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)
|
||||
@$(ECHO) "*** Installing FIPS module"
|
||||
@$(ECHO) "install $(INSTALL_FIPSMODULE) -> $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME)"
|
||||
@cp "$(INSTALL_FIPSMODULE)" $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).new
|
||||
@@ -691,11 +693,11 @@ install_dev: install_runtime_libs
|
||||
@[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
|
||||
@$(ECHO) "*** Installing development files"
|
||||
@$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
|
||||
@ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
|
||||
@ : {- output_off() if $disabled{uplink}; "" -}
|
||||
@$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
|
||||
@cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
|
||||
@chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
|
||||
@ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
|
||||
@ : {- output_on() if $disabled{uplink}; "" -}
|
||||
@set -e; for i in $(SRCDIR)/include/openssl/*.h \
|
||||
$(BLDDIR)/include/openssl/*.h; do \
|
||||
fn=`basename $$i`; \
|
||||
@@ -765,10 +767,10 @@ install_dev: install_runtime_libs
|
||||
|
||||
uninstall_dev: uninstall_runtime_libs
|
||||
@$(ECHO) "*** Uninstalling development files"
|
||||
@ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
|
||||
@ : {- output_off() if $disabled{uplink}; "" -}
|
||||
@$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
|
||||
@$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
|
||||
@ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
|
||||
@ : {- output_on() if $disabled{uplink}; "" -}
|
||||
@set -e; for i in $(SRCDIR)/include/openssl/*.h \
|
||||
$(BLDDIR)/include/openssl/*.h; do \
|
||||
fn=`basename $$i`; \
|
||||
@@ -1305,23 +1307,23 @@ SSLHEADERS={- join(" \\\n" . ' ' x 11,
|
||||
fill_lines(" ", $COLUMNS - 11, sort keys %sslheaders)) -}
|
||||
|
||||
renumber: build_generated
|
||||
$(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION) --no-warnings \
|
||||
$(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \
|
||||
--ordinals $(SRCDIR)/util/libcrypto.num \
|
||||
--symhacks $(SRCDIR)/include/openssl/symhacks.h \
|
||||
--renumber \
|
||||
$(CRYPTOHEADERS)
|
||||
$(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION) --no-warnings \
|
||||
$(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \
|
||||
--ordinals $(SRCDIR)/util/libssl.num \
|
||||
--symhacks $(SRCDIR)/include/openssl/symhacks.h \
|
||||
--renumber \
|
||||
$(SSLHEADERS)
|
||||
|
||||
ordinals: build_generated
|
||||
$(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION) --no-warnings \
|
||||
$(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \
|
||||
--ordinals $(SRCDIR)/util/libcrypto.num \
|
||||
--symhacks $(SRCDIR)/include/openssl/symhacks.h \
|
||||
$(CRYPTOHEADERS)
|
||||
$(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION) --no-warnings \
|
||||
$(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \
|
||||
--ordinals $(SRCDIR)/util/libssl.num \
|
||||
--symhacks $(SRCDIR)/include/openssl/symhacks.h \
|
||||
$(SSLHEADERS)
|
||||
@@ -1529,7 +1531,7 @@ EOF
|
||||
#
|
||||
my $target = platform->def($args{src});
|
||||
(my $mkdef_os = $target{shared_target}) =~ s|-shared$||;
|
||||
my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
|
||||
my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION_NUMBER)' : '';
|
||||
my $ord_name = $args{generator}->[1] || $args{product};
|
||||
return <<"EOF";
|
||||
$target: $gen0 $deps \$(SRCDIR)/util/mkdef.pl
|
||||
|
||||
+10
-7
@@ -41,6 +41,7 @@ BLDDIR={- $config{builddir} -}
|
||||
FIPSKEY={- $config{FIPSKEY} -}
|
||||
|
||||
VERSION={- "$config{full_version}" -}
|
||||
VERSION_NUMBER={- "$config{version}" -}
|
||||
MAJOR={- $config{major} -}
|
||||
MINOR={- $config{minor} -}
|
||||
|
||||
@@ -461,10 +462,10 @@ libclean:
|
||||
-del /Q /F $(LIBS) libcrypto.* libssl.* ossl_static.pdb
|
||||
|
||||
clean: libclean
|
||||
-rd /Q /S $(HTMLDOCS1_BLDDIRS)
|
||||
-rd /Q /S $(HTMLDOCS3_BLDDIRS)
|
||||
-rd /Q /S $(HTMLDOCS5_BLDDIRS)
|
||||
-rd /Q /S $(HTMLDOCS7_BLDDIRS)
|
||||
{- join("\n\t", map { "-del /Q /F $_" } @HTMLDOCS1) || "\@rem" -}
|
||||
{- join("\n\t", map { "-del /Q /F $_" } @HTMLDOCS3) || "\@rem" -}
|
||||
{- join("\n\t", map { "-del /Q /F $_" } @HTMLDOCS5) || "\@rem" -}
|
||||
{- join("\n\t", map { "-del /Q /F $_" } @HTMLDOCS7) || "\@rem" -}
|
||||
{- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) || "\@rem" -}
|
||||
{- join("\n\t", map { "-del /Q /F $_" } @MODULES) || "\@rem" -}
|
||||
{- join("\n\t", map { "-del /Q /F $_" } @SCRIPTS) || "\@rem" -}
|
||||
@@ -499,6 +500,7 @@ uninstall_docs: uninstall_html_docs
|
||||
install_fips: build_sw $(INSTALL_FIPSMODULECONF)
|
||||
# @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
|
||||
@$(PERL) $(SRCDIR)\util\mkdir-p.pl $(MODULESDIR)
|
||||
@$(PERL) $(SRCDIR)\util\mkdir-p.pl $(OPENSSLDIR)
|
||||
@$(ECHO) "*** Installing FIPS module"
|
||||
@$(ECHO) "install $(INSTALL_FIPSMODULE) -> $(MODULESDIR)\$(FIPSMODULENAME)"
|
||||
@"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(INSTALL_FIPSMODULE)" "$(MODULESDIR)"
|
||||
@@ -541,10 +543,10 @@ install_dev: install_runtime_libs
|
||||
@if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
|
||||
@$(ECHO) "*** Installing development files"
|
||||
@"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
|
||||
@{- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
|
||||
@{- output_off() if $disabled{uplink}; "" -}
|
||||
@"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
|
||||
"$(INSTALLTOP)\include\openssl"
|
||||
@{- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
|
||||
@{- output_on() if $disabled{uplink}; "" -}
|
||||
@"$(PERL)" "$(SRCDIR)\util\copy.pl" "-exclude_re=/__DECC_" \
|
||||
"$(SRCDIR)\include\openssl\*.h" \
|
||||
"$(INSTALLTOP)\include\openssl"
|
||||
@@ -727,7 +729,7 @@ EOF
|
||||
my $mkdef = abs2rel(rel2abs(catfile($config{sourcedir},
|
||||
"util", "mkdef.pl")),
|
||||
rel2abs($config{builddir}));
|
||||
my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
|
||||
my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION_NUMBER)' : '';
|
||||
my $ord_name =
|
||||
$args{generator}->[1] || platform->dsoname($args{product});
|
||||
return <<"EOF";
|
||||
@@ -981,6 +983,7 @@ EOF
|
||||
@{$args{objs}};
|
||||
my @deps = compute_lib_depends(@{$args{deps}});
|
||||
my $objs = join($target{ld_resp_delim}, @objs);
|
||||
my $ress = join($target{ld_resp_delim}, @ress);
|
||||
my $linklibs = join("", map { "$_$target{ld_resp_delim}" } @deps);
|
||||
my $deps = join(" ", @objs, @ress, @deps);
|
||||
return <<"EOF";
|
||||
|
||||
Vendored
+7
@@ -18,6 +18,13 @@ OpenSSL Releases
|
||||
OpenSSL 3.0
|
||||
-----------
|
||||
|
||||
### Major changes between OpenSSL 3.0.0 and OpenSSL 3.0.1 [14 Dec 2021]
|
||||
|
||||
* Fixed invalid handling of X509_verify_cert() internal errors in libssl
|
||||
([CVE-2021-4044])
|
||||
* Allow fetching an operation from the provider that owns an unexportable key
|
||||
as a fallback if that is still allowed by the property query.
|
||||
|
||||
### Major changes between OpenSSL 1.1.1 and OpenSSL 3.0.0 [7 sep 2021]
|
||||
|
||||
* Enhanced 'openssl list' with many new options.
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ Requirements
|
||||
See <http://valgrind.org/info/platforms.html>
|
||||
2. Valgrind installed on the platform
|
||||
See <http://valgrind.org/downloads/current.html>
|
||||
3. OpensSSL compiled
|
||||
3. OpenSSL compiled
|
||||
See [INSTALL.md](INSTALL.md)
|
||||
|
||||
Running Tests
|
||||
|
||||
Vendored
+15
-14
@@ -4,27 +4,28 @@ What This Is
|
||||
This is a fork of [OpenSSL](https://www.openssl.org) to enable QUIC. In addition
|
||||
to the website, the official source distribution is at
|
||||
<https://github.com/openssl/openssl>. The OpenSSL `README` can be found at
|
||||
[README-OpenSSL.md](README-OpenSSL.md).
|
||||
[README-OpenSSL.md](https://github.com/quictls/openssl/blob/openssl-3.0.1%2Bquic/README-OpenSSL.md)
|
||||
|
||||
This fork adds API that can be used by QUIC implementations for connection
|
||||
This fork adds APIs that can be used by QUIC implementations for connection
|
||||
handshakes. Quoting the IETF Working group
|
||||
[charter](https://datatracker.ietf.org/wg/quic/about/), QUIC is a "UDP-based,
|
||||
stream-multiplexing, encrypted transport protocol." If you don't need QUIC, you
|
||||
should use the official OpenSSL distributions.
|
||||
|
||||
This API's here are used by Microsoft's
|
||||
The APIs here are used by Microsoft's
|
||||
[MsQuic](https://github.com/microsoft/msquic) and Google's
|
||||
[Chromium QUIC](https://chromium.googlesource.com/chromium/src/+/master/net/quic/)
|
||||
|
||||
We are not in competition with OpenSSL project. We informed them of
|
||||
our plans to fork the code before we went public. We do not speak for the
|
||||
OpenSSL project, and can only point to a
|
||||
[blog post](https://www.openssl.org/blog/blog/2020/02/17/QUIC-and-OpenSSL/) that
|
||||
provides their view of QUIC support.
|
||||
[blog post](https://www.openssl.org/blog/blog/2020/02/17/QUIC-and-OpenSSL/) and
|
||||
[openssl-project email](https://github.com/quictls/openssl/discussions/54)
|
||||
that provides their view of QUIC support.
|
||||
|
||||
As stated in their blog post, the OpenSSL team is focused on their 3.0 release
|
||||
which is still in alpha, and does not intend to add QUIC functionality to 1.1.x.
|
||||
There is a community need for a QUIC capable TLS library. This fork is intended
|
||||
(released 2021-09-07), and does not intend to add QUIC functionality to 1.1.x.
|
||||
There is a community need for a QUIC-capable TLS library. This fork is intended
|
||||
as stopgap solution to enable higher level frameworks and runtimes to use QUIC
|
||||
with the proven and reliable TLS functionality from OpenSSL. This fork will be
|
||||
maintained until OpenSSL officially provides reasonable support for QUIC
|
||||
@@ -42,8 +43,8 @@ What about branches?
|
||||
|
||||
We don't want to conflict with OpenSSL branch names. Our current plan is to append
|
||||
`+quic`. Release tags are likely to be the QUIC branch with `-releaseX` appended.
|
||||
For example, the OpenSSL tag `openssl-3.0.0-alpha12` would have a branch named
|
||||
`openssl-3.0.0-alpha12+quic` and a release tag of `openssl-3.0.0-alpha12+quic-release1`
|
||||
For example, the OpenSSL tag `openssl-3.0.0` would have a branch named
|
||||
`openssl-3.0.0+quic` and a release tag of `openssl-3.0.0+quic-release1`.
|
||||
|
||||
How are you keeping current with OpenSSL?
|
||||
-----------------------------------------
|
||||
@@ -65,13 +66,13 @@ What about library names?
|
||||
|
||||
Library names will be the same, but will use a different version number. The version
|
||||
numbers for the current OpenSSL libraries are `1.1` (for the 1.1.0 and 1.1.1 branches)
|
||||
and `3` (for the to-be-3.0 branch). We will be prefixing 81 (ASCII for 'Q') to
|
||||
and `3` (for the 3.0 branch). We will be prefixing `81` (ASCII for 'Q') to
|
||||
the version numbers to generate a unique version number.
|
||||
|
||||
- libcrypto.so.81.3 vs libcrypto.so.3
|
||||
- libcrypto.so.81.1.1 vs libcrypto.so.1.1
|
||||
- libssl.so.81.3 vs libssl.so.3
|
||||
- libssl.so.81.1.1 vs libsslo.so.1.1
|
||||
- `libcrypto.so.81.3` vs `libcrypto.so.3`
|
||||
- `libcrypto.so.81.1.1` vs `libcrypto.so.1.1`
|
||||
- `libssl.so.81.3` vs `libssl.so.3`
|
||||
- `libssl.so.81.1.1` vs `libssl.so.1.1`
|
||||
|
||||
The SONAME of these libraries are all different, guaranteeing the correct library
|
||||
will be used.
|
||||
|
||||
Vendored
+3
-1
@@ -55,7 +55,7 @@ particular the manual pages, can be reported as issues.
|
||||
|
||||
The fastest way to get a bug fixed is to fix it yourself ;-). If you are
|
||||
experienced in programming and know how to fix the bug, you can open a
|
||||
pull request. The details are covered in the [Contributing](#contributing) section.
|
||||
pull request. The details are covered in the [Contributing][contributing] section.
|
||||
|
||||
Don't hesitate to open a pull request, even if it's only a small change
|
||||
like a grammatical or typographical error in the documentation.
|
||||
@@ -89,3 +89,5 @@ anymore, the searchable archive may still contain useful information.
|
||||
[openssl-announce]: https://mta.openssl.org/mailman/listinfo/openssl-announce
|
||||
[openssl-project]: https://mta.openssl.org/mailman/listinfo/openssl-project
|
||||
[openssl-dev]: https://mta.openssl.org/mailman/listinfo/openssl-dev
|
||||
[github-issues]: https://github.com/openssl/openssl/issues/new/choose
|
||||
[contributing]: https://github.com/openssl/openssl/blob/master/CONTRIBUTING.md
|
||||
Vendored
+2
-2
@@ -1,7 +1,7 @@
|
||||
MAJOR=3
|
||||
MINOR=0
|
||||
PATCH=0
|
||||
PATCH=1
|
||||
PRE_RELEASE_TAG=
|
||||
BUILD_METADATA=quic
|
||||
RELEASE_DATE="7 sep 2021"
|
||||
RELEASE_DATE="14 Dec 2021"
|
||||
SHLIB_VERSION=81.3
|
||||
+8
-2
@@ -14,8 +14,8 @@ $ INSTALLTOP_ = F$PARSE("A.;",INSTALLTOP,,,"NO_CONCEAL") -
|
||||
$ OPENSSLDIR_ = F$PARSE("A.;",OPENSSLDIR,,,"NO_CONCEAL") -
|
||||
- ".][000000" - "[000000." - "][" - "]A.;" + "."
|
||||
$
|
||||
$ v := {- sprintf "%02d%02d", split(/\./, $config{version}) -}
|
||||
$ pz := {- $config{pointer_size} -}
|
||||
$ v := {- sprintf "%02d", split(/\./, $config{version}) -}
|
||||
$ pz := {- $target{pointer_size} -}
|
||||
$
|
||||
$ @'INSTALLTOP_'SYS$STARTUP]openssl_startup'v'
|
||||
$ @'INSTALLTOP_'SYS$STARTUP]openssl_utils'v'
|
||||
@@ -41,6 +41,12 @@ $
|
||||
$ ! FUTURE ENHANCEMENT: Verify that engines are where they should be.
|
||||
$ ! openssl engine -c -t checker
|
||||
$
|
||||
$ ! Verify that the built in providers are reachable. If they aren't,
|
||||
$ ! then we're likely to get an image activation error here
|
||||
$ openssl list -provider base -providers
|
||||
$ openssl list -provider default -providers
|
||||
$ openssl list -provider legacy -providers
|
||||
$
|
||||
$ WRITE SYS$ERROR "OpenSSL IVP passed"
|
||||
$ EXIT %x10000001
|
||||
$
|
||||
|
||||
+5
-4
@@ -26,15 +26,16 @@ $ ENDIF
|
||||
$
|
||||
$ ! Abbrevs
|
||||
$ DEAS := DEASSIGN /NOLOG 'P1'
|
||||
$ sv := {- sprintf "%02d%02d", split m|\.|, $config{shlib_version} -}
|
||||
$ pz := {- $config{pointer_size} -}
|
||||
$ sv := {- platform->shlib_version_as_filename(); -}
|
||||
$ pz := {- $target{pointer_size} -}
|
||||
$
|
||||
$ DEAS OSSL$DATAROOT
|
||||
$ DEAS OSSL$INSTROOT
|
||||
$ DEAS OSSL$INCLUDE
|
||||
$ DEAS OSSL$LIB
|
||||
$ DEAS OSSL$SHARE
|
||||
$ DEAS OSSL$ENGINES'sv'
|
||||
$ DEAS OSSL$ENGINES'sv''pz'
|
||||
$ DEAS OSSL$MODULES'pz'
|
||||
$ DEAS OSSL$EXE
|
||||
$ DEAS OSSL$LIBCRYPTO'pz'
|
||||
$ DEAS OSSL$LIBSSL'pz'
|
||||
@@ -46,7 +47,7 @@ $ DEAS OPENSSL
|
||||
$
|
||||
$ IF P2 .NES. "NOALIASES"
|
||||
$ THEN
|
||||
$ DEAS OSSL$ENGINES
|
||||
$ DEAS OSSL$ENGINES'pz'
|
||||
${- output_off() if $config{no_shared}; "" -}
|
||||
$ DEAS OSSL$LIBCRYPTO_SHR'pz'
|
||||
$ DEAS OSSL$LIBSSL_SHR'pz'
|
||||
|
||||
+5
-3
@@ -15,7 +15,8 @@ $ ! are located
|
||||
$ ! OSSL$SHARE Where the shareable image files
|
||||
$ ! are located
|
||||
$ ! OSSL$EXE Where the executables are located
|
||||
$ ! OSSL$ENGINESnnn Where the shareable images are located
|
||||
$ ! OSSL$ENGINESnnn Where the engines modules are located
|
||||
$ ! OSSL$MODULES Where the non-engine modules are located
|
||||
$ ! OSSL$LIBCRYPTO The static crypto library
|
||||
$ ! OSSL$LIBSSL The static ssl library
|
||||
$ ! OSSL$LIBCRYPTOnnn_SHR The shareable crypto image
|
||||
@@ -88,8 +89,8 @@ $
|
||||
$ ! Abbrevs
|
||||
$ DEFT := DEFINE /TRANSLATION=CONCEALED /NOLOG 'P1'
|
||||
$ DEF := DEFINE /NOLOG 'P1'
|
||||
$ sv := {- sprintf "%02d%02d", split m|\.|, $config{shlib_version} -}
|
||||
$ pz := {- $config{pointer_size} -}
|
||||
$ sv := {- platform->shlib_version_as_filename(); -}
|
||||
$ pz := {- $target{pointer_size} -}
|
||||
$
|
||||
$ DEFT OSSL$DATAROOT 'OPENSSLDIR_']
|
||||
$ DEFT OSSL$INSTROOT 'INSTALLTOP_']
|
||||
@@ -97,6 +98,7 @@ $ DEFT OSSL$INCLUDE 'INSTALLTOP_'INCLUDE.]
|
||||
$ DEF OSSL$LIB OSSL$INSTROOT:[LIB.'arch']
|
||||
$ DEF OSSL$SHARE OSSL$INSTROOT:[LIB.'arch']
|
||||
$ DEF OSSL$ENGINES'sv''pz' OSSL$INSTROOT:[ENGINES'sv''pz'.'arch']
|
||||
$ DEF OSSL$MODULES'pz' OSSL$INSTROOT:[MODULES'pz'.'arch']
|
||||
$ DEF OSSL$EXE OSSL$INSTROOT:[EXE.'arch'],-
|
||||
OSSL$INSTROOT:[EXE]
|
||||
$ DEF OSSL$LIBCRYPTO'pz' OSSL$LIB:OSSL$LIBCRYPTO'pz'.OLB
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
$ ! OpenSSL utilities
|
||||
$ !
|
||||
$
|
||||
$ v := {- sprintf "%02d%02d", split(/\./, $config{version}) -}
|
||||
$ v := {- sprintf "%02d", split(/\./, $config{version}) -}
|
||||
$
|
||||
$ OPENSSL'v' :== $OSSL$EXE:OPENSSL'v'
|
||||
$ OPENSSL :== $OSSL$EXE:OPENSSL'v'
|
||||
|
||||
Vendored
+138
-52
@@ -9,6 +9,8 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/* This app is disabled when OPENSSL_NO_CMP is defined. */
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
@@ -66,12 +68,13 @@ typedef enum {
|
||||
} cmp_cmd_t;
|
||||
|
||||
/* message transfer */
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
static char *opt_server = NULL;
|
||||
static char server_port[32] = { '\0' };
|
||||
static char *opt_path = NULL;
|
||||
static char *opt_proxy = NULL;
|
||||
static char *opt_no_proxy = NULL;
|
||||
#endif
|
||||
static char *opt_recipient = NULL;
|
||||
static char *opt_path = NULL;
|
||||
static int opt_keep_alive = 1;
|
||||
static int opt_msg_timeout = -1;
|
||||
static int opt_total_timeout = -1;
|
||||
@@ -137,6 +140,7 @@ static int opt_keyform = FORMAT_UNDEF;
|
||||
static char *opt_otherpass = NULL;
|
||||
static char *opt_engine = NULL;
|
||||
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
/* TLS connection */
|
||||
static int opt_tls_used = 0;
|
||||
static char *opt_tls_cert = NULL;
|
||||
@@ -145,6 +149,7 @@ static char *opt_tls_keypass = NULL;
|
||||
static char *opt_tls_extra = NULL;
|
||||
static char *opt_tls_trusted = NULL;
|
||||
static char *opt_tls_host = NULL;
|
||||
#endif
|
||||
|
||||
/* client-side debugging */
|
||||
static int opt_batch = 0;
|
||||
@@ -157,9 +162,10 @@ static char *opt_rspout = NULL;
|
||||
static int opt_use_mock_srv = 0;
|
||||
|
||||
/* server-side debugging */
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
static char *opt_port = NULL;
|
||||
static int opt_max_msgs = 0;
|
||||
|
||||
#endif
|
||||
static char *opt_srv_ref = NULL;
|
||||
static char *opt_srv_secret = NULL;
|
||||
static char *opt_srv_cert = NULL;
|
||||
@@ -204,8 +210,10 @@ typedef enum OPTION_choice {
|
||||
|
||||
OPT_OLDCERT, OPT_REVREASON,
|
||||
|
||||
OPT_SERVER, OPT_PATH, OPT_PROXY, OPT_NO_PROXY,
|
||||
OPT_RECIPIENT,
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
OPT_SERVER, OPT_PROXY, OPT_NO_PROXY,
|
||||
#endif
|
||||
OPT_RECIPIENT, OPT_PATH,
|
||||
OPT_KEEP_ALIVE, OPT_MSG_TIMEOUT, OPT_TOTAL_TIMEOUT,
|
||||
|
||||
OPT_TRUSTED, OPT_UNTRUSTED, OPT_SRVCERT,
|
||||
@@ -225,15 +233,19 @@ typedef enum OPTION_choice {
|
||||
OPT_PROV_ENUM,
|
||||
OPT_R_ENUM,
|
||||
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
OPT_TLS_USED, OPT_TLS_CERT, OPT_TLS_KEY,
|
||||
OPT_TLS_KEYPASS,
|
||||
OPT_TLS_EXTRA, OPT_TLS_TRUSTED, OPT_TLS_HOST,
|
||||
#endif
|
||||
|
||||
OPT_BATCH, OPT_REPEAT,
|
||||
OPT_REQIN, OPT_REQIN_NEW_TID, OPT_REQOUT, OPT_RSPIN, OPT_RSPOUT,
|
||||
OPT_USE_MOCK_SRV,
|
||||
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
OPT_PORT, OPT_MAX_MSGS,
|
||||
#endif
|
||||
OPT_SRV_REF, OPT_SRV_SECRET,
|
||||
OPT_SRV_CERT, OPT_SRV_KEY, OPT_SRV_KEYPASS,
|
||||
OPT_SRV_TRUSTED, OPT_SRV_UNTRUSTED,
|
||||
@@ -331,20 +343,25 @@ const OPTIONS cmp_options[] = {
|
||||
"0..6, 8..10 (see RFC5280, 5.3.1) or -1. Default -1 = none included"},
|
||||
|
||||
OPT_SECTION("Message transfer"),
|
||||
#ifdef OPENSSL_NO_SOCK
|
||||
{OPT_MORE_STR, 0, 0,
|
||||
"NOTE: -server, -proxy, and -no_proxy not supported due to no-sock build"},
|
||||
#else
|
||||
{"server", OPT_SERVER, 's',
|
||||
"[http[s]://]address[:port][/path] of CMP server. Default port 80 or 443."},
|
||||
{OPT_MORE_STR, 0, 0,
|
||||
"address may be a DNS name or an IP address; path can be overridden by -path"},
|
||||
{"path", OPT_PATH, 's',
|
||||
"HTTP path (aka CMP alias) at the CMP server. Default from -server, else \"/\""},
|
||||
{"proxy", OPT_PROXY, 's',
|
||||
"[http[s]://]address[:port][/path] of HTTP(S) proxy to use; path is ignored"},
|
||||
{"no_proxy", OPT_NO_PROXY, 's',
|
||||
"List of addresses of servers not to use HTTP(S) proxy for"},
|
||||
{OPT_MORE_STR, 0, 0,
|
||||
"Default from environment variable 'no_proxy', else 'NO_PROXY', else none"},
|
||||
#endif
|
||||
{"recipient", OPT_RECIPIENT, 's',
|
||||
"DN of CA. Default: subject of -srvcert, -issuer, issuer of -oldcert or -cert"},
|
||||
{"path", OPT_PATH, 's',
|
||||
"HTTP path (aka CMP alias) at the CMP server. Default from -server, else \"/\""},
|
||||
{"keep_alive", OPT_KEEP_ALIVE, 'N',
|
||||
"Persistent HTTP connections. 0: no, 1 (the default): request, 2: require"},
|
||||
{"msg_timeout", OPT_MSG_TIMEOUT, 'N',
|
||||
@@ -419,6 +436,10 @@ const OPTIONS cmp_options[] = {
|
||||
OPT_R_OPTIONS,
|
||||
|
||||
OPT_SECTION("TLS connection"),
|
||||
#ifdef OPENSSL_NO_SOCK
|
||||
{OPT_MORE_STR, 0, 0,
|
||||
"NOTE: -tls_used and all other TLS options not supported due to no-sock build"},
|
||||
#else
|
||||
{"tls_used", OPT_TLS_USED, '-',
|
||||
"Enable using TLS (also when other TLS options are not set)"},
|
||||
{"tls_cert", OPT_TLS_CERT, 's',
|
||||
@@ -434,6 +455,7 @@ const OPTIONS cmp_options[] = {
|
||||
{OPT_MORE_STR, 0, 0, "this implies host name validation"},
|
||||
{"tls_host", OPT_TLS_HOST, 's',
|
||||
"Address to be checked (rather than -server) during TLS host name validation"},
|
||||
#endif
|
||||
|
||||
OPT_SECTION("Client-side debugging"),
|
||||
{"batch", OPT_BATCH, '-',
|
||||
@@ -451,9 +473,14 @@ const OPTIONS cmp_options[] = {
|
||||
{"use_mock_srv", OPT_USE_MOCK_SRV, '-', "Use mock server at API level, bypassing HTTP"},
|
||||
|
||||
OPT_SECTION("Mock server"),
|
||||
#ifdef OPENSSL_NO_SOCK
|
||||
{OPT_MORE_STR, 0, 0,
|
||||
"NOTE: -port and -max_msgs not supported due to no-sock build"},
|
||||
#else
|
||||
{"port", OPT_PORT, 's', "Act as HTTP mock server listening on given port"},
|
||||
{"max_msgs", OPT_MAX_MSGS, 'N',
|
||||
"max number of messages handled by HTTP mock server. Default: 0 = unlimited"},
|
||||
#endif
|
||||
|
||||
{"srv_ref", OPT_SRV_REF, 's',
|
||||
"Reference value to use as senderKID of server in case no -srv_cert is given"},
|
||||
@@ -532,8 +559,10 @@ static varref cmp_vars[] = { /* must be in same order as enumerated above! */
|
||||
|
||||
{&opt_oldcert}, {(char **)&opt_revreason},
|
||||
|
||||
{&opt_server}, {&opt_path}, {&opt_proxy}, {&opt_no_proxy},
|
||||
{&opt_recipient}, {(char **)&opt_keep_alive},
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
{&opt_server}, {&opt_proxy}, {&opt_no_proxy},
|
||||
#endif
|
||||
{&opt_recipient}, {&opt_path}, {(char **)&opt_keep_alive},
|
||||
{(char **)&opt_msg_timeout}, {(char **)&opt_total_timeout},
|
||||
|
||||
{&opt_trusted}, {&opt_untrusted}, {&opt_srvcert},
|
||||
@@ -552,15 +581,20 @@ static varref cmp_vars[] = { /* must be in same order as enumerated above! */
|
||||
{&opt_engine},
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
{(char **)&opt_tls_used}, {&opt_tls_cert}, {&opt_tls_key},
|
||||
{&opt_tls_keypass},
|
||||
{&opt_tls_extra}, {&opt_tls_trusted}, {&opt_tls_host},
|
||||
#endif
|
||||
|
||||
{(char **)&opt_batch}, {(char **)&opt_repeat},
|
||||
{&opt_reqin}, {(char **)&opt_reqin_new_tid},
|
||||
{&opt_reqout}, {&opt_rspin}, {&opt_rspout},
|
||||
|
||||
{(char **)&opt_use_mock_srv}, {&opt_port}, {(char **)&opt_max_msgs},
|
||||
{(char **)&opt_use_mock_srv},
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
{&opt_port}, {(char **)&opt_max_msgs},
|
||||
#endif
|
||||
{&opt_srv_ref}, {&opt_srv_secret},
|
||||
{&opt_srv_cert}, {&opt_srv_key}, {&opt_srv_keypass},
|
||||
{&opt_srv_trusted}, {&opt_srv_untrusted},
|
||||
@@ -613,6 +647,12 @@ static int print_to_bio_out(const char *func, const char *file, int line,
|
||||
return OSSL_CMP_print_to_bio(bio_out, func, file, line, level, msg);
|
||||
}
|
||||
|
||||
static int print_to_bio_err(const char *func, const char *file, int line,
|
||||
OSSL_CMP_severity level, const char *msg)
|
||||
{
|
||||
return OSSL_CMP_print_to_bio(bio_err, func, file, line, level, msg);
|
||||
}
|
||||
|
||||
static int set_verbosity(int level)
|
||||
{
|
||||
if (level < OSSL_CMP_LOG_EMERG || level > OSSL_CMP_LOG_MAX) {
|
||||
@@ -747,6 +787,7 @@ static OSSL_CMP_MSG *read_write_req_resp(OSSL_CMP_CTX *ctx,
|
||||
OSSL_CMP_MSG *req_new = NULL;
|
||||
OSSL_CMP_MSG *res = NULL;
|
||||
OSSL_CMP_PKIHEADER *hdr;
|
||||
const char *prev_opt_rspin = opt_rspin;
|
||||
|
||||
if (req != NULL && opt_reqout != NULL
|
||||
&& !write_PKIMESSAGE(req, &opt_reqout))
|
||||
@@ -776,7 +817,7 @@ static OSSL_CMP_MSG *read_write_req_resp(OSSL_CMP_CTX *ctx,
|
||||
if (res == NULL)
|
||||
goto err;
|
||||
|
||||
if (opt_reqin != NULL || opt_rspin != NULL) {
|
||||
if (opt_reqin != NULL || prev_opt_rspin != NULL) {
|
||||
/* need to satisfy nonce and transactionID checks */
|
||||
ASN1_OCTET_STRING *nonce;
|
||||
ASN1_OCTET_STRING *tid;
|
||||
@@ -1318,7 +1359,7 @@ static SSL_CTX *setup_ssl_ctx(OSSL_CMP_CTX *ctx, const char *host,
|
||||
SSL_CTX_free(ssl_ctx);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
#endif /* OPENSSL_NO_SOCK */
|
||||
|
||||
/*
|
||||
* set up protection aspects of OSSL_CMP_CTX based on options from config
|
||||
@@ -1758,12 +1799,16 @@ static int handle_opt_geninfo(OSSL_CMP_CTX *ctx)
|
||||
static int setup_client_ctx(OSSL_CMP_CTX *ctx, ENGINE *engine)
|
||||
{
|
||||
int ret = 0;
|
||||
char *host = NULL, *port = NULL, *path = NULL, *used_path;
|
||||
char *host = NULL, *port = NULL, *path = NULL, *used_path = opt_path;
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
int portnum, ssl;
|
||||
static char server_port[32] = { '\0' };
|
||||
const char *proxy_host = NULL;
|
||||
#endif
|
||||
char server_buf[200] = { '\0' };
|
||||
char proxy_buf[200] = { '\0' };
|
||||
const char *proxy_host = NULL;
|
||||
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
if (opt_server == NULL) {
|
||||
CMP_err("missing -server option");
|
||||
goto err;
|
||||
@@ -1777,11 +1822,12 @@ static int setup_client_ctx(OSSL_CMP_CTX *ctx, ENGINE *engine)
|
||||
CMP_err("missing -tls_used option since -server URL indicates https");
|
||||
goto err;
|
||||
}
|
||||
|
||||
BIO_snprintf(server_port, sizeof(server_port), "%s", port);
|
||||
used_path = opt_path != NULL ? opt_path : path;
|
||||
if (opt_path == NULL)
|
||||
used_path = path;
|
||||
if (!OSSL_CMP_CTX_set1_server(ctx, host)
|
||||
|| !OSSL_CMP_CTX_set_serverPort(ctx, portnum)
|
||||
|| !OSSL_CMP_CTX_set1_serverPath(ctx, used_path))
|
||||
|| !OSSL_CMP_CTX_set_serverPort(ctx, portnum))
|
||||
goto oom;
|
||||
if (opt_proxy != NULL && !OSSL_CMP_CTX_set1_proxy(ctx, opt_proxy))
|
||||
goto oom;
|
||||
@@ -1795,6 +1841,10 @@ static int setup_client_ctx(OSSL_CMP_CTX *ctx, ENGINE *engine)
|
||||
if (proxy_host != NULL)
|
||||
(void)BIO_snprintf(proxy_buf, sizeof(proxy_buf), " via %s", proxy_host);
|
||||
|
||||
#endif
|
||||
|
||||
if (!OSSL_CMP_CTX_set1_serverPath(ctx, used_path))
|
||||
goto oom;
|
||||
if (!transform_opts())
|
||||
goto err;
|
||||
|
||||
@@ -1835,16 +1885,13 @@ static int setup_client_ctx(OSSL_CMP_CTX *ctx, ENGINE *engine)
|
||||
|| opt_rspin != NULL || opt_rspout != NULL || opt_use_mock_srv)
|
||||
(void)OSSL_CMP_CTX_set_transfer_cb(ctx, read_write_req_resp);
|
||||
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
if ((opt_tls_cert != NULL || opt_tls_key != NULL
|
||||
|| opt_tls_keypass != NULL || opt_tls_extra != NULL
|
||||
|| opt_tls_trusted != NULL || opt_tls_host != NULL)
|
||||
&& !opt_tls_used)
|
||||
CMP_warn("TLS options(s) given but not -tls_used");
|
||||
if (opt_tls_used) {
|
||||
#ifdef OPENSSL_NO_SOCK
|
||||
BIO_printf(bio_err, "Cannot use TLS - sockets not supported\n");
|
||||
goto err;
|
||||
#else
|
||||
APP_HTTP_TLS_INFO *info;
|
||||
|
||||
if (opt_tls_cert != NULL
|
||||
@@ -1873,8 +1920,8 @@ static int setup_client_ctx(OSSL_CMP_CTX *ctx, ENGINE *engine)
|
||||
if (info->ssl_ctx == NULL)
|
||||
goto err;
|
||||
(void)OSSL_CMP_CTX_set_http_cb(ctx, app_http_tls_cb);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!setup_protection_ctx(ctx, engine))
|
||||
goto err;
|
||||
@@ -1989,7 +2036,7 @@ static void print_itavs(STACK_OF(OSSL_CMP_ITAV) *itavs)
|
||||
}
|
||||
|
||||
static char opt_item[SECTION_NAME_MAX + 1];
|
||||
/* get previous name from a comma-separated list of names */
|
||||
/* get previous name from a comma or space-separated list of names */
|
||||
static const char *prev_item(const char *opt, const char *end)
|
||||
{
|
||||
const char *beg;
|
||||
@@ -1998,19 +2045,28 @@ static const char *prev_item(const char *opt, const char *end)
|
||||
if (end == opt)
|
||||
return NULL;
|
||||
beg = end;
|
||||
while (beg != opt && beg[-1] != ',' && !isspace(beg[-1]))
|
||||
beg--;
|
||||
while (beg > opt) {
|
||||
--beg;
|
||||
if (beg[0] == ',' || isspace(beg[0])) {
|
||||
++beg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
len = end - beg;
|
||||
if (len > SECTION_NAME_MAX)
|
||||
if (len > SECTION_NAME_MAX) {
|
||||
CMP_warn3("using only first %d characters of section name starting with \"%.*s\"",
|
||||
SECTION_NAME_MAX, SECTION_NAME_MAX, beg);
|
||||
len = SECTION_NAME_MAX;
|
||||
strncpy(opt_item, beg, len);
|
||||
opt_item[SECTION_NAME_MAX] = '\0'; /* avoid gcc v8 O3 stringop-truncation */
|
||||
}
|
||||
memcpy(opt_item, beg, len);
|
||||
opt_item[len] = '\0';
|
||||
if (len > SECTION_NAME_MAX)
|
||||
CMP_warn2("using only first %d characters of section name starting with \"%s\"",
|
||||
SECTION_NAME_MAX, opt_item);
|
||||
while (beg != opt && (beg[-1] == ',' || isspace(beg[-1])))
|
||||
beg--;
|
||||
while (beg > opt) {
|
||||
--beg;
|
||||
if (beg[0] != ',' && !isspace(beg[0])) {
|
||||
++beg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return beg;
|
||||
}
|
||||
|
||||
@@ -2058,16 +2114,16 @@ static int read_config(void)
|
||||
long num = 0;
|
||||
char *txt = NULL;
|
||||
const OPTIONS *opt;
|
||||
int start = OPT_VERBOSITY;
|
||||
int start_opt = OPT_VERBOSITY - OPT_HELP;
|
||||
int start_idx = OPT_VERBOSITY - 2;
|
||||
/*
|
||||
* starting with offset OPT_VERBOSITY because OPT_CONFIG and OPT_SECTION
|
||||
* would not make sense within the config file.
|
||||
* Moreover, these two options and OPT_VERBOSITY have already been handled.
|
||||
*/
|
||||
int n_options = OSSL_NELEM(cmp_options) - 1;
|
||||
|
||||
for (i = start - OPT_HELP, opt = &cmp_options[start];
|
||||
opt->name; i++, opt++)
|
||||
for (opt = &cmp_options[start_opt], i = start_idx;
|
||||
opt->name != NULL; i++, opt++)
|
||||
if (!strcmp(opt->name, OPT_SECTION_STR)
|
||||
|| !strcmp(opt->name, OPT_MORE_STR))
|
||||
n_options--;
|
||||
@@ -2075,8 +2131,8 @@ static int read_config(void)
|
||||
+ OPT_PROV__FIRST + 1 - OPT_PROV__LAST
|
||||
+ OPT_R__FIRST + 1 - OPT_R__LAST
|
||||
+ OPT_V__FIRST + 1 - OPT_V__LAST);
|
||||
for (i = start - OPT_HELP, opt = &cmp_options[start];
|
||||
opt->name; i++, opt++) {
|
||||
for (opt = &cmp_options[start_opt], i = start_idx;
|
||||
opt->name != NULL; i++, opt++) {
|
||||
int provider_option = (OPT_PROV__FIRST <= opt->retval
|
||||
&& opt->retval < OPT_PROV__LAST);
|
||||
int rand_state_option = (OPT_R__FIRST <= opt->retval
|
||||
@@ -2106,7 +2162,7 @@ static int read_config(void)
|
||||
num, opt->name);
|
||||
return -1;
|
||||
}
|
||||
if (opt->valtype == 'N' && num <= 0) {
|
||||
if (opt->valtype == 'N' && num < 0) {
|
||||
opt_printf_stderr("Negative number \"%ld\" for config option -%s\n",
|
||||
num, opt->name);
|
||||
return -1;
|
||||
@@ -2216,8 +2272,12 @@ static int get_opts(int argc, char **argv)
|
||||
return -1;
|
||||
case OPT_CONFIG: /* has already been handled */
|
||||
case OPT_SECTION: /* has already been handled */
|
||||
case OPT_VERBOSITY: /* has already been handled */
|
||||
break;
|
||||
case OPT_VERBOSITY:
|
||||
if (!set_verbosity(opt_int_arg()))
|
||||
goto opthelp;
|
||||
break;
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
case OPT_SERVER:
|
||||
opt_server = opt_str();
|
||||
break;
|
||||
@@ -2227,12 +2287,13 @@ static int get_opts(int argc, char **argv)
|
||||
case OPT_NO_PROXY:
|
||||
opt_no_proxy = opt_str();
|
||||
break;
|
||||
case OPT_PATH:
|
||||
opt_path = opt_str();
|
||||
break;
|
||||
#endif
|
||||
case OPT_RECIPIENT:
|
||||
opt_recipient = opt_str();
|
||||
break;
|
||||
case OPT_PATH:
|
||||
opt_path = opt_str();
|
||||
break;
|
||||
case OPT_KEEP_ALIVE:
|
||||
opt_keep_alive = opt_int_arg();
|
||||
if (opt_keep_alive > 2) {
|
||||
@@ -2246,6 +2307,7 @@ static int get_opts(int argc, char **argv)
|
||||
case OPT_TOTAL_TIMEOUT:
|
||||
opt_total_timeout = opt_int_arg();
|
||||
break;
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
case OPT_TLS_USED:
|
||||
opt_tls_used = 1;
|
||||
break;
|
||||
@@ -2267,6 +2329,8 @@ static int get_opts(int argc, char **argv)
|
||||
case OPT_TLS_HOST:
|
||||
opt_tls_host = opt_str();
|
||||
break;
|
||||
#endif
|
||||
|
||||
case OPT_REF:
|
||||
opt_ref = opt_str();
|
||||
break;
|
||||
@@ -2455,12 +2519,15 @@ static int get_opts(int argc, char **argv)
|
||||
case OPT_USE_MOCK_SRV:
|
||||
opt_use_mock_srv = 1;
|
||||
break;
|
||||
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
case OPT_PORT:
|
||||
opt_port = opt_str();
|
||||
break;
|
||||
case OPT_MAX_MSGS:
|
||||
opt_max_msgs = opt_int_arg();
|
||||
break;
|
||||
#endif
|
||||
case OPT_SRV_REF:
|
||||
opt_srv_ref = opt_str();
|
||||
break;
|
||||
@@ -2625,7 +2692,9 @@ int cmp_main(int argc, char **argv)
|
||||
int i;
|
||||
X509 *newcert = NULL;
|
||||
ENGINE *engine = NULL;
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
char mock_server[] = "mock server:1";
|
||||
#endif
|
||||
OSSL_CMP_CTX *srv_cmp_ctx = NULL;
|
||||
int ret = 0; /* default: failure */
|
||||
|
||||
@@ -2687,6 +2756,8 @@ int cmp_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
ret = read_config();
|
||||
if (!set_verbosity(opt_verbosity)) /* just for checking range */
|
||||
ret = -1;
|
||||
if (ret <= 0) {
|
||||
if (ret == -1)
|
||||
BIO_printf(bio_err, "Use -help for summary.\n");
|
||||
@@ -2714,6 +2785,7 @@ int cmp_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
if (opt_port != NULL) {
|
||||
if (opt_use_mock_srv) {
|
||||
CMP_err("cannot use both -port and -use_mock_srv options");
|
||||
@@ -2724,6 +2796,7 @@ int cmp_main(int argc, char **argv)
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
cmp_ctx = OSSL_CMP_CTX_new(app_get0_libctx(), app_get0_propq());
|
||||
if (cmp_ctx == NULL)
|
||||
@@ -2733,14 +2806,18 @@ int cmp_main(int argc, char **argv)
|
||||
CMP_err1("cannot set up error reporting and logging for %s", prog);
|
||||
goto err;
|
||||
}
|
||||
if ((opt_use_mock_srv || opt_port != NULL)) {
|
||||
if (opt_use_mock_srv
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
|| opt_port != NULL
|
||||
#endif
|
||||
) {
|
||||
OSSL_CMP_SRV_CTX *srv_ctx;
|
||||
|
||||
if ((srv_ctx = setup_srv_ctx(engine)) == NULL)
|
||||
goto err;
|
||||
srv_cmp_ctx = OSSL_CMP_SRV_CTX_get0_cmp_ctx(srv_ctx);
|
||||
OSSL_CMP_CTX_set_transfer_cb_arg(cmp_ctx, srv_ctx);
|
||||
if (!OSSL_CMP_CTX_set_log_cb(srv_cmp_ctx, print_to_bio_out)) {
|
||||
if (!OSSL_CMP_CTX_set_log_cb(srv_cmp_ctx, print_to_bio_err)) {
|
||||
CMP_err1("cannot set up error reporting and logging for %s", prog);
|
||||
goto err;
|
||||
}
|
||||
@@ -2748,17 +2825,16 @@ int cmp_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
if (opt_port != NULL) { /* act as very basic CMP HTTP server */
|
||||
#ifdef OPENSSL_NO_SOCK
|
||||
BIO_printf(bio_err, "Cannot act as server - sockets not supported\n");
|
||||
#else
|
||||
ret = cmp_server(srv_cmp_ctx);
|
||||
#endif
|
||||
goto err;
|
||||
}
|
||||
#endif
|
||||
/* else act as CMP client */
|
||||
|
||||
if (opt_use_mock_srv) {
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
if (opt_server != NULL) {
|
||||
CMP_err("cannot use both -use_mock_srv and -server options");
|
||||
goto err;
|
||||
@@ -2769,6 +2845,7 @@ int cmp_main(int argc, char **argv)
|
||||
}
|
||||
opt_server = mock_server;
|
||||
opt_proxy = "API";
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!setup_client_ctx(cmp_ctx, engine)) {
|
||||
@@ -2833,7 +2910,14 @@ int cmp_main(int argc, char **argv)
|
||||
const char *string =
|
||||
OSSL_CMP_CTX_snprint_PKIStatus(cmp_ctx, buf,
|
||||
OSSL_CMP_PKISI_BUFLEN);
|
||||
const char *from = "", *server = "";
|
||||
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
if (opt_server != NULL) {
|
||||
from = " from ";
|
||||
server = opt_server;
|
||||
}
|
||||
#endif
|
||||
CMP_print(bio_err,
|
||||
status == OSSL_CMP_PKISTATUS_accepted
|
||||
? OSSL_CMP_LOG_INFO :
|
||||
@@ -2844,8 +2928,8 @@ int cmp_main(int argc, char **argv)
|
||||
status == OSSL_CMP_PKISTATUS_rejection ? "server error" :
|
||||
status == OSSL_CMP_PKISTATUS_waiting ? "internal error"
|
||||
: "warning",
|
||||
"received from %s %s %s", opt_server,
|
||||
string != NULL ? string : "<unknown PKIStatus>", "");
|
||||
"received%s%s %s", from, server,
|
||||
string != NULL ? string : "<unknown PKIStatus>");
|
||||
OPENSSL_free(buf);
|
||||
}
|
||||
|
||||
@@ -2882,7 +2966,9 @@ int cmp_main(int argc, char **argv)
|
||||
cleanse(opt_keypass);
|
||||
cleanse(opt_newkeypass);
|
||||
cleanse(opt_otherpass);
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
cleanse(opt_tls_keypass);
|
||||
#endif
|
||||
cleanse(opt_secret);
|
||||
cleanse(opt_srv_keypass);
|
||||
cleanse(opt_srv_secret);
|
||||
|
||||
Vendored
+2
-2
@@ -335,7 +335,7 @@ int dgst_main(int argc, char **argv)
|
||||
EVP_PKEY_CTX *pctx = NULL;
|
||||
int res;
|
||||
|
||||
if (!BIO_get_md_ctx(bmd, &mctx)) {
|
||||
if (BIO_get_md_ctx(bmd, &mctx) <= 0) {
|
||||
BIO_printf(bio_err, "Error getting context\n");
|
||||
goto end;
|
||||
}
|
||||
@@ -362,7 +362,7 @@ int dgst_main(int argc, char **argv)
|
||||
/* we use md as a filter, reading from 'in' */
|
||||
else {
|
||||
EVP_MD_CTX *mctx = NULL;
|
||||
if (!BIO_get_md_ctx(bmd, &mctx)) {
|
||||
if (BIO_get_md_ctx(bmd, &mctx) <= 0) {
|
||||
BIO_printf(bio_err, "Error getting context\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
Vendored
+3
-3
@@ -194,7 +194,7 @@ int dhparam_main(int argc, char **argv)
|
||||
"Generating %s parameters, %d bit long %sprime\n",
|
||||
alg, num, dsaparam ? "" : "safe ");
|
||||
|
||||
if (!EVP_PKEY_paramgen_init(ctx)) {
|
||||
if (EVP_PKEY_paramgen_init(ctx) <= 0) {
|
||||
BIO_printf(bio_err,
|
||||
"Error, unable to initialise %s parameters\n",
|
||||
alg);
|
||||
@@ -383,8 +383,8 @@ static EVP_PKEY *dsa_to_dh(EVP_PKEY *dh)
|
||||
|
||||
ctx = EVP_PKEY_CTX_new_from_name(NULL, "DHX", NULL);
|
||||
if (ctx == NULL
|
||||
|| !EVP_PKEY_fromdata_init(ctx)
|
||||
|| !EVP_PKEY_fromdata(ctx, &pkey, EVP_PKEY_KEY_PARAMETERS, params)) {
|
||||
|| EVP_PKEY_fromdata_init(ctx) <= 0
|
||||
|| EVP_PKEY_fromdata(ctx, &pkey, EVP_PKEY_KEY_PARAMETERS, params) <= 0) {
|
||||
BIO_printf(bio_err, "Error, failed to set DH parameters\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -211,7 +211,7 @@ int dsaparam_main(int argc, char **argv)
|
||||
"Error, DSA key generation context allocation failed\n");
|
||||
goto end;
|
||||
}
|
||||
if (!EVP_PKEY_keygen_init(ctx)) {
|
||||
if (EVP_PKEY_keygen_init(ctx) <= 0) {
|
||||
BIO_printf(bio_err,
|
||||
"Error, unable to initialise for key generation\n");
|
||||
goto end;
|
||||
|
||||
+9
-1
@@ -28,8 +28,14 @@ void app_RAND_load_conf(CONF *c, const char *section)
|
||||
BIO_printf(bio_err, "Can't load %s into RNG\n", randfile);
|
||||
ERR_print_errors(bio_err);
|
||||
}
|
||||
if (save_rand_file == NULL)
|
||||
if (save_rand_file == NULL) {
|
||||
save_rand_file = OPENSSL_strdup(randfile);
|
||||
/* If some internal memory errors have occurred */
|
||||
if (save_rand_file == NULL) {
|
||||
BIO_printf(bio_err, "Can't duplicate %s\n", randfile);
|
||||
ERR_print_errors(bio_err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int loadfiles(char *name)
|
||||
@@ -110,6 +116,8 @@ int opt_rand(int opt)
|
||||
case OPT_R_WRITERAND:
|
||||
OPENSSL_free(save_rand_file);
|
||||
save_rand_file = OPENSSL_strdup(opt_arg());
|
||||
if (save_rand_file == NULL)
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
|
||||
Vendored
+15
-3
@@ -2302,23 +2302,35 @@ int do_X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const char *md,
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
* do_X509_verify returns 1 if the signature is valid,
|
||||
* 0 if the signature check fails, or -1 if error occurs.
|
||||
*/
|
||||
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);
|
||||
rv = X509_verify(x, pkey);
|
||||
else
|
||||
rv = -1;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
* do_X509_REQ_verify returns 1 if the signature is valid,
|
||||
* 0 if the signature check fails, or -1 if error occurs.
|
||||
*/
|
||||
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_ex(x, pkey,
|
||||
app_get0_libctx(), app_get0_propq()) > 0);
|
||||
rv = X509_REQ_verify_ex(x, pkey,
|
||||
app_get0_libctx(), app_get0_propq());
|
||||
else
|
||||
rv = -1;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2018-2021 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -91,7 +91,7 @@ static OSSL_STORE_LOADER_CTX *engine_open(const OSSL_STORE_LOADER *loader,
|
||||
keyid = OPENSSL_strdup(q + 1);
|
||||
}
|
||||
|
||||
if (e != NULL)
|
||||
if (e != NULL && keyid != NULL)
|
||||
ctx = OSSL_STORE_LOADER_CTX_new(e, keyid);
|
||||
|
||||
if (ctx == NULL) {
|
||||
|
||||
Vendored
+29
-11
@@ -146,6 +146,7 @@ int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key,
|
||||
STACK_OF(X509) *chain, int build_chain)
|
||||
{
|
||||
int chflags = chain ? SSL_BUILD_CHAIN_FLAG_CHECK : 0;
|
||||
|
||||
if (cert == NULL)
|
||||
return 1;
|
||||
if (SSL_CTX_use_certificate(ctx, cert) <= 0) {
|
||||
@@ -199,6 +200,7 @@ static void ssl_print_client_cert_types(BIO *bio, SSL *s)
|
||||
const unsigned char *p;
|
||||
int i;
|
||||
int cert_type_num = SSL_get0_certificate_types(s, &p);
|
||||
|
||||
if (!cert_type_num)
|
||||
return;
|
||||
BIO_puts(bio, "Client Certificate Types: ");
|
||||
@@ -228,22 +230,22 @@ static const char *get_sigtype(int nid)
|
||||
case EVP_PKEY_DSA:
|
||||
return "DSA";
|
||||
|
||||
case EVP_PKEY_EC:
|
||||
case EVP_PKEY_EC:
|
||||
return "ECDSA";
|
||||
|
||||
case NID_ED25519:
|
||||
case NID_ED25519:
|
||||
return "Ed25519";
|
||||
|
||||
case NID_ED448:
|
||||
case NID_ED448:
|
||||
return "Ed448";
|
||||
|
||||
case NID_id_GostR3410_2001:
|
||||
case NID_id_GostR3410_2001:
|
||||
return "gost2001";
|
||||
|
||||
case NID_id_GostR3410_2012_256:
|
||||
case NID_id_GostR3410_2012_256:
|
||||
return "gost2012_256";
|
||||
|
||||
case NID_id_GostR3410_2012_512:
|
||||
case NID_id_GostR3410_2012_512:
|
||||
return "gost2012_512";
|
||||
|
||||
default:
|
||||
@@ -254,6 +256,7 @@ static const char *get_sigtype(int nid)
|
||||
static int do_print_sigalgs(BIO *out, SSL *s, int shared)
|
||||
{
|
||||
int i, nsig, client;
|
||||
|
||||
client = SSL_is_server(s) ? 0 : 1;
|
||||
if (shared)
|
||||
nsig = SSL_get_shared_sigalgs(s, 0, NULL, NULL, NULL, NULL, NULL);
|
||||
@@ -296,6 +299,7 @@ static int do_print_sigalgs(BIO *out, SSL *s, int shared)
|
||||
int ssl_print_sigalgs(BIO *out, SSL *s)
|
||||
{
|
||||
int nid;
|
||||
|
||||
if (!SSL_is_server(s))
|
||||
ssl_print_client_cert_types(out, s);
|
||||
do_print_sigalgs(out, s, 0);
|
||||
@@ -312,6 +316,7 @@ int ssl_print_point_formats(BIO *out, SSL *s)
|
||||
{
|
||||
int i, nformats;
|
||||
const char *pformats;
|
||||
|
||||
nformats = SSL_get0_ec_point_formats(s, &pformats);
|
||||
if (nformats <= 0)
|
||||
return 1;
|
||||
@@ -895,6 +900,7 @@ static int set_cert_cb(SSL *ssl, void *arg)
|
||||
SSL_EXCERT *exc = arg;
|
||||
#ifdef CERT_CB_TEST_RETRY
|
||||
static int retry_cnt;
|
||||
|
||||
if (retry_cnt < 5) {
|
||||
retry_cnt++;
|
||||
BIO_printf(bio_err,
|
||||
@@ -993,6 +999,7 @@ void ssl_excert_free(SSL_EXCERT *exc)
|
||||
int load_excert(SSL_EXCERT **pexc)
|
||||
{
|
||||
SSL_EXCERT *exc = *pexc;
|
||||
|
||||
if (exc == NULL)
|
||||
return 1;
|
||||
/* If nothing in list, free and set to NULL */
|
||||
@@ -1098,6 +1105,7 @@ static void print_raw_cipherlist(SSL *s)
|
||||
const unsigned char *rlist;
|
||||
static const unsigned char scsv_id[] = { 0, 0xFF };
|
||||
size_t i, rlistlen, num;
|
||||
|
||||
if (!SSL_is_server(s))
|
||||
return;
|
||||
num = SSL_get0_raw_cipherlist(s, NULL);
|
||||
@@ -1275,6 +1283,7 @@ static int add_crls_store(X509_STORE *st, STACK_OF(X509_CRL) *crls)
|
||||
int ssl_ctx_add_crls(SSL_CTX *ctx, STACK_OF(X509_CRL) *crls, int crl_download)
|
||||
{
|
||||
X509_STORE *st;
|
||||
|
||||
st = SSL_CTX_get_cert_store(ctx);
|
||||
add_crls_store(st, crls);
|
||||
if (crl_download)
|
||||
@@ -1291,6 +1300,7 @@ int ssl_load_stores(SSL_CTX *ctx,
|
||||
{
|
||||
X509_STORE *vfy = NULL, *ch = NULL;
|
||||
int rv = 0;
|
||||
|
||||
if (vfyCApath != NULL || vfyCAfile != NULL || vfyCAstore != NULL) {
|
||||
vfy = X509_STORE_new();
|
||||
if (vfy == NULL)
|
||||
@@ -1367,6 +1377,7 @@ static int security_callback_debug(const SSL *s, const SSL_CTX *ctx,
|
||||
int rv, show_bits = 1, cert_md = 0;
|
||||
const char *nm;
|
||||
int show_nm;
|
||||
|
||||
rv = sdb->old_cb(s, ctx, op, bits, nid, other, ex);
|
||||
if (rv == 1 && sdb->verbose < 2)
|
||||
return 1;
|
||||
@@ -1420,14 +1431,21 @@ static int security_callback_debug(const SSL *s, const SSL_CTX *ctx,
|
||||
{
|
||||
if (cert_md) {
|
||||
int sig_nid = X509_get_signature_nid(other);
|
||||
|
||||
BIO_puts(sdb->out, OBJ_nid2sn(sig_nid));
|
||||
} else {
|
||||
EVP_PKEY *pkey = X509_get0_pubkey(other);
|
||||
const char *algname = "";
|
||||
EVP_PKEY_asn1_get0_info(NULL, NULL, NULL, NULL,
|
||||
&algname, EVP_PKEY_get0_asn1(pkey));
|
||||
BIO_printf(sdb->out, "%s, bits=%d",
|
||||
algname, EVP_PKEY_get_bits(pkey));
|
||||
|
||||
if (pkey == NULL) {
|
||||
BIO_printf(sdb->out, "Public key missing");
|
||||
} else {
|
||||
const char *algname = "";
|
||||
|
||||
EVP_PKEY_asn1_get0_info(NULL, NULL, NULL, NULL,
|
||||
&algname, EVP_PKEY_get0_asn1(pkey));
|
||||
BIO_printf(sdb->out, "%s, bits=%d",
|
||||
algname, EVP_PKEY_get_bits(pkey));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Vendored
+5
-1
@@ -168,14 +168,17 @@ static void setup_trace_category(int category)
|
||||
{
|
||||
BIO *channel;
|
||||
tracedata *trace_data;
|
||||
BIO *bio = NULL;
|
||||
|
||||
if (OSSL_trace_enabled(category))
|
||||
return;
|
||||
|
||||
channel = BIO_push(BIO_new(BIO_f_prefix()), dup_bio_err(FORMAT_TEXT));
|
||||
bio = BIO_new(BIO_f_prefix());
|
||||
channel = BIO_push(bio, dup_bio_err(FORMAT_TEXT));
|
||||
trace_data = OPENSSL_zalloc(sizeof(*trace_data));
|
||||
|
||||
if (trace_data == NULL
|
||||
|| bio == NULL
|
||||
|| (trace_data->bio = channel) == NULL
|
||||
|| OSSL_trace_set_callback(category, internal_trace_cb,
|
||||
trace_data) == 0
|
||||
@@ -395,6 +398,7 @@ static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[])
|
||||
|
||||
if (argc <= 0 || argv[0] == NULL)
|
||||
return 0;
|
||||
memset(&f, 0, sizeof(f));
|
||||
f.name = argv[0];
|
||||
fp = lh_FUNCTION_retrieve(prog, &f);
|
||||
if (fp == NULL) {
|
||||
|
||||
Vendored
+8
-5
@@ -103,7 +103,7 @@ const OPTIONS req_options[] = {
|
||||
{"keygen_engine", OPT_KEYGEN_ENGINE, 's',
|
||||
"Specify engine to be used for key generation operations"},
|
||||
#endif
|
||||
{"in", OPT_IN, '<', "X.509 request input file"},
|
||||
{"in", OPT_IN, '<', "X.509 request input file (default stdin)"},
|
||||
{"inform", OPT_INFORM, 'F', "Input format - DER or PEM"},
|
||||
{"verify", OPT_VERIFY, '-', "Verify self-signature on the request"},
|
||||
|
||||
@@ -136,10 +136,11 @@ const OPTIONS req_options[] = {
|
||||
"Cert extension section (override value in config file)"},
|
||||
{"reqexts", OPT_REQEXTS, 's',
|
||||
"Request extension section (override value in config file)"},
|
||||
{"precert", OPT_PRECERT, '-', "Add a poison extension (implies -new)"},
|
||||
{"precert", OPT_PRECERT, '-',
|
||||
"Add a poison extension to the generated cert (implies -new)"},
|
||||
|
||||
OPT_SECTION("Keys and Signing"),
|
||||
{"key", OPT_KEY, 's', "Key to include and to use for self-signature"},
|
||||
{"key", OPT_KEY, 's', "Key for signing, and to include unless -in given"},
|
||||
{"keyform", OPT_KEYFORM, 'f', "Key file format (ENGINE, other values ignored)"},
|
||||
{"pubkey", OPT_PUBKEY, '-', "Output public key"},
|
||||
{"keyout", OPT_KEYOUT, '>', "File to write private key to"},
|
||||
@@ -742,7 +743,8 @@ int req_main(int argc, char **argv)
|
||||
goto end;
|
||||
|
||||
if (!newreq) {
|
||||
req = load_csr(infile, informat, "X509 request");
|
||||
req = load_csr(infile /* if NULL, reads from stdin */,
|
||||
informat, "X509 request");
|
||||
if (req == NULL)
|
||||
goto end;
|
||||
}
|
||||
@@ -752,7 +754,7 @@ int req_main(int argc, char **argv)
|
||||
if (CAkeyfile != NULL) {
|
||||
if (CAfile == NULL) {
|
||||
BIO_printf(bio_err,
|
||||
"Ignoring -CAkey option since no -CA option is given\n");
|
||||
"Warning: Ignoring -CAkey option since no -CA option is given\n");
|
||||
} else {
|
||||
if ((CAkey = load_key(CAkeyfile, FORMAT_UNDEF,
|
||||
0, passin, e,
|
||||
@@ -788,6 +790,7 @@ int req_main(int argc, char **argv)
|
||||
BIO_printf(bio_err, "Error making certificate request\n");
|
||||
goto end;
|
||||
}
|
||||
/* Note that -x509 can take over -key and -subj option values. */
|
||||
}
|
||||
if (gen_x509) {
|
||||
EVP_PKEY *pub_key = X509_REQ_get0_pubkey(req);
|
||||
|
||||
Vendored
+4
-2
@@ -3040,6 +3040,8 @@ int s_client_main(int argc, char **argv)
|
||||
#endif
|
||||
OPENSSL_free(connectstr);
|
||||
OPENSSL_free(bindstr);
|
||||
OPENSSL_free(bindhost);
|
||||
OPENSSL_free(bindport);
|
||||
OPENSSL_free(host);
|
||||
OPENSSL_free(port);
|
||||
OPENSSL_free(thost);
|
||||
@@ -3276,11 +3278,11 @@ static void print_stuff(BIO *bio, SSL *s, int full)
|
||||
BIO_printf(bio, " Label: '%s'\n", keymatexportlabel);
|
||||
BIO_printf(bio, " Length: %i bytes\n", keymatexportlen);
|
||||
exportedkeymat = app_malloc(keymatexportlen, "export key");
|
||||
if (!SSL_export_keying_material(s, exportedkeymat,
|
||||
if (SSL_export_keying_material(s, exportedkeymat,
|
||||
keymatexportlen,
|
||||
keymatexportlabel,
|
||||
strlen(keymatexportlabel),
|
||||
NULL, 0, 0)) {
|
||||
NULL, 0, 0) <= 0) {
|
||||
BIO_printf(bio, " Error\n");
|
||||
} else {
|
||||
BIO_printf(bio, " Keying material: ");
|
||||
|
||||
Vendored
+7
-7
@@ -131,12 +131,12 @@ static unsigned int psk_server_cb(SSL *ssl, const char *identity,
|
||||
if (s_debug)
|
||||
BIO_printf(bio_s_out, "psk_server_cb\n");
|
||||
|
||||
if (SSL_version(ssl) >= TLS1_3_VERSION) {
|
||||
if (!SSL_is_dtls(ssl) && SSL_version(ssl) >= TLS1_3_VERSION) {
|
||||
/*
|
||||
* This callback is designed for use in TLSv1.2. It is possible to use
|
||||
* a single callback for all protocol versions - but it is preferred to
|
||||
* use a dedicated callback for TLSv1.3. For TLSv1.3 we have
|
||||
* psk_find_session_cb.
|
||||
* This callback is designed for use in (D)TLSv1.2 (or below). It is
|
||||
* possible to use a single callback for all protocol versions - but it
|
||||
* is preferred to use a dedicated callback for TLSv1.3. For TLSv1.3 we
|
||||
* have psk_find_session_cb.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
@@ -2940,11 +2940,11 @@ static void print_connection_info(SSL *con)
|
||||
BIO_printf(bio_s_out, " Label: '%s'\n", keymatexportlabel);
|
||||
BIO_printf(bio_s_out, " Length: %i bytes\n", keymatexportlen);
|
||||
exportedkeymat = app_malloc(keymatexportlen, "export key");
|
||||
if (!SSL_export_keying_material(con, exportedkeymat,
|
||||
if (SSL_export_keying_material(con, exportedkeymat,
|
||||
keymatexportlen,
|
||||
keymatexportlabel,
|
||||
strlen(keymatexportlabel),
|
||||
NULL, 0, 0)) {
|
||||
NULL, 0, 0) <= 0) {
|
||||
BIO_printf(bio_s_out, " Error\n");
|
||||
} else {
|
||||
BIO_printf(bio_s_out, " Keying material: ");
|
||||
|
||||
Vendored
+16
-4
@@ -462,6 +462,7 @@ typedef struct loopargs_st {
|
||||
unsigned char *buf_malloc;
|
||||
unsigned char *buf2_malloc;
|
||||
unsigned char *key;
|
||||
size_t buflen;
|
||||
size_t sigsize;
|
||||
EVP_PKEY_CTX *rsa_sign_ctx[RSA_NUM];
|
||||
EVP_PKEY_CTX *rsa_verify_ctx[RSA_NUM];
|
||||
@@ -832,6 +833,7 @@ static int RSA_sign_loop(void *args)
|
||||
int ret, count;
|
||||
|
||||
for (count = 0; COND(rsa_c[testnum][0]); count++) {
|
||||
*rsa_num = tempargs->buflen;
|
||||
ret = EVP_PKEY_sign(rsa_sign_ctx[testnum], buf2, rsa_num, buf, 36);
|
||||
if (ret <= 0) {
|
||||
BIO_printf(bio_err, "RSA sign failure\n");
|
||||
@@ -892,6 +894,7 @@ static int DSA_sign_loop(void *args)
|
||||
int ret, count;
|
||||
|
||||
for (count = 0; COND(dsa_c[testnum][0]); count++) {
|
||||
*dsa_num = tempargs->buflen;
|
||||
ret = EVP_PKEY_sign(dsa_sign_ctx[testnum], buf2, dsa_num, buf, 20);
|
||||
if (ret <= 0) {
|
||||
BIO_printf(bio_err, "DSA sign failure\n");
|
||||
@@ -935,6 +938,7 @@ static int ECDSA_sign_loop(void *args)
|
||||
int ret, count;
|
||||
|
||||
for (count = 0; COND(ecdsa_c[testnum][0]); count++) {
|
||||
*ecdsa_num = tempargs->buflen;
|
||||
ret = EVP_PKEY_sign(ecdsa_sign_ctx[testnum], buf2, ecdsa_num, buf, 20);
|
||||
if (ret <= 0) {
|
||||
BIO_printf(bio_err, "ECDSA sign failure\n");
|
||||
@@ -1540,6 +1544,10 @@ int speed_main(int argc, char **argv)
|
||||
case OPT_MULTI:
|
||||
#ifndef NO_FORK
|
||||
multi = atoi(opt_arg());
|
||||
if ((size_t)multi >= SIZE_MAX / sizeof(int)) {
|
||||
BIO_printf(bio_err, "%s: multi argument too large\n", prog);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case OPT_ASYNCJOBS:
|
||||
@@ -1775,6 +1783,8 @@ int speed_main(int argc, char **argv)
|
||||
/* Align the start of buffers on a 64 byte boundary */
|
||||
loopargs[i].buf = loopargs[i].buf_malloc + misalign;
|
||||
loopargs[i].buf2 = loopargs[i].buf2_malloc + misalign;
|
||||
loopargs[i].buflen = buflen - misalign;
|
||||
loopargs[i].sigsize = buflen - misalign;
|
||||
loopargs[i].secret_a = app_malloc(MAX_ECDH_SIZE, "ECDH secret a");
|
||||
loopargs[i].secret_b = app_malloc(MAX_ECDH_SIZE, "ECDH secret b");
|
||||
#ifndef OPENSSL_NO_DH
|
||||
@@ -2345,6 +2355,7 @@ int speed_main(int argc, char **argv)
|
||||
|
||||
for (i = 0; st && i < loopargs_len; i++) {
|
||||
loopargs[i].rsa_sign_ctx[testnum] = EVP_PKEY_CTX_new(rsa_key, NULL);
|
||||
loopargs[i].sigsize = loopargs[i].buflen;
|
||||
if (loopargs[i].rsa_sign_ctx[testnum] == NULL
|
||||
|| EVP_PKEY_sign_init(loopargs[i].rsa_sign_ctx[testnum]) <= 0
|
||||
|| EVP_PKEY_sign(loopargs[i].rsa_sign_ctx[testnum],
|
||||
@@ -2423,6 +2434,7 @@ int speed_main(int argc, char **argv)
|
||||
for (i = 0; st && i < loopargs_len; i++) {
|
||||
loopargs[i].dsa_sign_ctx[testnum] = EVP_PKEY_CTX_new(dsa_key,
|
||||
NULL);
|
||||
loopargs[i].sigsize = loopargs[i].buflen;
|
||||
if (loopargs[i].dsa_sign_ctx[testnum] == NULL
|
||||
|| EVP_PKEY_sign_init(loopargs[i].dsa_sign_ctx[testnum]) <= 0
|
||||
|
||||
@@ -2501,6 +2513,7 @@ int speed_main(int argc, char **argv)
|
||||
for (i = 0; st && i < loopargs_len; i++) {
|
||||
loopargs[i].ecdsa_sign_ctx[testnum] = EVP_PKEY_CTX_new(ecdsa_key,
|
||||
NULL);
|
||||
loopargs[i].sigsize = loopargs[i].buflen;
|
||||
if (loopargs[i].ecdsa_sign_ctx[testnum] == NULL
|
||||
|| EVP_PKEY_sign_init(loopargs[i].ecdsa_sign_ctx[testnum]) <= 0
|
||||
|
||||
@@ -3092,10 +3105,9 @@ int speed_main(int argc, char **argv)
|
||||
#endif
|
||||
if (!mr) {
|
||||
printf("version: %s\n", OpenSSL_version(OPENSSL_FULL_VERSION_STRING));
|
||||
printf("built on: %s\n", OpenSSL_version(OPENSSL_BUILT_ON));
|
||||
printf("options:");
|
||||
printf("%s ", BN_options());
|
||||
printf("\n%s\n", OpenSSL_version(OPENSSL_CFLAGS));
|
||||
printf("%s\n", OpenSSL_version(OPENSSL_BUILT_ON));
|
||||
printf("options: %s\n", BN_options());
|
||||
printf("%s\n", OpenSSL_version(OPENSSL_CFLAGS));
|
||||
printf("%s\n", OpenSSL_version(OPENSSL_CPU_INFO));
|
||||
}
|
||||
|
||||
|
||||
Vendored
+26
-26
@@ -1,5 +1,5 @@
|
||||
#!{- $config{HASHBANGPERL} -}
|
||||
# Copyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2002-2021 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright (c) 2002 The OpenTSA Project. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
@@ -21,10 +21,10 @@ sub read_body {
|
||||
my $return_data = "";
|
||||
my $data_len = length ${$state->{data}};
|
||||
if ($state->{bytes} < $data_len) {
|
||||
$data_len = $data_len - $state->{bytes};
|
||||
$data_len = $maxlength if $data_len > $maxlength;
|
||||
$return_data = substr ${$state->{data}}, $state->{bytes}, $data_len;
|
||||
$state->{bytes} += $data_len;
|
||||
$data_len = $data_len - $state->{bytes};
|
||||
$data_len = $maxlength if $data_len > $maxlength;
|
||||
$return_data = substr ${$state->{data}}, $state->{bytes}, $data_len;
|
||||
$state->{bytes} += $data_len;
|
||||
}
|
||||
return $return_data;
|
||||
}
|
||||
@@ -53,8 +53,8 @@ sub create_curl {
|
||||
$curl->setopt(CURLOPT_UPLOAD, 1);
|
||||
$curl->setopt(CURLOPT_CUSTOMREQUEST, "POST");
|
||||
$curl->setopt(CURLOPT_HTTPHEADER,
|
||||
["Content-Type: application/timestamp-query",
|
||||
"Accept: application/timestamp-reply,application/timestamp-response"]);
|
||||
["Content-Type: application/timestamp-query",
|
||||
"Accept: application/timestamp-reply,application/timestamp-response"]);
|
||||
$curl->setopt(CURLOPT_READFUNCTION, \&read_body);
|
||||
$curl->setopt(CURLOPT_HEADERFUNCTION, sub { return length($_[0]); });
|
||||
|
||||
@@ -63,8 +63,8 @@ sub create_curl {
|
||||
|
||||
# SSL related options.
|
||||
$curl->setopt(CURLOPT_SSLKEYTYPE, "PEM");
|
||||
$curl->setopt(CURLOPT_SSL_VERIFYPEER, 1); # Verify server's certificate.
|
||||
$curl->setopt(CURLOPT_SSL_VERIFYHOST, 2); # Check server's CN.
|
||||
$curl->setopt(CURLOPT_SSL_VERIFYPEER, 1); # Verify server's certificate.
|
||||
$curl->setopt(CURLOPT_SSL_VERIFYHOST, 2); # Check server's CN.
|
||||
$curl->setopt(CURLOPT_SSLKEY, $options{k}) if defined($options{k});
|
||||
$curl->setopt(CURLOPT_SSLKEYPASSWD, $options{p}) if defined($options{p});
|
||||
$curl->setopt(CURLOPT_SSLCERT, $options{c}) if defined($options{c});
|
||||
@@ -101,15 +101,15 @@ sub get_timestamp {
|
||||
my $error_string;
|
||||
if ($error_code != 0) {
|
||||
my $http_code = $curl->getinfo(CURLINFO_HTTP_CODE);
|
||||
$error_string = "could not get timestamp";
|
||||
$error_string .= ", http code: $http_code" unless $http_code == 0;
|
||||
$error_string .= ", curl code: $error_code";
|
||||
$error_string .= " ($::error_buf)" if defined($::error_buf);
|
||||
$error_string = "could not get timestamp";
|
||||
$error_string .= ", http code: $http_code" unless $http_code == 0;
|
||||
$error_string .= ", curl code: $error_code";
|
||||
$error_string .= " ($::error_buf)" if defined($::error_buf);
|
||||
} else {
|
||||
my $ct = $curl->getinfo(CURLINFO_CONTENT_TYPE);
|
||||
if (lc($ct) ne "application/timestamp-reply"
|
||||
&& lc($ct) ne "application/timestamp-response") {
|
||||
$error_string = "unexpected content type returned: $ct";
|
||||
if (lc($ct) ne "application/timestamp-reply"
|
||||
&& lc($ct) ne "application/timestamp-response") {
|
||||
$error_string = "unexpected content type returned: $ct";
|
||||
}
|
||||
}
|
||||
return ($ts_body, $error_string);
|
||||
@@ -163,15 +163,15 @@ REQUEST: foreach (@ARGV) {
|
||||
# Read request.
|
||||
my $body;
|
||||
if ($input eq "-") {
|
||||
# Read the request from STDIN;
|
||||
$body = <STDIN>;
|
||||
# Read the request from STDIN;
|
||||
$body = <STDIN>;
|
||||
} else {
|
||||
# Read the request from file.
|
||||
# Read the request from file.
|
||||
open INPUT, "<" . $input
|
||||
or warn("$input: could not open input file: $!\n"), next REQUEST;
|
||||
or warn("$input: could not open input file: $!\n"), next REQUEST;
|
||||
$body = <INPUT>;
|
||||
close INPUT
|
||||
or warn("$input: could not close input file: $!\n"), next REQUEST;
|
||||
or warn("$input: could not close input file: $!\n"), next REQUEST;
|
||||
}
|
||||
|
||||
# Send request.
|
||||
@@ -179,21 +179,21 @@ REQUEST: foreach (@ARGV) {
|
||||
|
||||
my ($ts_body, $error) = get_timestamp $curl, \$body;
|
||||
if (defined($error)) {
|
||||
die "$input: fatal error: $error\n";
|
||||
die "$input: fatal error: $error\n";
|
||||
}
|
||||
STDERR->printflush(", reply received") if $options{v};
|
||||
|
||||
# Write response.
|
||||
if ($output eq "-") {
|
||||
# Write to STDOUT.
|
||||
# Write to STDOUT.
|
||||
print $ts_body;
|
||||
} else {
|
||||
# Write to file.
|
||||
# Write to file.
|
||||
open OUTPUT, ">", $output
|
||||
or warn("$output: could not open output file: $!\n"), next REQUEST;
|
||||
or warn("$output: could not open output file: $!\n"), next REQUEST;
|
||||
print OUTPUT $ts_body;
|
||||
close OUTPUT
|
||||
or warn("$output: could not close output file: $!\n"), next REQUEST;
|
||||
or warn("$output: could not close output file: $!\n"), next REQUEST;
|
||||
}
|
||||
STDERR->printflush(", $output written.\n") if $options{v};
|
||||
}
|
||||
|
||||
Vendored
+28
-21
@@ -61,7 +61,7 @@ const OPTIONS x509_options[] = {
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
|
||||
{"in", OPT_IN, '<',
|
||||
"Certificate input (default stdin), or CSR input file with -req"},
|
||||
"Certificate input, or CSR input file with -req (default stdin)"},
|
||||
{"passin", OPT_PASSIN, 's', "Private key and cert file pass-phrase source"},
|
||||
{"new", OPT_NEW, '-', "Generate a certificate from scratch"},
|
||||
{"x509toreq", OPT_X509TOREQ, '-',
|
||||
@@ -73,7 +73,7 @@ const OPTIONS x509_options[] = {
|
||||
"CSR input file format (DER or PEM) - default PEM"},
|
||||
{"vfyopt", OPT_VFYOPT, 's', "CSR verification parameter in n:v form"},
|
||||
{"key", OPT_KEY, 's',
|
||||
"Key to be used in certificate or cert request"},
|
||||
"Key for signing, and to include unless using -force_pubkey"},
|
||||
{"signkey", OPT_SIGNKEY, 's',
|
||||
"Same as -key"},
|
||||
{"keyform", OPT_KEYFORM, 'E',
|
||||
@@ -235,6 +235,21 @@ static X509_REQ *x509_to_req(X509 *cert, int ext_copy, const char *names)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int self_signed(X509_STORE *ctx, X509 *cert)
|
||||
{
|
||||
X509_STORE_CTX *xsc = X509_STORE_CTX_new();
|
||||
int ret = 0;
|
||||
|
||||
if (xsc == NULL || !X509_STORE_CTX_init(xsc, ctx, cert, NULL)) {
|
||||
BIO_printf(bio_err, "Error initialising X509 store\n");
|
||||
} else {
|
||||
X509_STORE_CTX_set_flags(xsc, X509_V_FLAG_CHECK_SS_SIGNATURE);
|
||||
ret = X509_verify_cert(xsc) > 0;
|
||||
}
|
||||
X509_STORE_CTX_free(xsc);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int x509_main(int argc, char **argv)
|
||||
{
|
||||
ASN1_INTEGER *sno = NULL;
|
||||
@@ -630,7 +645,7 @@ int x509_main(int argc, char **argv)
|
||||
}
|
||||
if (privkeyfile == NULL && pubkeyfile == NULL) {
|
||||
BIO_printf(bio_err,
|
||||
"The -new option without -key requires using -force_pubkey\n");
|
||||
"The -new option requires using the -key or -force_pubkey option\n");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
@@ -642,7 +657,7 @@ int x509_main(int argc, char **argv)
|
||||
CAkeyfile = CAfile;
|
||||
if (CAfile != NULL) {
|
||||
if (privkeyfile != NULL) {
|
||||
BIO_printf(bio_err, "Cannot use both -key and -CA option\n");
|
||||
BIO_printf(bio_err, "Cannot use both -key/-signkey and -CA option\n");
|
||||
goto end;
|
||||
}
|
||||
} else if (CAkeyfile != NULL) {
|
||||
@@ -787,6 +802,8 @@ int x509_main(int argc, char **argv)
|
||||
sno = x509_load_serial(CAfile, CAserial, CA_createserial);
|
||||
if (sno == NULL)
|
||||
goto end;
|
||||
if (!x509toreq && !reqfile && !newcert && !self_signed(ctx, x))
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (sno != NULL && !X509_set_serialNumber(x, sno))
|
||||
@@ -799,7 +816,12 @@ int x509_main(int argc, char **argv)
|
||||
goto end;
|
||||
}
|
||||
|
||||
X509V3_set_ctx(&ext_ctx, issuer_cert, x, req, NULL, X509V3_CTX_REPLACE);
|
||||
X509V3_set_ctx(&ext_ctx, issuer_cert, x, NULL, NULL, X509V3_CTX_REPLACE);
|
||||
/* prepare fallback for AKID, but only if issuer cert equals subject cert */
|
||||
if (CAfile == NULL) {
|
||||
if (!X509V3_set_issuer_pkey(&ext_ctx, privkey))
|
||||
goto end;
|
||||
}
|
||||
if (extconf != NULL && !x509toreq) {
|
||||
X509V3_set_nconf(&ext_ctx, extconf);
|
||||
if (!X509V3_EXT_add_nconf(extconf, &ext_ctx, extsect, x)) {
|
||||
@@ -819,7 +841,7 @@ int x509_main(int argc, char **argv)
|
||||
|
||||
if (x509toreq) { /* also works in conjunction with -req */
|
||||
if (privkey == NULL) {
|
||||
BIO_printf(bio_err, "Must specify request key using -key\n");
|
||||
BIO_printf(bio_err, "Must specify request signing key using -key\n");
|
||||
goto end;
|
||||
}
|
||||
if (clrext && ext_copy != EXT_COPY_NONE) {
|
||||
@@ -856,21 +878,6 @@ int x509_main(int argc, char **argv)
|
||||
if (!do_X509_sign(x, privkey, digest, sigopts, &ext_ctx))
|
||||
goto end;
|
||||
} else if (CAfile != NULL) {
|
||||
if (!reqfile && !newcert) { /* certificate should be self-signed */
|
||||
X509_STORE_CTX *xsc = X509_STORE_CTX_new();
|
||||
|
||||
if (xsc == NULL || !X509_STORE_CTX_init(xsc, ctx, x, NULL)) {
|
||||
BIO_printf(bio_err, "Error initialising X509 store\n");
|
||||
X509_STORE_CTX_free(xsc);
|
||||
goto end;
|
||||
}
|
||||
X509_STORE_CTX_set_cert(xsc, x);
|
||||
X509_STORE_CTX_set_flags(xsc, X509_V_FLAG_CHECK_SS_SIGNATURE);
|
||||
i = X509_verify_cert(xsc);
|
||||
X509_STORE_CTX_free(xsc);
|
||||
if (i <= 0)
|
||||
goto end;
|
||||
}
|
||||
if ((CAkey = load_key(CAkeyfile, CAkeyformat,
|
||||
0, passin, e, "CA private key")) == NULL)
|
||||
goto end;
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ IF[{- !$disabled{asm} -}]
|
||||
$AESASM_x86=aes-586.s
|
||||
$AESDEF_x86=AES_ASM
|
||||
$AESASM_x86_sse2=vpaes-x86.s aesni-x86.s
|
||||
$AESDEF_x86_sse2=VPAES_ASM
|
||||
$AESDEF_x86_sse2=VPAES_ASM OPENSSL_IA32_SSE2
|
||||
|
||||
$AESASM_x86_64=\
|
||||
aes-x86_64.s vpaes-x86_64.s bsaes-x86_64.s aesni-x86_64.s \
|
||||
|
||||
Vendored
+9
-6
@@ -112,20 +112,23 @@ static unsigned long getauxval(unsigned long key)
|
||||
* ARM puts the feature bits for Crypto Extensions in AT_HWCAP2, whereas
|
||||
* AArch64 used AT_HWCAP.
|
||||
*/
|
||||
# ifndef AT_HWCAP
|
||||
# define AT_HWCAP 16
|
||||
# endif
|
||||
# ifndef AT_HWCAP2
|
||||
# define AT_HWCAP2 26
|
||||
# endif
|
||||
# if defined(__arm__) || defined (__arm)
|
||||
# define HWCAP 16
|
||||
/* AT_HWCAP */
|
||||
# define HWCAP AT_HWCAP
|
||||
# define HWCAP_NEON (1 << 12)
|
||||
|
||||
# define HWCAP_CE 26
|
||||
/* AT_HWCAP2 */
|
||||
# define HWCAP_CE AT_HWCAP2
|
||||
# define HWCAP_CE_AES (1 << 0)
|
||||
# define HWCAP_CE_PMULL (1 << 1)
|
||||
# define HWCAP_CE_SHA1 (1 << 2)
|
||||
# define HWCAP_CE_SHA256 (1 << 3)
|
||||
# elif defined(__aarch64__)
|
||||
# define HWCAP 16
|
||||
/* AT_HWCAP */
|
||||
# define HWCAP AT_HWCAP
|
||||
# define HWCAP_NEON (1 << 1)
|
||||
|
||||
# define HWCAP_CE HWCAP
|
||||
|
||||
+20
-3
@@ -29,16 +29,27 @@ EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,
|
||||
long length)
|
||||
{
|
||||
EVP_PKEY *ret;
|
||||
EVP_PKEY *copy = NULL;
|
||||
|
||||
if ((a == NULL) || (*a == NULL)) {
|
||||
if ((ret = EVP_PKEY_new()) == NULL) {
|
||||
ERR_raise(ERR_LIB_ASN1, ERR_R_EVP_LIB);
|
||||
return NULL;
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
ret = *a;
|
||||
|
||||
if (type != EVP_PKEY_get_id(ret) && !EVP_PKEY_set_type(ret, type)) {
|
||||
#ifndef OPENSSL_NO_EC
|
||||
if (evp_pkey_is_provided(ret)
|
||||
&& EVP_PKEY_get_base_id(ret) == EVP_PKEY_EC) {
|
||||
if (!evp_pkey_copy_downgraded(©, ret))
|
||||
goto err;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if ((type != EVP_PKEY_get_id(ret) || copy != NULL)
|
||||
&& !EVP_PKEY_set_type(ret, type)) {
|
||||
ERR_raise(ERR_LIB_ASN1, ERR_R_EVP_LIB);
|
||||
goto err;
|
||||
}
|
||||
@@ -52,7 +63,6 @@ EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,
|
||||
break;
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
case EVP_PKEY_DSA:
|
||||
/* TMP UGLY CAST */
|
||||
if (!d2i_DSAPublicKey(&ret->pkey.dsa, pp, length)) {
|
||||
ERR_raise(ERR_LIB_ASN1, ERR_R_ASN1_LIB);
|
||||
goto err;
|
||||
@@ -61,6 +71,11 @@ EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
case EVP_PKEY_EC:
|
||||
if (copy != NULL) {
|
||||
/* use downgraded parameters from copy */
|
||||
ret->pkey.ec = copy->pkey.ec;
|
||||
copy->pkey.ec = NULL;
|
||||
}
|
||||
if (!o2i_ECPublicKey(&ret->pkey.ec, pp, length)) {
|
||||
ERR_raise(ERR_LIB_ASN1, ERR_R_ASN1_LIB);
|
||||
goto err;
|
||||
@@ -73,9 +88,11 @@ EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,
|
||||
}
|
||||
if (a != NULL)
|
||||
(*a) = ret;
|
||||
EVP_PKEY_free(copy);
|
||||
return ret;
|
||||
err:
|
||||
if (a == NULL || *a != ret)
|
||||
EVP_PKEY_free(ret);
|
||||
EVP_PKEY_free(copy);
|
||||
return NULL;
|
||||
}
|
||||
+2
-2
@@ -648,9 +648,9 @@ static int asn1_template_noexp_d2i(ASN1_VALUE **val,
|
||||
break;
|
||||
}
|
||||
skfield = NULL;
|
||||
if (!asn1_item_embed_d2i(&skfield, &p, len,
|
||||
if (asn1_item_embed_d2i(&skfield, &p, len,
|
||||
ASN1_ITEM_ptr(tt->item), -1, 0, 0, ctx,
|
||||
depth, libctx, propq)) {
|
||||
depth, libctx, propq) <= 0) {
|
||||
ERR_raise(ERR_LIB_ASN1, ERR_R_NESTED_ASN1_ERROR);
|
||||
/* |skfield| may be partially allocated despite failure. */
|
||||
ASN1_item_free(skfield, ASN1_ITEM_ptr(tt->item));
|
||||
|
||||
+8
@@ -138,6 +138,10 @@ static void async_release_job(ASYNC_JOB *job) {
|
||||
async_pool *pool;
|
||||
|
||||
pool = (async_pool *)CRYPTO_THREAD_get_local(&poolkey);
|
||||
if (pool == NULL) {
|
||||
ERR_raise(ERR_LIB_ASYNC, ERR_R_INTERNAL_ERROR);
|
||||
return;
|
||||
}
|
||||
OPENSSL_free(job->funcargs);
|
||||
job->funcargs = NULL;
|
||||
sk_ASYNC_JOB_push(pool->jobs, job);
|
||||
@@ -148,6 +152,10 @@ void async_start_func(void)
|
||||
ASYNC_JOB *job;
|
||||
async_ctx *ctx = async_get_ctx();
|
||||
|
||||
if (ctx == NULL) {
|
||||
ERR_raise(ERR_LIB_ASYNC, ERR_R_INTERNAL_ERROR);
|
||||
return;
|
||||
}
|
||||
while (1) {
|
||||
/* Run the job */
|
||||
job = ctx->currjob;
|
||||
|
||||
+5
-13
@@ -140,7 +140,7 @@ int BIO_free(BIO *a)
|
||||
if (HAS_CALLBACK(a)) {
|
||||
ret = (int)bio_call_callback(a, BIO_CB_FREE, NULL, 0, 0, 0L, 1L, NULL);
|
||||
if (ret <= 0)
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((a->method != NULL) && (a->method->destroy != NULL))
|
||||
@@ -563,10 +563,8 @@ long BIO_ctrl(BIO *b, int cmd, long larg, void *parg)
|
||||
{
|
||||
long ret;
|
||||
|
||||
if (b == NULL) {
|
||||
ERR_raise(ERR_LIB_BIO, ERR_R_PASSED_NULL_PARAMETER);
|
||||
if (b == NULL)
|
||||
return -1;
|
||||
}
|
||||
if (b->method == NULL || b->method->ctrl == NULL) {
|
||||
ERR_raise(ERR_LIB_BIO, BIO_R_UNSUPPORTED_METHOD);
|
||||
return -2;
|
||||
@@ -591,10 +589,8 @@ long BIO_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp)
|
||||
{
|
||||
long ret;
|
||||
|
||||
if (b == NULL) {
|
||||
ERR_raise(ERR_LIB_BIO, ERR_R_PASSED_NULL_PARAMETER);
|
||||
if (b == NULL)
|
||||
return -2;
|
||||
}
|
||||
if (b->method == NULL || b->method->callback_ctrl == NULL
|
||||
|| cmd != BIO_CTRL_SET_CALLBACK) {
|
||||
ERR_raise(ERR_LIB_BIO, BIO_R_UNSUPPORTED_METHOD);
|
||||
@@ -655,10 +651,8 @@ BIO *BIO_pop(BIO *b)
|
||||
{
|
||||
BIO *ret;
|
||||
|
||||
if (b == NULL) {
|
||||
ERR_raise(ERR_LIB_BIO, ERR_R_PASSED_NULL_PARAMETER);
|
||||
if (b == NULL)
|
||||
return NULL;
|
||||
}
|
||||
ret = b->next_bio;
|
||||
|
||||
BIO_ctrl(b, BIO_CTRL_POP, 0, b);
|
||||
@@ -728,10 +722,8 @@ BIO *BIO_find_type(BIO *bio, int type)
|
||||
|
||||
BIO *BIO_next(BIO *b)
|
||||
{
|
||||
if (b == NULL) {
|
||||
ERR_raise(ERR_LIB_BIO, ERR_R_PASSED_NULL_PARAMETER);
|
||||
if (b == NULL)
|
||||
return NULL;
|
||||
}
|
||||
return b->next_bio;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -254,7 +254,7 @@ static long mem_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
bm = bbm->readp;
|
||||
bo = bbm->buf;
|
||||
}
|
||||
off = bm->data - bo->data;
|
||||
off = (bm->data == bo->data) ? 0 : bm->data - bo->data;
|
||||
remain = bm->length;
|
||||
|
||||
switch (cmd) {
|
||||
@@ -277,7 +277,7 @@ static long mem_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
if (num < 0 || num > off + remain)
|
||||
return -1; /* Can't see outside of the current buffer */
|
||||
|
||||
bm->data = bo->data + num;
|
||||
bm->data = (num != 0) ? bo->data + num : bo->data;
|
||||
bm->length = bo->length - num;
|
||||
bm->max = bo->max - num;
|
||||
off = num;
|
||||
|
||||
+5
-1
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2010-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2010-2021 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
|
||||
@@ -1986,6 +1986,8 @@ $code.=<<___;
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $c_3,$t_2,$at
|
||||
$ST $c_2,$BNSZ($a0)
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
mflo ($t_1,$a_2,$a_0)
|
||||
mfhi ($t_2,$a_2,$a_0)
|
||||
___
|
||||
@@ -2196,6 +2198,8 @@ $code.=<<___;
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $c_3,$t_2,$at
|
||||
$ST $c_2,$BNSZ($a0)
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
mflo ($t_1,$a_2,$a_0)
|
||||
mfhi ($t_2,$a_2,$a_0)
|
||||
___
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2021 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
|
||||
@@ -505,7 +505,8 @@ int bn2binpad(const BIGNUM *a, unsigned char *to, int tolen, endianess_t endiane
|
||||
/* Swipe through whole available data and don't give away padded zero. */
|
||||
atop = a->dmax * BN_BYTES;
|
||||
if (atop == 0) {
|
||||
OPENSSL_cleanse(to, tolen);
|
||||
if (tolen != 0)
|
||||
memset(to, '\0', tolen);
|
||||
return tolen;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -287,7 +287,7 @@ int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
|
||||
goto err;
|
||||
}
|
||||
for (done = 0; done < num_k_bytes;) {
|
||||
if (!RAND_priv_bytes_ex(libctx, random_bytes, sizeof(random_bytes), 0))
|
||||
if (RAND_priv_bytes_ex(libctx, random_bytes, sizeof(random_bytes), 0) <= 0)
|
||||
goto err;
|
||||
|
||||
if (!EVP_DigestInit_ex(mdctx, md, NULL)
|
||||
|
||||
+13
-3
@@ -106,6 +106,7 @@ static int bn_rsa_fips186_4_find_aux_prob_prime(const BIGNUM *Xp1,
|
||||
{
|
||||
int ret = 0;
|
||||
int i = 0;
|
||||
int tmp = 0;
|
||||
|
||||
if (BN_copy(p1, Xp1) == NULL)
|
||||
return 0;
|
||||
@@ -116,8 +117,11 @@ static int bn_rsa_fips186_4_find_aux_prob_prime(const BIGNUM *Xp1,
|
||||
i++;
|
||||
BN_GENCB_call(cb, 0, i);
|
||||
/* MR test with trial division */
|
||||
if (BN_check_prime(p1, ctx, cb))
|
||||
tmp = BN_check_prime(p1, ctx, cb);
|
||||
if (tmp > 0)
|
||||
break;
|
||||
if (tmp < 0)
|
||||
goto err;
|
||||
/* Get next odd number */
|
||||
if (!BN_add_word(p1, 2))
|
||||
goto err;
|
||||
@@ -329,8 +333,14 @@ int ossl_bn_rsa_fips186_4_derive_prime(BIGNUM *Y, BIGNUM *X, const BIGNUM *Xin,
|
||||
|| !BN_sub_word(y1, 1)
|
||||
|| !BN_gcd(tmp, y1, e, ctx))
|
||||
goto err;
|
||||
if (BN_is_one(tmp) && BN_check_prime(Y, ctx, cb))
|
||||
goto end;
|
||||
if (BN_is_one(tmp)) {
|
||||
int rv = BN_check_prime(Y, ctx, cb);
|
||||
|
||||
if (rv > 0)
|
||||
goto end;
|
||||
if (rv < 0)
|
||||
goto err;
|
||||
}
|
||||
/* (Step 8-10) */
|
||||
if (++i >= imax || !BN_add(Y, Y, r1r2x2))
|
||||
goto err;
|
||||
|
||||
+13
-3
@@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
#include <openssl/opensslconf.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include "rsaz_exp.h"
|
||||
|
||||
#ifndef RSAZ_ENABLED
|
||||
@@ -310,14 +311,23 @@ static void RSAZ_exp52x20_x2_256(BN_ULONG *out, /* [2][20] */
|
||||
|
||||
/* Exponentiation */
|
||||
{
|
||||
int rem = BITSIZE_MODULUS % EXP_WIN_SIZE;
|
||||
int delta = rem ? rem : EXP_WIN_SIZE;
|
||||
const int rem = BITSIZE_MODULUS % EXP_WIN_SIZE;
|
||||
BN_ULONG table_idx_mask = EXP_WIN_MASK;
|
||||
|
||||
int exp_bit_no = BITSIZE_MODULUS - delta;
|
||||
int exp_bit_no = BITSIZE_MODULUS - rem;
|
||||
int exp_chunk_no = exp_bit_no / 64;
|
||||
int exp_chunk_shift = exp_bit_no % 64;
|
||||
|
||||
/*
|
||||
* If rem == 0, then
|
||||
* exp_bit_no = modulus_bitsize - exp_win_size
|
||||
* However, this isn't possible because rem is { 1024, 1536, 2048 } % 5
|
||||
* which is { 4, 1, 3 } respectively.
|
||||
*
|
||||
* If this assertion ever fails the fix above is easy.
|
||||
*/
|
||||
OPENSSL_assert(rem != 0);
|
||||
|
||||
/* Process 1-st exp window - just init result */
|
||||
BN_ULONG red_table_idx_0 = expz[0][exp_chunk_no];
|
||||
BN_ULONG red_table_idx_1 = expz[1][exp_chunk_no];
|
||||
|
||||
+1
-1
@@ -227,7 +227,7 @@ int CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen)
|
||||
for (i = 0; i < bl; i++)
|
||||
out[i] = ctx->last_block[i] ^ ctx->k2[i];
|
||||
}
|
||||
if (!EVP_Cipher(ctx->cctx, out, out, bl)) {
|
||||
if (EVP_Cipher(ctx->cctx, out, out, bl) <= 0) {
|
||||
OPENSSL_cleanse(out, bl);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+2
-3
@@ -1100,9 +1100,8 @@ OSSL_CMP_MSG *OSSL_CMP_MSG_read(const char *file, OSSL_LIB_CTX *libctx,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((bio = BIO_new_file(file, "rb")) == NULL)
|
||||
return NULL;
|
||||
if (d2i_OSSL_CMP_MSG_bio(bio, &msg) == NULL) {
|
||||
if ((bio = BIO_new_file(file, "rb")) == NULL
|
||||
|| d2i_OSSL_CMP_MSG_bio(bio, &msg) == NULL) {
|
||||
OSSL_CMP_MSG_free(msg);
|
||||
msg = NULL;
|
||||
}
|
||||
|
||||
+3
-3
@@ -457,6 +457,9 @@ OSSL_CMP_MSG *OSSL_CMP_SRV_process_request(OSSL_CMP_SRV_CTX *srv_ctx,
|
||||
}
|
||||
ctx = srv_ctx->ctx;
|
||||
backup_secret = ctx->secretValue;
|
||||
req_type = OSSL_CMP_MSG_get_bodytype(req);
|
||||
ossl_cmp_log1(DEBUG, ctx,
|
||||
"received %s", ossl_cmp_bodytype_to_string(req_type));
|
||||
|
||||
/*
|
||||
* Some things need to be done already before validating the message in
|
||||
@@ -469,7 +472,6 @@ OSSL_CMP_MSG *OSSL_CMP_SRV_process_request(OSSL_CMP_SRV_CTX *srv_ctx,
|
||||
if (!OSSL_CMP_CTX_set1_recipient(ctx, hdr->sender->d.directoryName))
|
||||
goto err;
|
||||
|
||||
req_type = OSSL_CMP_MSG_get_bodytype(req);
|
||||
switch (req_type) {
|
||||
case OSSL_CMP_PKIBODY_IR:
|
||||
case OSSL_CMP_PKIBODY_CR:
|
||||
@@ -503,8 +505,6 @@ OSSL_CMP_MSG *OSSL_CMP_SRV_process_request(OSSL_CMP_SRV_CTX *srv_ctx,
|
||||
#endif
|
||||
}
|
||||
}
|
||||
ossl_cmp_log1(DEBUG, ctx,
|
||||
"received %s", ossl_cmp_bodytype_to_string(req_type));
|
||||
|
||||
res = ossl_cmp_msg_check_update(ctx, req, unprotected_exception,
|
||||
srv_ctx->acceptUnprotected);
|
||||
|
||||
+3
-1
@@ -27,12 +27,14 @@ static int verify_signature(const OSSL_CMP_CTX *cmp_ctx,
|
||||
{
|
||||
OSSL_CMP_PROTECTEDPART prot_part;
|
||||
EVP_PKEY *pubkey = NULL;
|
||||
BIO *bio = BIO_new(BIO_s_mem()); /* may be NULL */
|
||||
BIO *bio;
|
||||
int res = 0;
|
||||
|
||||
if (!ossl_assert(cmp_ctx != NULL && msg != NULL && cert != NULL))
|
||||
return 0;
|
||||
|
||||
bio = BIO_new(BIO_s_mem()); /* may be NULL */
|
||||
|
||||
/* verify that keyUsage, if present, contains digitalSignature */
|
||||
if (!cmp_ctx->ignore_keyusage
|
||||
&& (X509_get_key_usage(cert) & X509v3_KU_DIGITAL_SIGNATURE) == 0) {
|
||||
|
||||
+1
-1
@@ -118,7 +118,7 @@ static int dh_cms_set_shared_info(EVP_PKEY_CTX *pctx, CMS_RecipientInfo *ri)
|
||||
if (kekctx == NULL)
|
||||
goto err;
|
||||
|
||||
if (!OBJ_obj2txt(name, sizeof(name), kekalg->algorithm, 0))
|
||||
if (OBJ_obj2txt(name, sizeof(name), kekalg->algorithm, 0) <= 0)
|
||||
goto err;
|
||||
|
||||
kekcipher = EVP_CIPHER_fetch(pctx->libctx, name, pctx->propquery);
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ static EVP_PKEY *pkey_type2param(int ptype, const void *pval,
|
||||
pctx = EVP_PKEY_CTX_new_from_name(libctx, "EC", propq);
|
||||
if (pctx == NULL || EVP_PKEY_paramgen_init(pctx) <= 0)
|
||||
goto err;
|
||||
if (!OBJ_obj2txt(groupname, sizeof(groupname), poid, 0)
|
||||
if (OBJ_obj2txt(groupname, sizeof(groupname), poid, 0) <= 0
|
||||
|| !EVP_PKEY_CTX_set_group_name(pctx, groupname)) {
|
||||
ERR_raise(ERR_LIB_CMS, CMS_R_DECODE_ERROR);
|
||||
goto err;
|
||||
|
||||
+4
@@ -85,6 +85,10 @@ CMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms,
|
||||
goto merr;
|
||||
}
|
||||
ctx = EVP_CIPHER_CTX_new();
|
||||
if (ctx == NULL) {
|
||||
ERR_raise(ERR_LIB_CMS, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (EVP_EncryptInit_ex(ctx, kekciph, NULL, NULL, NULL) <= 0) {
|
||||
ERR_raise(ERR_LIB_CMS, ERR_R_EVP_LIB);
|
||||
|
||||
+2
-2
@@ -784,8 +784,8 @@ int CMS_SignerInfo_sign(CMS_SignerInfo *si)
|
||||
const CMS_CTX *ctx = si->cms_ctx;
|
||||
char md_name[OSSL_MAX_NAME_SIZE];
|
||||
|
||||
if (!OBJ_obj2txt(md_name, sizeof(md_name),
|
||||
si->digestAlgorithm->algorithm, 0))
|
||||
if (OBJ_obj2txt(md_name, sizeof(md_name),
|
||||
si->digestAlgorithm->algorithm, 0) <= 0)
|
||||
return 0;
|
||||
|
||||
if (CMS_signed_get_attr_by_NID(si, NID_pkcs9_signingTime, -1) < 0) {
|
||||
|
||||
+2
@@ -608,6 +608,8 @@ CMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si,
|
||||
|
||||
/* Set embedded content */
|
||||
pos = CMS_get0_content(cms);
|
||||
if (pos == NULL)
|
||||
goto err;
|
||||
*pos = os;
|
||||
|
||||
r = 1;
|
||||
|
||||
+10
-2
@@ -380,7 +380,11 @@ static int bio_zlib_read(BIO *b, char *out, int outl)
|
||||
ERR_raise(ERR_LIB_COMP, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
inflateInit(zin);
|
||||
if ((ret = inflateInit(zin)) != Z_OK) {
|
||||
ERR_raise_data(ERR_LIB_COMP, COMP_R_ZLIB_INFLATE_ERROR,
|
||||
"zlib error: %s", zError(ret));
|
||||
return 0;
|
||||
}
|
||||
zin->next_in = ctx->ibuf;
|
||||
zin->avail_in = 0;
|
||||
}
|
||||
@@ -443,7 +447,11 @@ static int bio_zlib_write(BIO *b, const char *in, int inl)
|
||||
}
|
||||
ctx->optr = ctx->obuf;
|
||||
ctx->ocount = 0;
|
||||
deflateInit(zout, ctx->comp_level);
|
||||
if ((ret = deflateInit(zout, ctx->comp_level)) != Z_OK) {
|
||||
ERR_raise_data(ERR_LIB_COMP, COMP_R_ZLIB_DEFLATE_ERROR,
|
||||
"zlib error: %s", zError(ret));
|
||||
return 0;
|
||||
}
|
||||
zout->next_out = ctx->obuf;
|
||||
zout->avail_out = ctx->obufsize;
|
||||
}
|
||||
|
||||
+5
-2
@@ -135,7 +135,11 @@ IMPLEMENT_LHASH_DOALL_ARG_CONST(CONF_VALUE, LH_CONF_VALUE);
|
||||
|
||||
void _CONF_free_data(CONF *conf)
|
||||
{
|
||||
if (conf == NULL || conf->data == NULL)
|
||||
if (conf == NULL)
|
||||
return;
|
||||
|
||||
OPENSSL_free(conf->includedir);
|
||||
if (conf->data == NULL)
|
||||
return;
|
||||
|
||||
/* evil thing to make sure the 'OPENSSL_free()' works as expected */
|
||||
@@ -147,7 +151,6 @@ void _CONF_free_data(CONF *conf)
|
||||
* with
|
||||
*/
|
||||
|
||||
OPENSSL_free(conf->includedir);
|
||||
lh_CONF_VALUE_doall(conf->data, value_free_stack_doall);
|
||||
lh_CONF_VALUE_free(conf->data);
|
||||
}
|
||||
|
||||
+2
@@ -424,6 +424,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
|
||||
if (!parsebool(pval, &conf->flag_abspath))
|
||||
goto err;
|
||||
} else if (strcmp(p, "includedir") == 0) {
|
||||
OPENSSL_free(conf->includedir);
|
||||
if ((conf->includedir = OPENSSL_strdup(pval)) == NULL) {
|
||||
ERR_raise(ERR_LIB_CONF, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
@@ -474,6 +475,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
|
||||
if (conf->flag_abspath
|
||||
&& !ossl_is_absolute_path(include_path)) {
|
||||
ERR_raise(ERR_LIB_CONF, CONF_R_RELATIVE_PATH);
|
||||
OPENSSL_free(include_path);
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -240,6 +240,10 @@ void OSSL_LIB_CTX_free(OSSL_LIB_CTX *ctx)
|
||||
if (ossl_lib_ctx_is_default(ctx))
|
||||
return;
|
||||
|
||||
#ifndef FIPS_MODULE
|
||||
if (ctx->ischild)
|
||||
ossl_provider_deinit_child(ctx);
|
||||
#endif
|
||||
context_deinit(ctx);
|
||||
OPENSSL_free(ctx);
|
||||
}
|
||||
|
||||
+15
-2
@@ -105,10 +105,23 @@ void ossl_algorithm_do_all(OSSL_LIB_CTX *libctx, int operation_id,
|
||||
cbdata.post = post;
|
||||
cbdata.data = data;
|
||||
|
||||
if (provider == NULL)
|
||||
if (provider == NULL) {
|
||||
ossl_provider_doall_activated(libctx, algorithm_do_this, &cbdata);
|
||||
else
|
||||
} else {
|
||||
OSSL_LIB_CTX *libctx2 = ossl_provider_libctx(provider);
|
||||
|
||||
/*
|
||||
* If a provider is given, its library context MUST match the library
|
||||
* context we're passed. If this turns out not to be true, there is
|
||||
* a programming error in the functions up the call stack.
|
||||
*/
|
||||
if (!ossl_assert(ossl_lib_ctx_get_concrete(libctx)
|
||||
== ossl_lib_ctx_get_concrete(libctx2)))
|
||||
return;
|
||||
|
||||
cbdata.libctx = libctx2;
|
||||
algorithm_do_this(provider, &cbdata);
|
||||
}
|
||||
}
|
||||
|
||||
char *ossl_algorithm_get1_first_name(const OSSL_ALGORITHM *algo)
|
||||
|
||||
+8
-5
@@ -105,19 +105,21 @@ static void ossl_method_construct_this(OSSL_PROVIDER *provider,
|
||||
}
|
||||
|
||||
void *ossl_method_construct(OSSL_LIB_CTX *libctx, int operation_id,
|
||||
int force_store,
|
||||
OSSL_PROVIDER **provider_rw, int force_store,
|
||||
OSSL_METHOD_CONSTRUCT_METHOD *mcm, void *mcm_data)
|
||||
{
|
||||
void *method = NULL;
|
||||
|
||||
if ((method = mcm->get(NULL, mcm_data)) == NULL) {
|
||||
if ((method = mcm->get(NULL, (const OSSL_PROVIDER **)provider_rw,
|
||||
mcm_data)) == NULL) {
|
||||
OSSL_PROVIDER *provider = provider_rw != NULL ? *provider_rw : NULL;
|
||||
struct construct_data_st cbdata;
|
||||
|
||||
cbdata.store = NULL;
|
||||
cbdata.force_store = force_store;
|
||||
cbdata.mcm = mcm;
|
||||
cbdata.mcm_data = mcm_data;
|
||||
ossl_algorithm_do_all(libctx, operation_id, NULL,
|
||||
ossl_algorithm_do_all(libctx, operation_id, provider,
|
||||
ossl_method_construct_precondition,
|
||||
ossl_method_construct_this,
|
||||
ossl_method_construct_postcondition,
|
||||
@@ -125,11 +127,12 @@ void *ossl_method_construct(OSSL_LIB_CTX *libctx, int operation_id,
|
||||
|
||||
/* If there is a temporary store, try there first */
|
||||
if (cbdata.store != NULL)
|
||||
method = mcm->get(cbdata.store, mcm_data);
|
||||
method = mcm->get(cbdata.store, (const OSSL_PROVIDER **)provider_rw,
|
||||
mcm_data);
|
||||
|
||||
/* If no method was found yet, try the global store */
|
||||
if (method == NULL)
|
||||
method = mcm->get(NULL, mcm_data);
|
||||
method = mcm->get(NULL, (const OSSL_PROVIDER **)provider_rw, mcm_data);
|
||||
}
|
||||
|
||||
return method;
|
||||
|
||||
+1
-1
@@ -397,7 +397,7 @@ static void get_legacy_evp_names(int base_nid, int nid, const char *pem_name,
|
||||
if ((obj = OBJ_nid2obj(nid)) != NULL) {
|
||||
char txtoid[OSSL_MAX_NAME_SIZE];
|
||||
|
||||
if (OBJ_obj2txt(txtoid, sizeof(txtoid), obj, 1))
|
||||
if (OBJ_obj2txt(txtoid, sizeof(txtoid), obj, 1) > 0)
|
||||
num = ossl_namemap_add_name(arg, num, txtoid);
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -29,6 +29,8 @@ static const ERR_STRING_DATA CRYPTO_str_reasons[] = {
|
||||
"insufficient param size"},
|
||||
{ERR_PACK(ERR_LIB_CRYPTO, 0, CRYPTO_R_INSUFFICIENT_SECURE_DATA_SPACE),
|
||||
"insufficient secure data space"},
|
||||
{ERR_PACK(ERR_LIB_CRYPTO, 0, CRYPTO_R_INVALID_NEGATIVE_VALUE),
|
||||
"invalid negative value"},
|
||||
{ERR_PACK(ERR_LIB_CRYPTO, 0, CRYPTO_R_INVALID_NULL_ARGUMENT),
|
||||
"invalid null argument"},
|
||||
{ERR_PACK(ERR_LIB_CRYPTO, 0, CRYPTO_R_INVALID_OSSL_PARAM_TYPE),
|
||||
|
||||
+2
-2
@@ -200,8 +200,8 @@ int OSSL_CRMF_pbm_new(OSSL_LIB_CTX *libctx, const char *propq,
|
||||
mac_nid = OBJ_obj2nid(pbmp->mac->algorithm);
|
||||
|
||||
if (!EVP_PBE_find(EVP_PBE_TYPE_PRF, mac_nid, NULL, &hmac_md_nid, NULL)
|
||||
|| !OBJ_obj2txt(hmac_mdname, sizeof(hmac_mdname),
|
||||
OBJ_nid2obj(hmac_md_nid), 0)) {
|
||||
|| OBJ_obj2txt(hmac_mdname, sizeof(hmac_mdname),
|
||||
OBJ_nid2obj(hmac_md_nid), 0) <= 0) {
|
||||
ERR_raise(ERR_LIB_CRMF, CRMF_R_UNSUPPORTED_ALGORITHM);
|
||||
goto err;
|
||||
}
|
||||
|
||||
+35
-12
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2021 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
|
||||
@@ -23,6 +23,8 @@
|
||||
#include "internal/deprecated.h"
|
||||
|
||||
#include <openssl/crypto.h>
|
||||
#include "internal/constant_time.h"
|
||||
#include "internal/nelem.h"
|
||||
#include "des_local.h"
|
||||
|
||||
static const unsigned char odd_parity[256] = {
|
||||
@@ -62,15 +64,23 @@ void DES_set_odd_parity(DES_cblock *key)
|
||||
(*key)[i] = odd_parity[(*key)[i]];
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that a key has the correct parity.
|
||||
* Return 1 if parity is okay and 0 if not.
|
||||
*/
|
||||
int DES_check_key_parity(const_DES_cblock *key)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned char res = 0377, b;
|
||||
|
||||
for (i = 0; i < DES_KEY_SZ; i++) {
|
||||
if ((*key)[i] != odd_parity[(*key)[i]])
|
||||
return 0;
|
||||
b = (*key)[i];
|
||||
b ^= b >> 4;
|
||||
b ^= b >> 2;
|
||||
b ^= b >> 1;
|
||||
res &= constant_time_eq_8(b & 1, 1);
|
||||
}
|
||||
return 1;
|
||||
return (int)(res & 1);
|
||||
}
|
||||
|
||||
/*-
|
||||
@@ -81,8 +91,7 @@ int DES_check_key_parity(const_DES_cblock *key)
|
||||
* %I John Wiley & Sons
|
||||
* %D 1984
|
||||
*/
|
||||
#define NUM_WEAK_KEY 16
|
||||
static const DES_cblock weak_keys[NUM_WEAK_KEY] = {
|
||||
static const DES_cblock weak_keys[] = {
|
||||
/* weak keys */
|
||||
{0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
|
||||
{0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE},
|
||||
@@ -103,14 +112,20 @@ static const DES_cblock weak_keys[NUM_WEAK_KEY] = {
|
||||
{0xFE, 0xE0, 0xFE, 0xE0, 0xFE, 0xF1, 0xFE, 0xF1}
|
||||
};
|
||||
|
||||
/*
|
||||
* Check for weak keys.
|
||||
* Return 1 if the key is weak and 0 otherwise.
|
||||
*/
|
||||
int DES_is_weak_key(const_DES_cblock *key)
|
||||
{
|
||||
int i;
|
||||
unsigned int i, res = 0;
|
||||
int j;
|
||||
|
||||
for (i = 0; i < NUM_WEAK_KEY; i++)
|
||||
if (memcmp(weak_keys[i], key, sizeof(DES_cblock)) == 0)
|
||||
return 1;
|
||||
return 0;
|
||||
for (i = 0; i < OSSL_NELEM(weak_keys); i++) {
|
||||
j = CRYPTO_memcmp(weak_keys[i], key, sizeof(DES_cblock));
|
||||
res |= constant_time_is_zero((unsigned int)j);
|
||||
}
|
||||
return (int)(res & 1);
|
||||
}
|
||||
|
||||
/*-
|
||||
@@ -279,9 +294,17 @@ static const DES_LONG des_skb[8][64] = {
|
||||
}
|
||||
};
|
||||
|
||||
/* Return values as DES_set_key_checked() but always set the key */
|
||||
int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule)
|
||||
{
|
||||
return DES_set_key_checked(key, schedule);
|
||||
int ret = 0;
|
||||
|
||||
if (!DES_check_key_parity(key))
|
||||
ret = -1;
|
||||
if (DES_is_weak_key(key))
|
||||
ret = -2;
|
||||
DES_set_key_unchecked(key, schedule);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*-
|
||||
|
||||
+1
-1
@@ -311,7 +311,7 @@ static int dh_security_bits(const EVP_PKEY *pkey)
|
||||
|
||||
static int dh_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b)
|
||||
{
|
||||
return ossl_ffc_params_cmp(&a->pkey.dh->params, &a->pkey.dh->params,
|
||||
return ossl_ffc_params_cmp(&a->pkey.dh->params, &b->pkey.dh->params,
|
||||
a->ameth != &ossl_dhx_asn1_meth);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ int DH_KDF_X9_42(unsigned char *out, size_t outlen,
|
||||
const OSSL_PROVIDER *prov = EVP_MD_get0_provider(md);
|
||||
OSSL_LIB_CTX *libctx = ossl_provider_libctx(prov);
|
||||
|
||||
if (!OBJ_obj2txt(key_alg, sizeof(key_alg), key_oid, 0))
|
||||
if (OBJ_obj2txt(key_alg, sizeof(key_alg), key_oid, 0) <= 0)
|
||||
return 0;
|
||||
|
||||
return ossl_dh_kdf_X9_42_asn1(out, outlen, Z, Zlen, key_alg,
|
||||
|
||||
+2
-1
@@ -65,7 +65,8 @@ DSA_SIG *d2i_DSA_SIG(DSA_SIG **psig, const unsigned char **ppin, long len)
|
||||
sig->r = BN_new();
|
||||
if (sig->s == NULL)
|
||||
sig->s = BN_new();
|
||||
if (ossl_decode_der_dsa_sig(sig->r, sig->s, ppin, (size_t)len) == 0) {
|
||||
if (sig->r == NULL || sig->s == NULL
|
||||
|| ossl_decode_der_dsa_sig(sig->r, sig->s, ppin, (size_t)len) == 0) {
|
||||
if (psig == NULL || *psig == NULL)
|
||||
DSA_SIG_free(sig);
|
||||
return NULL;
|
||||
|
||||
+6
-18
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2000-2021 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
|
||||
@@ -10,20 +10,10 @@
|
||||
#include "dso_local.h"
|
||||
#include "internal/refcount.h"
|
||||
|
||||
static DSO_METHOD *default_DSO_meth = NULL;
|
||||
|
||||
static DSO *DSO_new_method(DSO_METHOD *meth)
|
||||
{
|
||||
DSO *ret;
|
||||
|
||||
if (default_DSO_meth == NULL) {
|
||||
/*
|
||||
* We default to DSO_METH_openssl() which in turn defaults to
|
||||
* stealing the "best available" method. Will fallback to
|
||||
* DSO_METH_null() in the worst case.
|
||||
*/
|
||||
default_DSO_meth = DSO_METHOD_openssl();
|
||||
}
|
||||
ret = OPENSSL_zalloc(sizeof(*ret));
|
||||
if (ret == NULL) {
|
||||
ERR_raise(ERR_LIB_DSO, ERR_R_MALLOC_FAILURE);
|
||||
@@ -36,7 +26,7 @@ static DSO *DSO_new_method(DSO_METHOD *meth)
|
||||
OPENSSL_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
ret->meth = default_DSO_meth;
|
||||
ret->meth = DSO_METHOD_openssl();
|
||||
ret->references = 1;
|
||||
ret->lock = CRYPTO_THREAD_lock_new();
|
||||
if (ret->lock == NULL) {
|
||||
@@ -309,9 +299,8 @@ char *DSO_convert_filename(DSO *dso, const char *filename)
|
||||
|
||||
int DSO_pathbyaddr(void *addr, char *path, int sz)
|
||||
{
|
||||
DSO_METHOD *meth = default_DSO_meth;
|
||||
if (meth == NULL)
|
||||
meth = DSO_METHOD_openssl();
|
||||
DSO_METHOD *meth = DSO_METHOD_openssl();
|
||||
|
||||
if (meth->pathbyaddr == NULL) {
|
||||
ERR_raise(ERR_LIB_DSO, DSO_R_UNSUPPORTED);
|
||||
return -1;
|
||||
@@ -339,9 +328,8 @@ DSO *DSO_dsobyaddr(void *addr, int flags)
|
||||
|
||||
void *DSO_global_lookup(const char *name)
|
||||
{
|
||||
DSO_METHOD *meth = default_DSO_meth;
|
||||
if (meth == NULL)
|
||||
meth = DSO_METHOD_openssl();
|
||||
DSO_METHOD *meth = DSO_METHOD_openssl();
|
||||
|
||||
if (meth->globallookup == NULL) {
|
||||
ERR_raise(ERR_LIB_DSO, DSO_R_UNSUPPORTED);
|
||||
return NULL;
|
||||
|
||||
+2
-1
@@ -1223,7 +1223,8 @@ ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **psig, const unsigned char **ppin, long len)
|
||||
sig->r = BN_new();
|
||||
if (sig->s == NULL)
|
||||
sig->s = BN_new();
|
||||
if (ossl_decode_der_dsa_sig(sig->r, sig->s, ppin, (size_t)len) == 0) {
|
||||
if (sig->r == NULL || sig->s == NULL
|
||||
|| ossl_decode_der_dsa_sig(sig->r, sig->s, ppin, (size_t)len) == 0) {
|
||||
if (psig == NULL || *psig == NULL)
|
||||
ECDSA_SIG_free(sig);
|
||||
return NULL;
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2002-2021 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
|
||||
@@ -52,7 +52,7 @@ EC_POINT *EC_POINT_bn2point(const EC_GROUP *group,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!BN_bn2binpad(bn, buf, buf_len)) {
|
||||
if (BN_bn2binpad(bn, buf, buf_len) < 0) {
|
||||
OPENSSL_free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+18
-7
@@ -70,11 +70,23 @@ int ossl_ecx_key_fromdata(ECX_KEY *ecx, const OSSL_PARAM params[],
|
||||
if (param_pub_key == NULL && param_priv_key == NULL)
|
||||
return 0;
|
||||
|
||||
if (param_priv_key != NULL
|
||||
&& !OSSL_PARAM_get_octet_string(param_priv_key,
|
||||
(void **)&ecx->privkey, ecx->keylen,
|
||||
&privkeylen))
|
||||
return 0;
|
||||
if (param_priv_key != NULL) {
|
||||
if (!OSSL_PARAM_get_octet_string(param_priv_key,
|
||||
(void **)&ecx->privkey, ecx->keylen,
|
||||
&privkeylen))
|
||||
return 0;
|
||||
if (privkeylen != ecx->keylen) {
|
||||
/*
|
||||
* Invalid key length. We will clear what we've received now. We
|
||||
* can't leave it to ossl_ecx_key_free() because that will call
|
||||
* OPENSSL_secure_clear_free() and assume the correct key length
|
||||
*/
|
||||
OPENSSL_secure_clear_free(ecx->privkey, privkeylen);
|
||||
ecx->privkey = NULL;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pubkey = ecx->pubkey;
|
||||
if (param_pub_key != NULL
|
||||
@@ -83,8 +95,7 @@ int ossl_ecx_key_fromdata(ECX_KEY *ecx, const OSSL_PARAM params[],
|
||||
sizeof(ecx->pubkey), &pubkeylen))
|
||||
return 0;
|
||||
|
||||
if ((param_pub_key != NULL && pubkeylen != ecx->keylen)
|
||||
|| (param_priv_key != NULL && privkeylen != ecx->keylen))
|
||||
if ((param_pub_key != NULL && pubkeylen != ecx->keylen))
|
||||
return 0;
|
||||
|
||||
if (param_pub_key == NULL && !ossl_ecx_public_from_private(ecx))
|
||||
|
||||
@@ -125,7 +125,8 @@ static OSSL_METHOD_STORE *get_decoder_store(OSSL_LIB_CTX *libctx)
|
||||
}
|
||||
|
||||
/* Get decoder methods from a store, or put one in */
|
||||
static void *get_decoder_from_store(void *store, void *data)
|
||||
static void *get_decoder_from_store(void *store, const OSSL_PROVIDER **prov,
|
||||
void *data)
|
||||
{
|
||||
struct decoder_data_st *methdata = data;
|
||||
void *method = NULL;
|
||||
@@ -154,7 +155,7 @@ static void *get_decoder_from_store(void *store, void *data)
|
||||
&& (store = get_decoder_store(methdata->libctx)) == NULL)
|
||||
return NULL;
|
||||
|
||||
if (!ossl_method_store_fetch(store, id, methdata->propquery, &method))
|
||||
if (!ossl_method_store_fetch(store, id, methdata->propquery, prov, &method))
|
||||
return NULL;
|
||||
return method;
|
||||
}
|
||||
@@ -366,7 +367,7 @@ inner_ossl_decoder_fetch(struct decoder_data_st *methdata, int id,
|
||||
unsupported = 1;
|
||||
|
||||
if (id == 0
|
||||
|| !ossl_method_store_cache_get(store, id, properties, &method)) {
|
||||
|| !ossl_method_store_cache_get(store, NULL, id, properties, &method)) {
|
||||
OSSL_METHOD_CONSTRUCT_METHOD mcm = {
|
||||
get_tmp_decoder_store,
|
||||
get_decoder_from_store,
|
||||
@@ -380,7 +381,7 @@ inner_ossl_decoder_fetch(struct decoder_data_st *methdata, int id,
|
||||
methdata->propquery = properties;
|
||||
methdata->flag_construct_error_occurred = 0;
|
||||
if ((method = ossl_method_construct(methdata->libctx, OSSL_OP_DECODER,
|
||||
0 /* !force_cache */,
|
||||
NULL, 0 /* !force_cache */,
|
||||
&mcm, methdata)) != NULL) {
|
||||
/*
|
||||
* If construction did create a method for us, we know that
|
||||
@@ -391,7 +392,7 @@ inner_ossl_decoder_fetch(struct decoder_data_st *methdata, int id,
|
||||
if (id == 0 && name != NULL)
|
||||
id = ossl_namemap_name2num(namemap, name);
|
||||
if (id != 0)
|
||||
ossl_method_store_cache_set(store, id, properties, method,
|
||||
ossl_method_store_cache_set(store, NULL, id, properties, method,
|
||||
up_ref_decoder, free_decoder);
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -92,7 +92,7 @@ int OSSL_ENCODER_to_fp(OSSL_ENCODER_CTX *ctx, FILE *fp)
|
||||
int OSSL_ENCODER_to_data(OSSL_ENCODER_CTX *ctx, unsigned char **pdata,
|
||||
size_t *pdata_len)
|
||||
{
|
||||
BIO *out = BIO_new(BIO_s_mem());
|
||||
BIO *out;
|
||||
BUF_MEM *buf = NULL;
|
||||
int ret = 0;
|
||||
|
||||
@@ -101,7 +101,10 @@ int OSSL_ENCODER_to_data(OSSL_ENCODER_CTX *ctx, unsigned char **pdata,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (OSSL_ENCODER_to_bio(ctx, out)
|
||||
out = BIO_new(BIO_s_mem());
|
||||
|
||||
if (out != NULL
|
||||
&& OSSL_ENCODER_to_bio(ctx, out)
|
||||
&& BIO_get_mem_ptr(out, &buf) > 0) {
|
||||
ret = 1; /* Hope for the best. A too small buffer will clear this */
|
||||
|
||||
|
||||
@@ -125,7 +125,8 @@ static OSSL_METHOD_STORE *get_encoder_store(OSSL_LIB_CTX *libctx)
|
||||
}
|
||||
|
||||
/* Get encoder methods from a store, or put one in */
|
||||
static void *get_encoder_from_store(void *store, void *data)
|
||||
static void *get_encoder_from_store(void *store, const OSSL_PROVIDER **prov,
|
||||
void *data)
|
||||
{
|
||||
struct encoder_data_st *methdata = data;
|
||||
void *method = NULL;
|
||||
@@ -154,7 +155,7 @@ static void *get_encoder_from_store(void *store, void *data)
|
||||
&& (store = get_encoder_store(methdata->libctx)) == NULL)
|
||||
return NULL;
|
||||
|
||||
if (!ossl_method_store_fetch(store, id, methdata->propquery, &method))
|
||||
if (!ossl_method_store_fetch(store, id, methdata->propquery, prov, &method))
|
||||
return NULL;
|
||||
return method;
|
||||
}
|
||||
@@ -376,7 +377,7 @@ inner_ossl_encoder_fetch(struct encoder_data_st *methdata, int id,
|
||||
unsupported = 1;
|
||||
|
||||
if (id == 0
|
||||
|| !ossl_method_store_cache_get(store, id, properties, &method)) {
|
||||
|| !ossl_method_store_cache_get(store, NULL, id, properties, &method)) {
|
||||
OSSL_METHOD_CONSTRUCT_METHOD mcm = {
|
||||
get_tmp_encoder_store,
|
||||
get_encoder_from_store,
|
||||
@@ -390,7 +391,7 @@ inner_ossl_encoder_fetch(struct encoder_data_st *methdata, int id,
|
||||
methdata->propquery = properties;
|
||||
methdata->flag_construct_error_occurred = 0;
|
||||
if ((method = ossl_method_construct(methdata->libctx, OSSL_OP_ENCODER,
|
||||
0 /* !force_cache */,
|
||||
NULL, 0 /* !force_cache */,
|
||||
&mcm, methdata)) != NULL) {
|
||||
/*
|
||||
* If construction did create a method for us, we know that
|
||||
@@ -400,7 +401,7 @@ inner_ossl_encoder_fetch(struct encoder_data_st *methdata, int id,
|
||||
*/
|
||||
if (id == 0)
|
||||
id = ossl_namemap_name2num(namemap, name);
|
||||
ossl_method_store_cache_set(store, id, properties, method,
|
||||
ossl_method_store_cache_set(store, NULL, id, properties, method,
|
||||
up_ref_encoder, free_encoder);
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -484,7 +484,9 @@ static int dynamic_load(ENGINE *e, dynamic_data_ctx *ctx)
|
||||
engine_set_all_null(e);
|
||||
|
||||
/* Try to bind the ENGINE onto our own ENGINE structure */
|
||||
if (!ctx->bind_engine(e, ctx->engine_id, &fns)) {
|
||||
if (!engine_add_dynamic_id(e, (ENGINE_DYNAMIC_ID)ctx->bind_engine, 1)
|
||||
|| !ctx->bind_engine(e, ctx->engine_id, &fns)) {
|
||||
engine_remove_dynamic_id(e, 1);
|
||||
ctx->bind_engine = NULL;
|
||||
ctx->v_check = NULL;
|
||||
DSO_free(ctx->dynamic_dso);
|
||||
|
||||
@@ -65,6 +65,7 @@ void engine_set_all_null(ENGINE *e)
|
||||
e->load_pubkey = NULL;
|
||||
e->cmd_defns = NULL;
|
||||
e->flags = 0;
|
||||
e->dynamic_id = NULL;
|
||||
}
|
||||
|
||||
int engine_free_util(ENGINE *e, int not_locked)
|
||||
@@ -90,6 +91,7 @@ int engine_free_util(ENGINE *e, int not_locked)
|
||||
*/
|
||||
if (e->destroy)
|
||||
e->destroy(e);
|
||||
engine_remove_dynamic_id(e, not_locked);
|
||||
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ENGINE, e, &e->ex_data);
|
||||
OPENSSL_free(e);
|
||||
return 1;
|
||||
|
||||
+87
@@ -27,6 +27,12 @@
|
||||
static ENGINE *engine_list_head = NULL;
|
||||
static ENGINE *engine_list_tail = NULL;
|
||||
|
||||
/*
|
||||
* The linked list of currently loaded dynamic engines.
|
||||
*/
|
||||
static ENGINE *engine_dyn_list_head = NULL;
|
||||
static ENGINE *engine_dyn_list_tail = NULL;
|
||||
|
||||
/*
|
||||
* This cleanup function is only needed internally. If it should be called,
|
||||
* we register it with the "engine_cleanup_int()" stack to be called during
|
||||
@@ -128,6 +134,85 @@ static int engine_list_remove(ENGINE *e)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Add engine to dynamic engine list. */
|
||||
int engine_add_dynamic_id(ENGINE *e, ENGINE_DYNAMIC_ID dynamic_id,
|
||||
int not_locked)
|
||||
{
|
||||
int result = 0;
|
||||
ENGINE *iterator = NULL;
|
||||
|
||||
if (e == NULL)
|
||||
return 0;
|
||||
|
||||
if (e->dynamic_id == NULL && dynamic_id == NULL)
|
||||
return 0;
|
||||
|
||||
if (not_locked && !CRYPTO_THREAD_write_lock(global_engine_lock))
|
||||
return 0;
|
||||
|
||||
if (dynamic_id != NULL) {
|
||||
iterator = engine_dyn_list_head;
|
||||
while (iterator != NULL) {
|
||||
if (iterator->dynamic_id == dynamic_id)
|
||||
goto err;
|
||||
iterator = iterator->next;
|
||||
}
|
||||
if (e->dynamic_id != NULL)
|
||||
goto err;
|
||||
e->dynamic_id = dynamic_id;
|
||||
}
|
||||
|
||||
if (engine_dyn_list_head == NULL) {
|
||||
/* We are adding to an empty list. */
|
||||
if (engine_dyn_list_tail != NULL)
|
||||
goto err;
|
||||
engine_dyn_list_head = e;
|
||||
e->prev_dyn = NULL;
|
||||
} else {
|
||||
/* We are adding to the tail of an existing list. */
|
||||
if (engine_dyn_list_tail == NULL
|
||||
|| engine_dyn_list_tail->next_dyn != NULL)
|
||||
goto err;
|
||||
engine_dyn_list_tail->next_dyn = e;
|
||||
e->prev_dyn = engine_dyn_list_tail;
|
||||
}
|
||||
|
||||
engine_dyn_list_tail = e;
|
||||
e->next_dyn = NULL;
|
||||
result = 1;
|
||||
|
||||
err:
|
||||
if (not_locked)
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Remove engine from dynamic engine list. */
|
||||
void engine_remove_dynamic_id(ENGINE *e, int not_locked)
|
||||
{
|
||||
if (e == NULL || e->dynamic_id == NULL)
|
||||
return;
|
||||
|
||||
if (not_locked && !CRYPTO_THREAD_write_lock(global_engine_lock))
|
||||
return;
|
||||
|
||||
e->dynamic_id = NULL;
|
||||
|
||||
/* un-link e from the chain. */
|
||||
if (e->next_dyn != NULL)
|
||||
e->next_dyn->prev_dyn = e->prev_dyn;
|
||||
if (e->prev_dyn != NULL)
|
||||
e->prev_dyn->next_dyn = e->next_dyn;
|
||||
/* Correct our head/tail if necessary. */
|
||||
if (engine_dyn_list_head == e)
|
||||
engine_dyn_list_head = e->next_dyn;
|
||||
if (engine_dyn_list_tail == e)
|
||||
engine_dyn_list_tail = e->prev_dyn;
|
||||
|
||||
if (not_locked)
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
}
|
||||
|
||||
/* Get the first/last "ENGINE" type available. */
|
||||
ENGINE *ENGINE_get_first(void)
|
||||
{
|
||||
@@ -278,6 +363,8 @@ static void engine_cpy(ENGINE *dest, const ENGINE *src)
|
||||
dest->load_pubkey = src->load_pubkey;
|
||||
dest->cmd_defns = src->cmd_defns;
|
||||
dest->flags = src->flags;
|
||||
dest->dynamic_id = src->dynamic_id;
|
||||
engine_add_dynamic_id(dest, NULL, 0);
|
||||
}
|
||||
|
||||
ENGINE *ENGINE_by_id(const char *id)
|
||||
|
||||
@@ -99,6 +99,11 @@ void engine_pkey_asn1_meths_free(ENGINE *e);
|
||||
extern CRYPTO_ONCE engine_lock_init;
|
||||
DECLARE_RUN_ONCE(do_engine_lock_init)
|
||||
|
||||
typedef void (*ENGINE_DYNAMIC_ID)(void);
|
||||
int engine_add_dynamic_id(ENGINE *e, ENGINE_DYNAMIC_ID dynamic_id,
|
||||
int not_locked);
|
||||
void engine_remove_dynamic_id(ENGINE *e, int not_locked);
|
||||
|
||||
/*
|
||||
* This is a structure for storing implementations of various crypto
|
||||
* algorithms and functions.
|
||||
@@ -143,6 +148,10 @@ struct engine_st {
|
||||
/* Used to maintain the linked-list of engines. */
|
||||
struct engine_st *prev;
|
||||
struct engine_st *next;
|
||||
/* Used to maintain the linked-list of dynamic engines. */
|
||||
struct engine_st *prev_dyn;
|
||||
struct engine_st *next_dyn;
|
||||
ENGINE_DYNAMIC_ID dynamic_id;
|
||||
};
|
||||
|
||||
typedef struct st_engine_pile ENGINE_PILE;
|
||||
|
||||
+10
-6
@@ -80,6 +80,10 @@ static ERR_STRING_DATA ERR_str_libraries[] = {
|
||||
{0, NULL},
|
||||
};
|
||||
|
||||
/*
|
||||
* Should make sure that all ERR_R_ reasons defined in include/openssl/err.h.in
|
||||
* are listed. For maintainability, please keep all reasons in the same order.
|
||||
*/
|
||||
static ERR_STRING_DATA ERR_str_reasons[] = {
|
||||
{ERR_R_SYS_LIB, "system lib"},
|
||||
{ERR_R_BN_LIB, "BN lib"},
|
||||
@@ -92,17 +96,16 @@ static ERR_STRING_DATA ERR_str_reasons[] = {
|
||||
{ERR_R_DSA_LIB, "DSA lib"},
|
||||
{ERR_R_X509_LIB, "X509 lib"},
|
||||
{ERR_R_ASN1_LIB, "ASN1 lib"},
|
||||
{ERR_R_CRYPTO_LIB, "CRYPTO lib"},
|
||||
{ERR_R_EC_LIB, "EC lib"},
|
||||
{ERR_R_BIO_LIB, "BIO lib"},
|
||||
{ERR_R_PKCS7_LIB, "PKCS7 lib"},
|
||||
{ERR_R_X509V3_LIB, "X509V3 lib"},
|
||||
{ERR_R_ENGINE_LIB, "ENGINE lib"},
|
||||
{ERR_R_UI_LIB, "UI lib"},
|
||||
{ERR_R_OSSL_STORE_LIB, "STORE lib"},
|
||||
{ERR_R_ECDSA_LIB, "ECDSA lib"},
|
||||
|
||||
{ERR_R_NESTED_ASN1_ERROR, "nested asn1 error"},
|
||||
{ERR_R_MISSING_ASN1_EOS, "missing asn1 eos"},
|
||||
{ERR_R_OSSL_STORE_LIB, "OSSL_STORE lib"},
|
||||
{ERR_R_OSSL_DECODER_LIB, "OSSL_DECODER lib"},
|
||||
|
||||
{ERR_R_FATAL, "fatal"},
|
||||
{ERR_R_MALLOC_FAILURE, "malloc failure"},
|
||||
@@ -112,10 +115,12 @@ static ERR_STRING_DATA ERR_str_reasons[] = {
|
||||
{ERR_R_INTERNAL_ERROR, "internal error"},
|
||||
{ERR_R_DISABLED, "called a function that was disabled at compile-time"},
|
||||
{ERR_R_INIT_FAIL, "init fail"},
|
||||
{ERR_R_PASSED_INVALID_ARGUMENT, "passed invalid argument"},
|
||||
{ERR_R_OPERATION_FAIL, "operation fail"},
|
||||
{ERR_R_INVALID_PROVIDER_FUNCTIONS, "invalid provider functions"},
|
||||
{ERR_R_INTERRUPTED_OR_CANCELLED, "interrupted or cancelled"},
|
||||
|
||||
{ERR_R_NESTED_ASN1_ERROR, "nested asn1 error"},
|
||||
{ERR_R_MISSING_ASN1_EOS, "missing asn1 eos"},
|
||||
/*
|
||||
* Something is unsupported, exactly what is expressed with additional data
|
||||
*/
|
||||
@@ -125,7 +130,6 @@ static ERR_STRING_DATA ERR_str_reasons[] = {
|
||||
* unsupported.
|
||||
*/
|
||||
{ERR_R_FETCH_FAILED, "fetch failed"},
|
||||
|
||||
{ERR_R_INVALID_PROPERTY_DEFINITION, "invalid property definition"},
|
||||
{ERR_R_UNABLE_TO_GET_READ_LOCK, "unable to get read lock"},
|
||||
{ERR_R_UNABLE_TO_GET_WRITE_LOCK, "unable to get write lock"},
|
||||
|
||||
+2
@@ -434,6 +434,7 @@ CRYPTO_R_ILLEGAL_HEX_DIGIT:102:illegal hex digit
|
||||
CRYPTO_R_INSUFFICIENT_DATA_SPACE:106:insufficient data space
|
||||
CRYPTO_R_INSUFFICIENT_PARAM_SIZE:107:insufficient param size
|
||||
CRYPTO_R_INSUFFICIENT_SECURE_DATA_SPACE:108:insufficient secure data space
|
||||
CRYPTO_R_INVALID_NEGATIVE_VALUE:122:invalid negative value
|
||||
CRYPTO_R_INVALID_NULL_ARGUMENT:109:invalid null argument
|
||||
CRYPTO_R_INVALID_OSSL_PARAM_TYPE:110:invalid ossl param type
|
||||
CRYPTO_R_ODD_NUMBER_OF_DIGITS:103:odd number of digits
|
||||
@@ -778,6 +779,7 @@ HTTP_R_REDIRECTION_FROM_HTTPS_TO_HTTP:112:redirection from https to http
|
||||
HTTP_R_REDIRECTION_NOT_ENABLED:116:redirection not enabled
|
||||
HTTP_R_RESPONSE_LINE_TOO_LONG:113:response line too long
|
||||
HTTP_R_RESPONSE_PARSE_ERROR:104:response parse error
|
||||
HTTP_R_RETRY_TIMEOUT:129:retry timeout
|
||||
HTTP_R_SERVER_CANCELED_CONNECTION:127:server canceled connection
|
||||
HTTP_R_SOCK_NOT_SUPPORTED:122:sock not supported
|
||||
HTTP_R_STATUS_CODE_UNSUPPORTED:114:status code unsupported
|
||||
|
||||
+97
-34
@@ -24,7 +24,9 @@ static int evp_pkey_asym_cipher_init(EVP_PKEY_CTX *ctx, int operation,
|
||||
void *provkey = NULL;
|
||||
EVP_ASYM_CIPHER *cipher = NULL;
|
||||
EVP_KEYMGMT *tmp_keymgmt = NULL;
|
||||
const OSSL_PROVIDER *tmp_prov = NULL;
|
||||
const char *supported_ciph = NULL;
|
||||
int iter;
|
||||
|
||||
if (ctx == NULL) {
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
|
||||
@@ -39,56 +41,102 @@ static int evp_pkey_asym_cipher_init(EVP_PKEY_CTX *ctx, int operation,
|
||||
if (evp_pkey_ctx_is_legacy(ctx))
|
||||
goto legacy;
|
||||
|
||||
if (ctx->pkey == NULL) {
|
||||
ERR_clear_last_mark();
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_NO_KEY_SET);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ensure that the key is provided, either natively, or as a cached export.
|
||||
* If not, go legacy
|
||||
* Try to derive the supported asym cipher from |ctx->keymgmt|.
|
||||
*/
|
||||
tmp_keymgmt = ctx->keymgmt;
|
||||
provkey = evp_pkey_export_to_provider(ctx->pkey, ctx->libctx,
|
||||
&tmp_keymgmt, ctx->propquery);
|
||||
if (provkey == NULL)
|
||||
goto legacy;
|
||||
if (!EVP_KEYMGMT_up_ref(tmp_keymgmt)) {
|
||||
if (!ossl_assert(ctx->pkey->keymgmt == NULL
|
||||
|| ctx->pkey->keymgmt == ctx->keymgmt)) {
|
||||
ERR_clear_last_mark();
|
||||
ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
supported_ciph
|
||||
= evp_keymgmt_util_query_operation_name(ctx->keymgmt,
|
||||
OSSL_OP_ASYM_CIPHER);
|
||||
if (supported_ciph == NULL) {
|
||||
ERR_clear_last_mark();
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
||||
goto err;
|
||||
}
|
||||
EVP_KEYMGMT_free(ctx->keymgmt);
|
||||
ctx->keymgmt = tmp_keymgmt;
|
||||
|
||||
if (ctx->keymgmt->query_operation_name != NULL)
|
||||
supported_ciph =
|
||||
ctx->keymgmt->query_operation_name(OSSL_OP_ASYM_CIPHER);
|
||||
|
||||
/*
|
||||
* If we didn't get a supported ciph, assume there is one with the
|
||||
* same name as the key type.
|
||||
* We perform two iterations:
|
||||
*
|
||||
* 1. Do the normal asym cipher fetch, using the fetching data given by
|
||||
* the EVP_PKEY_CTX.
|
||||
* 2. Do the provider specific asym cipher fetch, from the same provider
|
||||
* as |ctx->keymgmt|
|
||||
*
|
||||
* We then try to fetch the keymgmt from the same provider as the
|
||||
* asym cipher, and try to export |ctx->pkey| to that keymgmt (when
|
||||
* this keymgmt happens to be the same as |ctx->keymgmt|, the export
|
||||
* is a no-op, but we call it anyway to not complicate the code even
|
||||
* more).
|
||||
* If the export call succeeds (returns a non-NULL provider key pointer),
|
||||
* we're done and can perform the operation itself. If not, we perform
|
||||
* the second iteration, or jump to legacy.
|
||||
*/
|
||||
if (supported_ciph == NULL)
|
||||
supported_ciph = ctx->keytype;
|
||||
for (iter = 1, provkey = NULL; iter < 3 && provkey == NULL; iter++) {
|
||||
EVP_KEYMGMT *tmp_keymgmt_tofree;
|
||||
|
||||
/*
|
||||
* Because we cleared out old ops, we shouldn't need to worry about
|
||||
* checking if cipher is already there.
|
||||
*/
|
||||
cipher =
|
||||
EVP_ASYM_CIPHER_fetch(ctx->libctx, supported_ciph, ctx->propquery);
|
||||
|
||||
if (cipher == NULL
|
||||
|| (EVP_KEYMGMT_get0_provider(ctx->keymgmt)
|
||||
!= EVP_ASYM_CIPHER_get0_provider(cipher))) {
|
||||
/*
|
||||
* We don't need to free ctx->keymgmt here, as it's not necessarily
|
||||
* tied to this operation. It will be freed by EVP_PKEY_CTX_free().
|
||||
* If we're on the second iteration, free the results from the first.
|
||||
* They are NULL on the first iteration, so no need to check what
|
||||
* iteration we're on.
|
||||
*/
|
||||
EVP_ASYM_CIPHER_free(cipher);
|
||||
EVP_KEYMGMT_free(tmp_keymgmt);
|
||||
|
||||
switch (iter) {
|
||||
case 1:
|
||||
cipher = EVP_ASYM_CIPHER_fetch(ctx->libctx, supported_ciph,
|
||||
ctx->propquery);
|
||||
if (cipher != NULL)
|
||||
tmp_prov = EVP_ASYM_CIPHER_get0_provider(cipher);
|
||||
break;
|
||||
case 2:
|
||||
tmp_prov = EVP_KEYMGMT_get0_provider(ctx->keymgmt);
|
||||
cipher =
|
||||
evp_asym_cipher_fetch_from_prov((OSSL_PROVIDER *)tmp_prov,
|
||||
supported_ciph, ctx->propquery);
|
||||
if (cipher == NULL)
|
||||
goto legacy;
|
||||
break;
|
||||
}
|
||||
if (cipher == NULL)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Ensure that the key is provided, either natively, or as a cached
|
||||
* export. We start by fetching the keymgmt with the same name as
|
||||
* |ctx->pkey|, but from the provider of the asym cipher method, using
|
||||
* the same property query as when fetching the asym cipher method.
|
||||
* With the keymgmt we found (if we did), we try to export |ctx->pkey|
|
||||
* to it (evp_pkey_export_to_provider() is smart enough to only actually
|
||||
* export it if |tmp_keymgmt| is different from |ctx->pkey|'s keymgmt)
|
||||
*/
|
||||
tmp_keymgmt_tofree = tmp_keymgmt
|
||||
= evp_keymgmt_fetch_from_prov((OSSL_PROVIDER *)tmp_prov,
|
||||
EVP_KEYMGMT_get0_name(ctx->keymgmt),
|
||||
ctx->propquery);
|
||||
if (tmp_keymgmt != NULL)
|
||||
provkey = evp_pkey_export_to_provider(ctx->pkey, ctx->libctx,
|
||||
&tmp_keymgmt, ctx->propquery);
|
||||
if (tmp_keymgmt == NULL)
|
||||
EVP_KEYMGMT_free(tmp_keymgmt_tofree);
|
||||
}
|
||||
|
||||
if (provkey == NULL) {
|
||||
EVP_ASYM_CIPHER_free(cipher);
|
||||
goto legacy;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we don't have the full support we need with provided methods,
|
||||
* let's go see if legacy does.
|
||||
*/
|
||||
ERR_pop_to_mark();
|
||||
|
||||
/* No more legacy from here down to legacy: */
|
||||
@@ -125,6 +173,7 @@ static int evp_pkey_asym_cipher_init(EVP_PKEY_CTX *ctx, int operation,
|
||||
|
||||
if (ret <= 0)
|
||||
goto err;
|
||||
EVP_KEYMGMT_free(tmp_keymgmt);
|
||||
return 1;
|
||||
|
||||
legacy:
|
||||
@@ -133,6 +182,8 @@ static int evp_pkey_asym_cipher_init(EVP_PKEY_CTX *ctx, int operation,
|
||||
* let's go see if legacy does.
|
||||
*/
|
||||
ERR_pop_to_mark();
|
||||
EVP_KEYMGMT_free(tmp_keymgmt);
|
||||
tmp_keymgmt = NULL;
|
||||
|
||||
if (ctx->pmeth == NULL || ctx->pmeth->encrypt == NULL) {
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
|
||||
@@ -159,6 +210,7 @@ static int evp_pkey_asym_cipher_init(EVP_PKEY_CTX *ctx, int operation,
|
||||
evp_pkey_ctx_free_old_ops(ctx);
|
||||
ctx->operation = EVP_PKEY_OP_UNDEFINED;
|
||||
}
|
||||
EVP_KEYMGMT_free(tmp_keymgmt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -423,6 +475,17 @@ EVP_ASYM_CIPHER *EVP_ASYM_CIPHER_fetch(OSSL_LIB_CTX *ctx, const char *algorithm,
|
||||
(void (*)(void *))EVP_ASYM_CIPHER_free);
|
||||
}
|
||||
|
||||
EVP_ASYM_CIPHER *evp_asym_cipher_fetch_from_prov(OSSL_PROVIDER *prov,
|
||||
const char *algorithm,
|
||||
const char *properties)
|
||||
{
|
||||
return evp_generic_fetch_from_prov(prov, OSSL_OP_ASYM_CIPHER,
|
||||
algorithm, properties,
|
||||
evp_asym_cipher_from_algorithm,
|
||||
(int (*)(void *))EVP_ASYM_CIPHER_up_ref,
|
||||
(void (*)(void *))EVP_ASYM_CIPHER_free);
|
||||
}
|
||||
|
||||
int EVP_ASYM_CIPHER_is_a(const EVP_ASYM_CIPHER *cipher, const char *name)
|
||||
{
|
||||
return evp_is_a(cipher->prov, cipher->name_id, NULL, name);
|
||||
|
||||
+26
-9
@@ -465,8 +465,8 @@ static int default_fixup_args(enum state state,
|
||||
ERR_raise(ERR_LIB_EVP, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
if (!BN_bn2nativepad(ctx->p2,
|
||||
ctx->allocated_buf, ctx->buflen)) {
|
||||
if (BN_bn2nativepad(ctx->p2,
|
||||
ctx->allocated_buf, ctx->buflen) < 0) {
|
||||
OPENSSL_free(ctx->allocated_buf);
|
||||
ctx->allocated_buf = NULL;
|
||||
return 0;
|
||||
@@ -1026,10 +1026,23 @@ static int fix_dh_nid5114(enum state state,
|
||||
if (ctx->action_type != SET)
|
||||
return 0;
|
||||
|
||||
if (state == PRE_CTRL_STR_TO_PARAMS) {
|
||||
switch (state) {
|
||||
case PRE_CTRL_TO_PARAMS:
|
||||
ctx->p2 = (char *)ossl_ffc_named_group_get_name
|
||||
(ossl_ffc_uid_to_dh_named_group(ctx->p1));
|
||||
ctx->p1 = 0;
|
||||
break;
|
||||
|
||||
case PRE_CTRL_STR_TO_PARAMS:
|
||||
if (ctx->p2 == NULL)
|
||||
return 0;
|
||||
ctx->p2 = (char *)ossl_ffc_named_group_get_name
|
||||
(ossl_ffc_uid_to_dh_named_group(atoi(ctx->p2)));
|
||||
ctx->p1 = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return default_fixup_args(state, translation, ctx);
|
||||
@@ -1379,21 +1392,23 @@ static int fix_rsa_pss_saltlen(enum state state,
|
||||
if ((ctx->action_type == SET && state == PRE_PARAMS_TO_CTRL)
|
||||
|| (ctx->action_type == GET && state == POST_CTRL_TO_PARAMS)) {
|
||||
size_t i;
|
||||
int val;
|
||||
|
||||
for (i = 0; i < OSSL_NELEM(str_value_map); i++) {
|
||||
if (strcmp(ctx->p2, str_value_map[i].ptr) == 0)
|
||||
break;
|
||||
}
|
||||
if (i == OSSL_NELEM(str_value_map)) {
|
||||
ctx->p1 = atoi(ctx->p2);
|
||||
} else if (state == POST_CTRL_TO_PARAMS) {
|
||||
|
||||
val = i == OSSL_NELEM(str_value_map) ? atoi(ctx->p2)
|
||||
: (int)str_value_map[i].id;
|
||||
if (state == POST_CTRL_TO_PARAMS) {
|
||||
/*
|
||||
* EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN weirdness explained further
|
||||
* up
|
||||
*/
|
||||
*(int *)ctx->orig_p2 = str_value_map[i].id;
|
||||
*(int *)ctx->orig_p2 = val;
|
||||
} else {
|
||||
ctx->p1 = (int)str_value_map[i].id;
|
||||
ctx->p1 = val;
|
||||
}
|
||||
ctx->p2 = NULL;
|
||||
}
|
||||
@@ -1595,10 +1610,13 @@ static int get_payload_public_key(enum state state,
|
||||
const EC_GROUP *ecg = EC_KEY_get0_group(eckey);
|
||||
const EC_POINT *point = EC_KEY_get0_public_key(eckey);
|
||||
|
||||
if (bnctx == NULL)
|
||||
return 0;
|
||||
ctx->sz = EC_POINT_point2buf(ecg, point,
|
||||
POINT_CONVERSION_COMPRESSED,
|
||||
&buf, bnctx);
|
||||
ctx->p2 = buf;
|
||||
BN_CTX_free(bnctx);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
@@ -2738,4 +2756,3 @@ int evp_pkey_get_params_to_ctrl(const EVP_PKEY *pkey, OSSL_PARAM *params)
|
||||
{
|
||||
return evp_pkey_setget_params_to_ctrl(pkey, GET, params);
|
||||
}
|
||||
|
||||
+15
-3
@@ -228,7 +228,10 @@ static int evp_md_init_internal(EVP_MD_CTX *ctx, const EVP_MD *type,
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
||||
return 0;
|
||||
#else
|
||||
EVP_MD *provmd = EVP_MD_fetch(NULL, OBJ_nid2sn(type->type), "");
|
||||
/* The NULL digest is a special case */
|
||||
EVP_MD *provmd = EVP_MD_fetch(NULL,
|
||||
type->type != NID_undef ? OBJ_nid2sn(type->type)
|
||||
: "NULL", "");
|
||||
|
||||
if (provmd == NULL) {
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
||||
@@ -506,11 +509,20 @@ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in)
|
||||
{
|
||||
unsigned char *tmp_buf;
|
||||
|
||||
if (in == NULL || in->digest == NULL) {
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_INPUT_NOT_INITIALIZED);
|
||||
if (in == NULL) {
|
||||
ERR_raise(ERR_LIB_EVP, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (in->digest == NULL) {
|
||||
/* copying uninitialized digest context */
|
||||
EVP_MD_CTX_reset(out);
|
||||
if (out->fetched_digest != NULL)
|
||||
EVP_MD_free(out->fetched_digest);
|
||||
*out = *in;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (in->digest->prov == NULL
|
||||
|| (in->flags & EVP_MD_CTX_FLAG_NO_INIT) != 0)
|
||||
goto legacy;
|
||||
|
||||
+4
-3
@@ -72,12 +72,13 @@ static int rc5_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
|
||||
static int r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
const unsigned char *iv, int enc)
|
||||
{
|
||||
if (EVP_CIPHER_CTX_get_key_length(ctx) > 255) {
|
||||
const int key_len = EVP_CIPHER_CTX_get_key_length(ctx);
|
||||
|
||||
if (key_len > 255 || key_len < 0) {
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_BAD_KEY_LENGTH);
|
||||
return 0;
|
||||
}
|
||||
return RC5_32_set_key(&data(ctx)->ks, EVP_CIPHER_CTX_get_key_length(ctx),
|
||||
key, data(ctx)->rounds);
|
||||
return RC5_32_set_key(&data(ctx)->ks, key_len, key, data(ctx)->rounds);
|
||||
}
|
||||
|
||||
#endif
|
||||
+42
-13
@@ -115,7 +115,8 @@ static uint32_t evp_method_id(int name_id, unsigned int operation_id)
|
||||
| (operation_id & METHOD_ID_OPERATION_MASK));
|
||||
}
|
||||
|
||||
static void *get_evp_method_from_store(void *store, void *data)
|
||||
static void *get_evp_method_from_store(void *store, const OSSL_PROVIDER **prov,
|
||||
void *data)
|
||||
{
|
||||
struct evp_method_data_st *methdata = data;
|
||||
void *method = NULL;
|
||||
@@ -146,7 +147,7 @@ static void *get_evp_method_from_store(void *store, void *data)
|
||||
&& (store = get_evp_method_store(methdata->libctx)) == NULL)
|
||||
return NULL;
|
||||
|
||||
if (!ossl_method_store_fetch(store, meth_id, methdata->propquery,
|
||||
if (!ossl_method_store_fetch(store, meth_id, methdata->propquery, prov,
|
||||
&method))
|
||||
return NULL;
|
||||
return method;
|
||||
@@ -234,7 +235,8 @@ static void destruct_evp_method(void *method, void *data)
|
||||
}
|
||||
|
||||
static void *
|
||||
inner_evp_generic_fetch(struct evp_method_data_st *methdata, int operation_id,
|
||||
inner_evp_generic_fetch(struct evp_method_data_st *methdata,
|
||||
OSSL_PROVIDER *prov, int operation_id,
|
||||
int name_id, const char *name,
|
||||
const char *properties,
|
||||
void *(*new_method)(int name_id,
|
||||
@@ -297,7 +299,8 @@ inner_evp_generic_fetch(struct evp_method_data_st *methdata, int operation_id,
|
||||
unsupported = 1;
|
||||
|
||||
if (meth_id == 0
|
||||
|| !ossl_method_store_cache_get(store, meth_id, properties, &method)) {
|
||||
|| !ossl_method_store_cache_get(store, prov, meth_id, properties,
|
||||
&method)) {
|
||||
OSSL_METHOD_CONSTRUCT_METHOD mcm = {
|
||||
get_tmp_evp_method_store,
|
||||
get_evp_method_from_store,
|
||||
@@ -315,7 +318,7 @@ inner_evp_generic_fetch(struct evp_method_data_st *methdata, int operation_id,
|
||||
methdata->destruct_method = free_method;
|
||||
methdata->flag_construct_error_occurred = 0;
|
||||
if ((method = ossl_method_construct(methdata->libctx, operation_id,
|
||||
0 /* !force_cache */,
|
||||
&prov, 0 /* !force_cache */,
|
||||
&mcm, methdata)) != NULL) {
|
||||
/*
|
||||
* If construction did create a method for us, we know that
|
||||
@@ -327,8 +330,8 @@ inner_evp_generic_fetch(struct evp_method_data_st *methdata, int operation_id,
|
||||
name_id = ossl_namemap_name2num(namemap, name);
|
||||
meth_id = evp_method_id(name_id, operation_id);
|
||||
if (name_id != 0)
|
||||
ossl_method_store_cache_set(store, meth_id, properties, method,
|
||||
up_ref_method, free_method);
|
||||
ossl_method_store_cache_set(store, prov, meth_id, properties,
|
||||
method, up_ref_method, free_method);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -366,8 +369,8 @@ void *evp_generic_fetch(OSSL_LIB_CTX *libctx, int operation_id,
|
||||
|
||||
methdata.libctx = libctx;
|
||||
methdata.tmp_store = NULL;
|
||||
method = inner_evp_generic_fetch(&methdata,
|
||||
operation_id, 0, name, properties,
|
||||
method = inner_evp_generic_fetch(&methdata, NULL, operation_id,
|
||||
0, name, properties,
|
||||
new_method, up_ref_method, free_method);
|
||||
dealloc_tmp_evp_method_store(methdata.tmp_store);
|
||||
return method;
|
||||
@@ -378,7 +381,7 @@ void *evp_generic_fetch(OSSL_LIB_CTX *libctx, int operation_id,
|
||||
* already known names, i.e. it refuses to work if no name_id can be found
|
||||
* (it's considered an internal programming error).
|
||||
* This is meant to be used when one method needs to fetch an associated
|
||||
* other method.
|
||||
* method.
|
||||
*/
|
||||
void *evp_generic_fetch_by_number(OSSL_LIB_CTX *libctx, int operation_id,
|
||||
int name_id, const char *properties,
|
||||
@@ -393,8 +396,34 @@ void *evp_generic_fetch_by_number(OSSL_LIB_CTX *libctx, int operation_id,
|
||||
|
||||
methdata.libctx = libctx;
|
||||
methdata.tmp_store = NULL;
|
||||
method = inner_evp_generic_fetch(&methdata,
|
||||
operation_id, name_id, NULL, properties,
|
||||
method = inner_evp_generic_fetch(&methdata, NULL, operation_id,
|
||||
name_id, NULL, properties,
|
||||
new_method, up_ref_method, free_method);
|
||||
dealloc_tmp_evp_method_store(methdata.tmp_store);
|
||||
return method;
|
||||
}
|
||||
|
||||
/*
|
||||
* evp_generic_fetch_from_prov() is special, and only returns methods from
|
||||
* the given provider.
|
||||
* This is meant to be used when one method needs to fetch an associated
|
||||
* method.
|
||||
*/
|
||||
void *evp_generic_fetch_from_prov(OSSL_PROVIDER *prov, int operation_id,
|
||||
const char *name, const char *properties,
|
||||
void *(*new_method)(int name_id,
|
||||
const OSSL_ALGORITHM *algodef,
|
||||
OSSL_PROVIDER *prov),
|
||||
int (*up_ref_method)(void *),
|
||||
void (*free_method)(void *))
|
||||
{
|
||||
struct evp_method_data_st methdata;
|
||||
void *method;
|
||||
|
||||
methdata.libctx = ossl_provider_libctx(prov);
|
||||
methdata.tmp_store = NULL;
|
||||
method = inner_evp_generic_fetch(&methdata, prov, operation_id,
|
||||
0, name, properties,
|
||||
new_method, up_ref_method, free_method);
|
||||
dealloc_tmp_evp_method_store(methdata.tmp_store);
|
||||
return method;
|
||||
@@ -588,7 +617,7 @@ void evp_generic_do_all(OSSL_LIB_CTX *libctx, int operation_id,
|
||||
|
||||
methdata.libctx = libctx;
|
||||
methdata.tmp_store = NULL;
|
||||
(void)inner_evp_generic_fetch(&methdata, operation_id, 0, NULL, NULL,
|
||||
(void)inner_evp_generic_fetch(&methdata, NULL, operation_id, 0, NULL, NULL,
|
||||
new_method, up_ref_method, free_method);
|
||||
|
||||
data.operation_id = operation_id;
|
||||
|
||||
+1
-1
@@ -999,7 +999,7 @@ EVP_MD *EVP_MD_CTX_get1_md(EVP_MD_CTX *ctx)
|
||||
if (ctx == NULL)
|
||||
return NULL;
|
||||
md = (EVP_MD *)ctx->reqdigest;
|
||||
if (!EVP_MD_up_ref(md))
|
||||
if (md == NULL || !EVP_MD_up_ref(md))
|
||||
return NULL;
|
||||
return md;
|
||||
}
|
||||
|
||||
+22
@@ -276,6 +276,13 @@ void *evp_generic_fetch_by_number(OSSL_LIB_CTX *ctx, int operation_id,
|
||||
OSSL_PROVIDER *prov),
|
||||
int (*up_ref_method)(void *),
|
||||
void (*free_method)(void *));
|
||||
void *evp_generic_fetch_from_prov(OSSL_PROVIDER *prov, int operation_id,
|
||||
const char *name, const char *properties,
|
||||
void *(*new_method)(int name_id,
|
||||
const OSSL_ALGORITHM *algodef,
|
||||
OSSL_PROVIDER *prov),
|
||||
int (*up_ref_method)(void *),
|
||||
void (*free_method)(void *));
|
||||
void evp_generic_do_all_prefetched(OSSL_LIB_CTX *libctx, int operation_id,
|
||||
void (*user_fn)(void *method, void *arg),
|
||||
void *user_arg);
|
||||
@@ -291,6 +298,21 @@ void evp_generic_do_all(OSSL_LIB_CTX *libctx, int operation_id,
|
||||
/* Internal fetchers for method types that are to be combined with others */
|
||||
EVP_KEYMGMT *evp_keymgmt_fetch_by_number(OSSL_LIB_CTX *ctx, int name_id,
|
||||
const char *properties);
|
||||
EVP_KEYMGMT *evp_keymgmt_fetch_from_prov(OSSL_PROVIDER *prov,
|
||||
const char *name,
|
||||
const char *properties);
|
||||
EVP_SIGNATURE *evp_signature_fetch_from_prov(OSSL_PROVIDER *prov,
|
||||
const char *name,
|
||||
const char *properties);
|
||||
EVP_ASYM_CIPHER *evp_asym_cipher_fetch_from_prov(OSSL_PROVIDER *prov,
|
||||
const char *name,
|
||||
const char *properties);
|
||||
EVP_KEYEXCH *evp_keyexch_fetch_from_prov(OSSL_PROVIDER *prov,
|
||||
const char *name,
|
||||
const char *properties);
|
||||
EVP_KEM *evp_kem_fetch_from_prov(OSSL_PROVIDER *prov,
|
||||
const char *name,
|
||||
const char *properties);
|
||||
|
||||
/* Internal structure constructors for fetched methods */
|
||||
EVP_MD *evp_md_new(void);
|
||||
|
||||
+99
-42
@@ -10,6 +10,7 @@
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/err.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include "internal/refcount.h"
|
||||
#include "internal/provider.h"
|
||||
#include "internal/core.h"
|
||||
@@ -180,6 +181,17 @@ EVP_KEYEXCH *EVP_KEYEXCH_fetch(OSSL_LIB_CTX *ctx, const char *algorithm,
|
||||
(void (*)(void *))EVP_KEYEXCH_free);
|
||||
}
|
||||
|
||||
EVP_KEYEXCH *evp_keyexch_fetch_from_prov(OSSL_PROVIDER *prov,
|
||||
const char *algorithm,
|
||||
const char *properties)
|
||||
{
|
||||
return evp_generic_fetch_from_prov(prov, OSSL_OP_KEYEXCH,
|
||||
algorithm, properties,
|
||||
evp_keyexch_from_algorithm,
|
||||
(int (*)(void *))EVP_KEYEXCH_up_ref,
|
||||
(void (*)(void *))EVP_KEYEXCH_free);
|
||||
}
|
||||
|
||||
int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx)
|
||||
{
|
||||
return EVP_PKEY_derive_init_ex(ctx, NULL);
|
||||
@@ -191,7 +203,9 @@ int EVP_PKEY_derive_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[])
|
||||
void *provkey = NULL;
|
||||
EVP_KEYEXCH *exchange = NULL;
|
||||
EVP_KEYMGMT *tmp_keymgmt = NULL;
|
||||
const OSSL_PROVIDER *tmp_prov = NULL;
|
||||
const char *supported_exch = NULL;
|
||||
int iter;
|
||||
|
||||
if (ctx == NULL) {
|
||||
ERR_raise(ERR_LIB_EVP, ERR_R_PASSED_NULL_PARAMETER);
|
||||
@@ -207,73 +221,113 @@ int EVP_PKEY_derive_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[])
|
||||
goto legacy;
|
||||
|
||||
/*
|
||||
* Ensure that the key is provided, either natively, or as a cached export.
|
||||
* If not, goto legacy
|
||||
* Some algorithms (e.g. legacy KDFs) don't have a pkey - so we create
|
||||
* a blank one.
|
||||
*/
|
||||
tmp_keymgmt = ctx->keymgmt;
|
||||
if (ctx->pkey == NULL) {
|
||||
/*
|
||||
* Some algorithms (e.g. legacy KDFs) don't have a pkey - so we create
|
||||
* a blank one.
|
||||
*/
|
||||
EVP_PKEY *pkey = EVP_PKEY_new();
|
||||
|
||||
if (pkey == NULL || !EVP_PKEY_set_type_by_keymgmt(pkey, tmp_keymgmt)) {
|
||||
if (pkey == NULL
|
||||
|| !EVP_PKEY_set_type_by_keymgmt(pkey, ctx->keymgmt)
|
||||
|| (pkey->keydata = evp_keymgmt_newdata(ctx->keymgmt)) == NULL) {
|
||||
ERR_clear_last_mark();
|
||||
EVP_PKEY_free(pkey);
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
||||
goto err;
|
||||
}
|
||||
provkey = pkey->keydata = evp_keymgmt_newdata(tmp_keymgmt);
|
||||
if (provkey == NULL)
|
||||
EVP_PKEY_free(pkey);
|
||||
else
|
||||
ctx->pkey = pkey;
|
||||
} else {
|
||||
provkey = evp_pkey_export_to_provider(ctx->pkey, ctx->libctx,
|
||||
&tmp_keymgmt, ctx->propquery);
|
||||
ctx->pkey = pkey;
|
||||
}
|
||||
if (provkey == NULL)
|
||||
goto legacy;
|
||||
if (!EVP_KEYMGMT_up_ref(tmp_keymgmt)) {
|
||||
|
||||
/*
|
||||
* Try to derive the supported exch from |ctx->keymgmt|.
|
||||
*/
|
||||
if (!ossl_assert(ctx->pkey->keymgmt == NULL
|
||||
|| ctx->pkey->keymgmt == ctx->keymgmt)) {
|
||||
ERR_clear_last_mark();
|
||||
ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
supported_exch = evp_keymgmt_util_query_operation_name(ctx->keymgmt,
|
||||
OSSL_OP_KEYEXCH);
|
||||
if (supported_exch == NULL) {
|
||||
ERR_clear_last_mark();
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
||||
goto err;
|
||||
}
|
||||
EVP_KEYMGMT_free(ctx->keymgmt);
|
||||
ctx->keymgmt = tmp_keymgmt;
|
||||
|
||||
if (ctx->keymgmt->query_operation_name != NULL)
|
||||
supported_exch = ctx->keymgmt->query_operation_name(OSSL_OP_KEYEXCH);
|
||||
|
||||
/*
|
||||
* If we didn't get a supported exch, assume there is one with the
|
||||
* same name as the key type.
|
||||
* We perform two iterations:
|
||||
*
|
||||
* 1. Do the normal exchange fetch, using the fetching data given by
|
||||
* the EVP_PKEY_CTX.
|
||||
* 2. Do the provider specific exchange fetch, from the same provider
|
||||
* as |ctx->keymgmt|
|
||||
*
|
||||
* We then try to fetch the keymgmt from the same provider as the
|
||||
* exchange, and try to export |ctx->pkey| to that keymgmt (when
|
||||
* this keymgmt happens to be the same as |ctx->keymgmt|, the export
|
||||
* is a no-op, but we call it anyway to not complicate the code even
|
||||
* more).
|
||||
* If the export call succeeds (returns a non-NULL provider key pointer),
|
||||
* we're done and can perform the operation itself. If not, we perform
|
||||
* the second iteration, or jump to legacy.
|
||||
*/
|
||||
if (supported_exch == NULL)
|
||||
supported_exch = ctx->keytype;
|
||||
for (iter = 1, provkey = NULL; iter < 3 && provkey == NULL; iter++) {
|
||||
EVP_KEYMGMT *tmp_keymgmt_tofree = NULL;
|
||||
|
||||
/*
|
||||
* Because we cleared out old ops, we shouldn't need to worry about
|
||||
* checking if exchange is already there.
|
||||
*/
|
||||
exchange = EVP_KEYEXCH_fetch(ctx->libctx, supported_exch, ctx->propquery);
|
||||
|
||||
if (exchange == NULL
|
||||
|| (EVP_KEYMGMT_get0_provider(ctx->keymgmt)
|
||||
!= EVP_KEYEXCH_get0_provider(exchange))) {
|
||||
/*
|
||||
* We don't need to free ctx->keymgmt here, as it's not necessarily
|
||||
* tied to this operation. It will be freed by EVP_PKEY_CTX_free().
|
||||
* If we're on the second iteration, free the results from the first.
|
||||
* They are NULL on the first iteration, so no need to check what
|
||||
* iteration we're on.
|
||||
*/
|
||||
EVP_KEYEXCH_free(exchange);
|
||||
EVP_KEYMGMT_free(tmp_keymgmt);
|
||||
|
||||
switch (iter) {
|
||||
case 1:
|
||||
exchange =
|
||||
EVP_KEYEXCH_fetch(ctx->libctx, supported_exch, ctx->propquery);
|
||||
if (exchange != NULL)
|
||||
tmp_prov = EVP_KEYEXCH_get0_provider(exchange);
|
||||
break;
|
||||
case 2:
|
||||
tmp_prov = EVP_KEYMGMT_get0_provider(ctx->keymgmt);
|
||||
exchange =
|
||||
evp_keyexch_fetch_from_prov((OSSL_PROVIDER *)tmp_prov,
|
||||
supported_exch, ctx->propquery);
|
||||
if (exchange == NULL)
|
||||
goto legacy;
|
||||
break;
|
||||
}
|
||||
if (exchange == NULL)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Ensure that the key is provided, either natively, or as a cached
|
||||
* export. We start by fetching the keymgmt with the same name as
|
||||
* |ctx->pkey|, but from the provider of the exchange method, using
|
||||
* the same property query as when fetching the exchange method.
|
||||
* With the keymgmt we found (if we did), we try to export |ctx->pkey|
|
||||
* to it (evp_pkey_export_to_provider() is smart enough to only actually
|
||||
* export it if |tmp_keymgmt| is different from |ctx->pkey|'s keymgmt)
|
||||
*/
|
||||
tmp_keymgmt_tofree = tmp_keymgmt =
|
||||
evp_keymgmt_fetch_from_prov((OSSL_PROVIDER *)tmp_prov,
|
||||
EVP_KEYMGMT_get0_name(ctx->keymgmt),
|
||||
ctx->propquery);
|
||||
if (tmp_keymgmt != NULL)
|
||||
provkey = evp_pkey_export_to_provider(ctx->pkey, ctx->libctx,
|
||||
&tmp_keymgmt, ctx->propquery);
|
||||
if (tmp_keymgmt == NULL)
|
||||
EVP_KEYMGMT_free(tmp_keymgmt_tofree);
|
||||
}
|
||||
|
||||
if (provkey == NULL) {
|
||||
EVP_KEYEXCH_free(exchange);
|
||||
goto legacy;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we don't have the full support we need with provided methods,
|
||||
* let's go see if legacy does.
|
||||
*/
|
||||
ERR_pop_to_mark();
|
||||
|
||||
/* No more legacy from here down to legacy: */
|
||||
@@ -287,10 +341,12 @@ int EVP_PKEY_derive_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[])
|
||||
}
|
||||
ret = exchange->init(ctx->op.kex.algctx, provkey, params);
|
||||
|
||||
EVP_KEYMGMT_free(tmp_keymgmt);
|
||||
return ret ? 1 : 0;
|
||||
err:
|
||||
evp_pkey_ctx_free_old_ops(ctx);
|
||||
ctx->operation = EVP_PKEY_OP_UNDEFINED;
|
||||
EVP_KEYMGMT_free(tmp_keymgmt);
|
||||
return 0;
|
||||
|
||||
legacy:
|
||||
@@ -313,6 +369,7 @@ int EVP_PKEY_derive_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[])
|
||||
ret = ctx->pmeth->derive_init(ctx);
|
||||
if (ret <= 0)
|
||||
ctx->operation = EVP_PKEY_OP_UNDEFINED;
|
||||
EVP_KEYMGMT_free(tmp_keymgmt);
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
+101
-20
@@ -23,8 +23,10 @@ static int evp_kem_init(EVP_PKEY_CTX *ctx, int operation,
|
||||
int ret = 0;
|
||||
EVP_KEM *kem = NULL;
|
||||
EVP_KEYMGMT *tmp_keymgmt = NULL;
|
||||
const OSSL_PROVIDER *tmp_prov = NULL;
|
||||
void *provkey = NULL;
|
||||
const char *supported_kem = NULL;
|
||||
int iter;
|
||||
|
||||
if (ctx == NULL || ctx->keytype == NULL) {
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
||||
@@ -34,35 +36,101 @@ static int evp_kem_init(EVP_PKEY_CTX *ctx, int operation,
|
||||
evp_pkey_ctx_free_old_ops(ctx);
|
||||
ctx->operation = operation;
|
||||
|
||||
if (ctx->pkey == NULL) {
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_NO_KEY_SET);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ensure that the key is provided, either natively, or as a cached export.
|
||||
* Try to derive the supported kem from |ctx->keymgmt|.
|
||||
*/
|
||||
tmp_keymgmt = ctx->keymgmt;
|
||||
provkey = evp_pkey_export_to_provider(ctx->pkey, ctx->libctx,
|
||||
&tmp_keymgmt, ctx->propquery);
|
||||
if (provkey == NULL
|
||||
|| !EVP_KEYMGMT_up_ref(tmp_keymgmt)) {
|
||||
if (!ossl_assert(ctx->pkey->keymgmt == NULL
|
||||
|| ctx->pkey->keymgmt == ctx->keymgmt)) {
|
||||
ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
supported_kem = evp_keymgmt_util_query_operation_name(ctx->keymgmt,
|
||||
OSSL_OP_KEM);
|
||||
if (supported_kem == NULL) {
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
||||
goto err;
|
||||
}
|
||||
EVP_KEYMGMT_free(ctx->keymgmt);
|
||||
ctx->keymgmt = tmp_keymgmt;
|
||||
|
||||
if (ctx->keymgmt->query_operation_name != NULL)
|
||||
supported_kem = ctx->keymgmt->query_operation_name(OSSL_OP_KEM);
|
||||
|
||||
/*
|
||||
* If we didn't get a supported kem, assume there is one with the
|
||||
* same name as the key type.
|
||||
* Because we cleared out old ops, we shouldn't need to worry about
|
||||
* checking if kem is already there.
|
||||
* We perform two iterations:
|
||||
*
|
||||
* 1. Do the normal kem fetch, using the fetching data given by
|
||||
* the EVP_PKEY_CTX.
|
||||
* 2. Do the provider specific kem fetch, from the same provider
|
||||
* as |ctx->keymgmt|
|
||||
*
|
||||
* We then try to fetch the keymgmt from the same provider as the
|
||||
* kem, and try to export |ctx->pkey| to that keymgmt (when this
|
||||
* keymgmt happens to be the same as |ctx->keymgmt|, the export is
|
||||
* a no-op, but we call it anyway to not complicate the code even
|
||||
* more).
|
||||
* If the export call succeeds (returns a non-NULL provider key pointer),
|
||||
* we're done and can perform the operation itself. If not, we perform
|
||||
* the second iteration, or jump to legacy.
|
||||
*/
|
||||
if (supported_kem == NULL)
|
||||
supported_kem = ctx->keytype;
|
||||
for (iter = 1, provkey = NULL; iter < 3 && provkey == NULL; iter++) {
|
||||
EVP_KEYMGMT *tmp_keymgmt_tofree = NULL;
|
||||
|
||||
kem = EVP_KEM_fetch(ctx->libctx, supported_kem, ctx->propquery);
|
||||
if (kem == NULL
|
||||
|| (EVP_KEYMGMT_get0_provider(ctx->keymgmt) != EVP_KEM_get0_provider(kem))) {
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
|
||||
ret = -2;
|
||||
/*
|
||||
* If we're on the second iteration, free the results from the first.
|
||||
* They are NULL on the first iteration, so no need to check what
|
||||
* iteration we're on.
|
||||
*/
|
||||
EVP_KEM_free(kem);
|
||||
EVP_KEYMGMT_free(tmp_keymgmt);
|
||||
|
||||
switch (iter) {
|
||||
case 1:
|
||||
kem = EVP_KEM_fetch(ctx->libctx, supported_kem, ctx->propquery);
|
||||
if (kem != NULL)
|
||||
tmp_prov = EVP_KEM_get0_provider(kem);
|
||||
break;
|
||||
case 2:
|
||||
tmp_prov = EVP_KEYMGMT_get0_provider(ctx->keymgmt);
|
||||
kem = evp_kem_fetch_from_prov((OSSL_PROVIDER *)tmp_prov,
|
||||
supported_kem, ctx->propquery);
|
||||
|
||||
if (kem == NULL) {
|
||||
ERR_raise(ERR_LIB_EVP,
|
||||
EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
|
||||
ret = -2;
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (kem == NULL)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Ensure that the key is provided, either natively, or as a cached
|
||||
* export. We start by fetching the keymgmt with the same name as
|
||||
* |ctx->pkey|, but from the provider of the kem method, using the
|
||||
* same property query as when fetching the kem method.
|
||||
* With the keymgmt we found (if we did), we try to export |ctx->pkey|
|
||||
* to it (evp_pkey_export_to_provider() is smart enough to only actually
|
||||
|
||||
* export it if |tmp_keymgmt| is different from |ctx->pkey|'s keymgmt)
|
||||
*/
|
||||
tmp_keymgmt_tofree = tmp_keymgmt =
|
||||
evp_keymgmt_fetch_from_prov((OSSL_PROVIDER *)tmp_prov,
|
||||
EVP_KEYMGMT_get0_name(ctx->keymgmt),
|
||||
ctx->propquery);
|
||||
if (tmp_keymgmt != NULL)
|
||||
provkey = evp_pkey_export_to_provider(ctx->pkey, ctx->libctx,
|
||||
&tmp_keymgmt, ctx->propquery);
|
||||
if (tmp_keymgmt == NULL)
|
||||
EVP_KEYMGMT_free(tmp_keymgmt_tofree);
|
||||
}
|
||||
|
||||
if (provkey == NULL) {
|
||||
EVP_KEM_free(kem);
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -96,6 +164,9 @@ static int evp_kem_init(EVP_PKEY_CTX *ctx, int operation,
|
||||
goto err;
|
||||
}
|
||||
|
||||
EVP_KEYMGMT_free(tmp_keymgmt);
|
||||
tmp_keymgmt = NULL;
|
||||
|
||||
if (ret > 0)
|
||||
return 1;
|
||||
err:
|
||||
@@ -103,6 +174,7 @@ static int evp_kem_init(EVP_PKEY_CTX *ctx, int operation,
|
||||
evp_pkey_ctx_free_old_ops(ctx);
|
||||
ctx->operation = EVP_PKEY_OP_UNDEFINED;
|
||||
}
|
||||
EVP_KEYMGMT_free(tmp_keymgmt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -338,6 +410,15 @@ EVP_KEM *EVP_KEM_fetch(OSSL_LIB_CTX *ctx, const char *algorithm,
|
||||
(void (*)(void *))EVP_KEM_free);
|
||||
}
|
||||
|
||||
EVP_KEM *evp_kem_fetch_from_prov(OSSL_PROVIDER *prov, const char *algorithm,
|
||||
const char *properties)
|
||||
{
|
||||
return evp_generic_fetch_from_prov(prov, OSSL_OP_KEM, algorithm, properties,
|
||||
evp_kem_from_algorithm,
|
||||
(int (*)(void *))EVP_KEM_up_ref,
|
||||
(void (*)(void *))EVP_KEM_free);
|
||||
}
|
||||
|
||||
int EVP_KEM_is_a(const EVP_KEM *kem, const char *name)
|
||||
{
|
||||
return evp_is_a(kem->prov, kem->name_id, NULL, name);
|
||||
|
||||
+20
@@ -197,6 +197,7 @@ void *evp_keymgmt_util_export_to_provider(EVP_PKEY *pk, EVP_KEYMGMT *keymgmt)
|
||||
|
||||
/* Add the new export to the operation cache */
|
||||
if (!evp_keymgmt_util_cache_keydata(pk, keymgmt, import_data.keydata)) {
|
||||
CRYPTO_THREAD_unlock(pk->lock);
|
||||
evp_keymgmt_freedata(keymgmt, import_data.keydata);
|
||||
return NULL;
|
||||
}
|
||||
@@ -561,3 +562,22 @@ int evp_keymgmt_util_get_deflt_digest_name(EVP_KEYMGMT *keymgmt,
|
||||
OPENSSL_strlcpy(mdname, result, mdname_sz);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
* If |keymgmt| has the method function |query_operation_name|, use it to get
|
||||
* the name of a supported operation identity. Otherwise, return the keytype,
|
||||
* assuming that it works as a default operation name.
|
||||
*/
|
||||
const char *evp_keymgmt_util_query_operation_name(EVP_KEYMGMT *keymgmt,
|
||||
int op_id)
|
||||
{
|
||||
const char *name = NULL;
|
||||
|
||||
if (keymgmt != NULL) {
|
||||
if (keymgmt->query_operation_name != NULL)
|
||||
name = keymgmt->query_operation_name(op_id);
|
||||
if (name == NULL)
|
||||
name = EVP_KEYMGMT_get0_name(keymgmt);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
+11
@@ -213,6 +213,17 @@ EVP_KEYMGMT *evp_keymgmt_fetch_by_number(OSSL_LIB_CTX *ctx, int name_id,
|
||||
(void (*)(void *))EVP_KEYMGMT_free);
|
||||
}
|
||||
|
||||
EVP_KEYMGMT *evp_keymgmt_fetch_from_prov(OSSL_PROVIDER *prov,
|
||||
const char *name,
|
||||
const char *properties)
|
||||
{
|
||||
return evp_generic_fetch_from_prov(prov, OSSL_OP_KEYMGMT,
|
||||
name, properties,
|
||||
keymgmt_from_algorithm,
|
||||
(int (*)(void *))EVP_KEYMGMT_up_ref,
|
||||
(void (*)(void *))EVP_KEYMGMT_free);
|
||||
}
|
||||
|
||||
EVP_KEYMGMT *EVP_KEYMGMT_fetch(OSSL_LIB_CTX *ctx, const char *algorithm,
|
||||
const char *properties)
|
||||
{
|
||||
|
||||
+120
-50
@@ -45,10 +45,11 @@ static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
|
||||
EVP_PKEY_CTX *locpctx = NULL;
|
||||
EVP_SIGNATURE *signature = NULL;
|
||||
EVP_KEYMGMT *tmp_keymgmt = NULL;
|
||||
const OSSL_PROVIDER *tmp_prov = NULL;
|
||||
const char *supported_sig = NULL;
|
||||
char locmdname[80] = ""; /* 80 chars should be enough */
|
||||
void *provkey = NULL;
|
||||
int ret;
|
||||
int ret, iter, reinit = 1;
|
||||
|
||||
if (ctx->algctx != NULL) {
|
||||
if (!ossl_assert(ctx->digest != NULL)) {
|
||||
@@ -61,6 +62,7 @@ static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
|
||||
}
|
||||
|
||||
if (ctx->pctx == NULL) {
|
||||
reinit = 0;
|
||||
if (e == NULL)
|
||||
ctx->pctx = EVP_PKEY_CTX_new_from_pkey(libctx, pkey, props);
|
||||
else
|
||||
@@ -70,75 +72,133 @@ static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
|
||||
return 0;
|
||||
|
||||
locpctx = ctx->pctx;
|
||||
evp_pkey_ctx_free_old_ops(locpctx);
|
||||
|
||||
if (props == NULL)
|
||||
props = locpctx->propquery;
|
||||
|
||||
ERR_set_mark();
|
||||
|
||||
if (evp_pkey_ctx_is_legacy(locpctx))
|
||||
goto legacy;
|
||||
|
||||
/* do not reinitialize if pkey is set or operation is different */
|
||||
if (reinit
|
||||
&& (pkey != NULL
|
||||
|| locpctx->operation != (ver ? EVP_PKEY_OP_VERIFYCTX
|
||||
: EVP_PKEY_OP_SIGNCTX)
|
||||
|| (signature = locpctx->op.sig.signature) == NULL
|
||||
|| locpctx->op.sig.algctx == NULL))
|
||||
reinit = 0;
|
||||
|
||||
if (props == NULL)
|
||||
props = locpctx->propquery;
|
||||
|
||||
if (locpctx->pkey == NULL) {
|
||||
ERR_clear_last_mark();
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_NO_KEY_SET);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!reinit) {
|
||||
evp_pkey_ctx_free_old_ops(locpctx);
|
||||
} else {
|
||||
if (mdname == NULL && type == NULL)
|
||||
mdname = canon_mdname(EVP_MD_get0_name(ctx->reqdigest));
|
||||
goto reinitialize;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ensure that the key is provided, either natively, or as a cached export.
|
||||
* Try to derive the supported signature from |locpctx->keymgmt|.
|
||||
*/
|
||||
tmp_keymgmt = locpctx->keymgmt;
|
||||
provkey = evp_pkey_export_to_provider(locpctx->pkey, locpctx->libctx,
|
||||
&tmp_keymgmt, locpctx->propquery);
|
||||
if (provkey == NULL) {
|
||||
if (!ossl_assert(locpctx->pkey->keymgmt == NULL
|
||||
|| locpctx->pkey->keymgmt == locpctx->keymgmt)) {
|
||||
ERR_clear_last_mark();
|
||||
ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
supported_sig = evp_keymgmt_util_query_operation_name(locpctx->keymgmt,
|
||||
OSSL_OP_SIGNATURE);
|
||||
if (supported_sig == NULL) {
|
||||
ERR_clear_last_mark();
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
||||
goto err;
|
||||
}
|
||||
if (!EVP_KEYMGMT_up_ref(tmp_keymgmt)) {
|
||||
ERR_clear_last_mark();
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
||||
goto err;
|
||||
}
|
||||
EVP_KEYMGMT_free(locpctx->keymgmt);
|
||||
locpctx->keymgmt = tmp_keymgmt;
|
||||
|
||||
if (locpctx->keymgmt->query_operation_name != NULL)
|
||||
supported_sig =
|
||||
locpctx->keymgmt->query_operation_name(OSSL_OP_SIGNATURE);
|
||||
|
||||
/*
|
||||
* If we didn't get a supported sig, assume there is one with the
|
||||
* same name as the key type.
|
||||
* We perform two iterations:
|
||||
*
|
||||
* 1. Do the normal signature fetch, using the fetching data given by
|
||||
* the EVP_PKEY_CTX.
|
||||
* 2. Do the provider specific signature fetch, from the same provider
|
||||
* as |ctx->keymgmt|
|
||||
*
|
||||
* We then try to fetch the keymgmt from the same provider as the
|
||||
* signature, and try to export |ctx->pkey| to that keymgmt (when
|
||||
* this keymgmt happens to be the same as |ctx->keymgmt|, the export
|
||||
* is a no-op, but we call it anyway to not complicate the code even
|
||||
* more).
|
||||
* If the export call succeeds (returns a non-NULL provider key pointer),
|
||||
* we're done and can perform the operation itself. If not, we perform
|
||||
* the second iteration, or jump to legacy.
|
||||
*/
|
||||
if (supported_sig == NULL)
|
||||
supported_sig = locpctx->keytype;
|
||||
for (iter = 1, provkey = NULL; iter < 3 && provkey == NULL; iter++) {
|
||||
EVP_KEYMGMT *tmp_keymgmt_tofree = NULL;
|
||||
|
||||
/*
|
||||
* Because we cleared out old ops, we shouldn't need to worry about
|
||||
* checking if signature is already there.
|
||||
*/
|
||||
signature = EVP_SIGNATURE_fetch(locpctx->libctx, supported_sig,
|
||||
locpctx->propquery);
|
||||
|
||||
if (signature == NULL
|
||||
|| (EVP_KEYMGMT_get0_provider(locpctx->keymgmt)
|
||||
!= EVP_SIGNATURE_get0_provider(signature))) {
|
||||
/*
|
||||
* We don't need to free ctx->keymgmt here, as it's not necessarily
|
||||
* tied to this operation. It will be freed by EVP_PKEY_CTX_free().
|
||||
* If we're on the second iteration, free the results from the first.
|
||||
* They are NULL on the first iteration, so no need to check what
|
||||
* iteration we're on.
|
||||
*/
|
||||
EVP_SIGNATURE_free(signature);
|
||||
goto legacy;
|
||||
EVP_KEYMGMT_free(tmp_keymgmt);
|
||||
|
||||
switch (iter) {
|
||||
case 1:
|
||||
signature = EVP_SIGNATURE_fetch(locpctx->libctx, supported_sig,
|
||||
locpctx->propquery);
|
||||
if (signature != NULL)
|
||||
tmp_prov = EVP_SIGNATURE_get0_provider(signature);
|
||||
break;
|
||||
case 2:
|
||||
tmp_prov = EVP_KEYMGMT_get0_provider(locpctx->keymgmt);
|
||||
signature =
|
||||
evp_signature_fetch_from_prov((OSSL_PROVIDER *)tmp_prov,
|
||||
supported_sig, locpctx->propquery);
|
||||
if (signature == NULL)
|
||||
goto legacy;
|
||||
break;
|
||||
}
|
||||
if (signature == NULL)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Ensure that the key is provided, either natively, or as a cached
|
||||
* export. We start by fetching the keymgmt with the same name as
|
||||
* |locpctx->pkey|, but from the provider of the signature method, using
|
||||
* the same property query as when fetching the signature method.
|
||||
* With the keymgmt we found (if we did), we try to export |locpctx->pkey|
|
||||
* to it (evp_pkey_export_to_provider() is smart enough to only actually
|
||||
|
||||
* export it if |tmp_keymgmt| is different from |locpctx->pkey|'s keymgmt)
|
||||
*/
|
||||
tmp_keymgmt_tofree = tmp_keymgmt =
|
||||
evp_keymgmt_fetch_from_prov((OSSL_PROVIDER *)tmp_prov,
|
||||
EVP_KEYMGMT_get0_name(locpctx->keymgmt),
|
||||
locpctx->propquery);
|
||||
if (tmp_keymgmt != NULL)
|
||||
provkey = evp_pkey_export_to_provider(locpctx->pkey, locpctx->libctx,
|
||||
&tmp_keymgmt, locpctx->propquery);
|
||||
if (tmp_keymgmt == NULL)
|
||||
EVP_KEYMGMT_free(tmp_keymgmt_tofree);
|
||||
}
|
||||
|
||||
if (provkey == NULL) {
|
||||
EVP_SIGNATURE_free(signature);
|
||||
ERR_clear_last_mark();
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we don't have the full support we need with provided methods,
|
||||
* let's go see if legacy does.
|
||||
*/
|
||||
ERR_pop_to_mark();
|
||||
|
||||
/* No more legacy from here down to legacy: */
|
||||
|
||||
if (pctx != NULL)
|
||||
*pctx = locpctx;
|
||||
|
||||
locpctx->op.sig.signature = signature;
|
||||
locpctx->operation = ver ? EVP_PKEY_OP_VERIFYCTX
|
||||
: EVP_PKEY_OP_SIGNCTX;
|
||||
@@ -148,12 +208,17 @@ static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
||||
goto err;
|
||||
}
|
||||
|
||||
reinitialize:
|
||||
if (pctx != NULL)
|
||||
*pctx = locpctx;
|
||||
|
||||
if (type != NULL) {
|
||||
ctx->reqdigest = type;
|
||||
if (mdname == NULL)
|
||||
mdname = canon_mdname(EVP_MD_get0_name(type));
|
||||
} else {
|
||||
if (mdname == NULL) {
|
||||
if (mdname == NULL && !reinit) {
|
||||
if (evp_keymgmt_util_get_deflt_digest_name(tmp_keymgmt, provkey,
|
||||
locmdname,
|
||||
sizeof(locmdname)) > 0) {
|
||||
@@ -221,6 +286,7 @@ static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
|
||||
err:
|
||||
evp_pkey_ctx_free_old_ops(locpctx);
|
||||
locpctx->operation = EVP_PKEY_OP_UNDEFINED;
|
||||
EVP_KEYMGMT_free(tmp_keymgmt);
|
||||
return 0;
|
||||
|
||||
legacy:
|
||||
@@ -229,6 +295,8 @@ static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
|
||||
* let's go see if legacy does.
|
||||
*/
|
||||
ERR_pop_to_mark();
|
||||
EVP_KEYMGMT_free(tmp_keymgmt);
|
||||
tmp_keymgmt = NULL;
|
||||
|
||||
if (type == NULL && mdname != NULL)
|
||||
type = evp_get_digestbyname_ex(locpctx->libctx, mdname);
|
||||
@@ -299,6 +367,7 @@ static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
|
||||
ret = evp_pkey_ctx_use_cached_data(locpctx);
|
||||
#endif
|
||||
|
||||
EVP_KEYMGMT_free(tmp_keymgmt);
|
||||
return ret > 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
@@ -411,14 +480,14 @@ int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
|
||||
if (sigret == NULL || (ctx->flags & EVP_MD_CTX_FLAG_FINALISE) != 0)
|
||||
return pctx->op.sig.signature->digest_sign_final(pctx->op.sig.algctx,
|
||||
sigret, siglen,
|
||||
SIZE_MAX);
|
||||
(siglen == NULL) ? 0 : *siglen);
|
||||
dctx = EVP_PKEY_CTX_dup(pctx);
|
||||
if (dctx == NULL)
|
||||
return 0;
|
||||
|
||||
r = dctx->op.sig.signature->digest_sign_final(dctx->op.sig.algctx,
|
||||
sigret, siglen,
|
||||
SIZE_MAX);
|
||||
(siglen == NULL) ? 0 : *siglen);
|
||||
EVP_PKEY_CTX_free(dctx);
|
||||
return r;
|
||||
|
||||
@@ -506,7 +575,8 @@ int EVP_DigestSign(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen,
|
||||
&& pctx->op.sig.signature != NULL) {
|
||||
if (pctx->op.sig.signature->digest_sign != NULL)
|
||||
return pctx->op.sig.signature->digest_sign(pctx->op.sig.algctx,
|
||||
sigret, siglen, SIZE_MAX,
|
||||
sigret, siglen,
|
||||
sigret == NULL ? 0 : *siglen,
|
||||
tbs, tbslen);
|
||||
} else {
|
||||
/* legacy */
|
||||
|
||||
+7
-1
@@ -132,6 +132,7 @@ static int evp_mac_final(EVP_MAC_CTX *ctx, int xof,
|
||||
size_t l;
|
||||
int res;
|
||||
OSSL_PARAM params[2];
|
||||
size_t macsize;
|
||||
|
||||
if (ctx == NULL || ctx->meth == NULL) {
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_INVALID_NULL_ALGORITHM);
|
||||
@@ -142,14 +143,19 @@ static int evp_mac_final(EVP_MAC_CTX *ctx, int xof,
|
||||
return 0;
|
||||
}
|
||||
|
||||
macsize = EVP_MAC_CTX_get_mac_size(ctx);
|
||||
if (out == NULL) {
|
||||
if (outl == NULL) {
|
||||
ERR_raise(ERR_LIB_EVP, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
*outl = EVP_MAC_CTX_get_mac_size(ctx);
|
||||
*outl = macsize;
|
||||
return 1;
|
||||
}
|
||||
if (outsize < macsize) {
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_BUFFER_TOO_SMALL);
|
||||
return 0;
|
||||
}
|
||||
if (xof) {
|
||||
params[0] = OSSL_PARAM_construct_int(OSSL_MAC_PARAM_XOF, &xof);
|
||||
params[1] = OSSL_PARAM_construct_end();
|
||||
|
||||
+16
-6
@@ -343,7 +343,7 @@ int EVP_PKEY_eq(const EVP_PKEY *a, const EVP_PKEY *b)
|
||||
|
||||
if (a->keymgmt != NULL || b->keymgmt != NULL)
|
||||
return evp_pkey_cmp_any(a, b, (SELECT_PARAMETERS
|
||||
| OSSL_KEYMGMT_SELECT_PUBLIC_KEY));
|
||||
| OSSL_KEYMGMT_SELECT_KEYPAIR));
|
||||
|
||||
/* All legacy keys */
|
||||
if (a->type != b->type)
|
||||
@@ -529,12 +529,14 @@ static int get_raw_key_details(const OSSL_PARAM params[], void *arg)
|
||||
if ((p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PRIV_KEY))
|
||||
!= NULL)
|
||||
return OSSL_PARAM_get_octet_string(p, (void **)raw_key->key,
|
||||
SIZE_MAX, raw_key->len);
|
||||
raw_key->key == NULL ? 0 : *raw_key->len,
|
||||
raw_key->len);
|
||||
} else if (raw_key->selection == OSSL_KEYMGMT_SELECT_PUBLIC_KEY) {
|
||||
if ((p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PUB_KEY))
|
||||
!= NULL)
|
||||
return OSSL_PARAM_get_octet_string(p, (void **)raw_key->key,
|
||||
SIZE_MAX, raw_key->len);
|
||||
raw_key->key == NULL ? 0 : *raw_key->len,
|
||||
raw_key->len);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -630,7 +632,7 @@ static EVP_PKEY *new_cmac_key_int(const unsigned char *priv, size_t len,
|
||||
if (ctx == NULL)
|
||||
goto err;
|
||||
|
||||
if (!EVP_PKEY_fromdata_init(ctx)) {
|
||||
if (EVP_PKEY_fromdata_init(ctx) <= 0) {
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_KEY_SETUP_FAILED);
|
||||
goto err;
|
||||
}
|
||||
@@ -649,7 +651,7 @@ static EVP_PKEY *new_cmac_key_int(const unsigned char *priv, size_t len,
|
||||
# endif
|
||||
*p = OSSL_PARAM_construct_end();
|
||||
|
||||
if (!EVP_PKEY_fromdata(ctx, &pkey, EVP_PKEY_KEYPAIR, params)) {
|
||||
if (EVP_PKEY_fromdata(ctx, &pkey, EVP_PKEY_KEYPAIR, params) <= 0) {
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_KEY_SETUP_FAILED);
|
||||
goto err;
|
||||
}
|
||||
@@ -1554,7 +1556,6 @@ static int pkey_set_type(EVP_PKEY *pkey, ENGINE *e, int type, const char *str,
|
||||
*/
|
||||
if (keymgmt == NULL)
|
||||
pkey->ameth = ameth;
|
||||
pkey->engine = e;
|
||||
|
||||
/*
|
||||
* The EVP_PKEY_ASN1_METHOD |pkey_id| retains its legacy key purpose
|
||||
@@ -1570,6 +1571,13 @@ static int pkey_set_type(EVP_PKEY *pkey, ENGINE *e, int type, const char *str,
|
||||
} else {
|
||||
pkey->type = EVP_PKEY_KEYMGMT;
|
||||
}
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
if (eptr == NULL && e != NULL && !ENGINE_init(e)) {
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
||||
return 0;
|
||||
}
|
||||
# endif
|
||||
pkey->engine = e;
|
||||
#endif
|
||||
}
|
||||
return 1;
|
||||
@@ -1842,6 +1850,8 @@ void *evp_pkey_export_to_provider(EVP_PKEY *pk, OSSL_LIB_CTX *libctx,
|
||||
if (tmp_keymgmt == NULL) {
|
||||
EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new_from_pkey(libctx, pk, propquery);
|
||||
|
||||
if (ctx == NULL)
|
||||
goto end;
|
||||
tmp_keymgmt = ctx->keymgmt;
|
||||
ctx->keymgmt = NULL;
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
|
||||
+14
-1
@@ -265,7 +265,20 @@ static EVP_PKEY_CTX *int_ctx_new(OSSL_LIB_CTX *libctx,
|
||||
* fetching a provider implementation.
|
||||
*/
|
||||
if (e == NULL && app_pmeth == NULL && keytype != NULL) {
|
||||
keymgmt = EVP_KEYMGMT_fetch(libctx, keytype, propquery);
|
||||
/*
|
||||
* If |pkey| is given and is provided, we take a reference to its
|
||||
* keymgmt. Otherwise, we fetch one for the keytype we got. This
|
||||
* is to ensure that operation init functions can access what they
|
||||
* need through this single pointer.
|
||||
*/
|
||||
if (pkey != NULL && pkey->keymgmt != NULL) {
|
||||
if (!EVP_KEYMGMT_up_ref(pkey->keymgmt))
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
||||
else
|
||||
keymgmt = pkey->keymgmt;
|
||||
} else {
|
||||
keymgmt = EVP_KEYMGMT_fetch(libctx, keytype, propquery);
|
||||
}
|
||||
if (keymgmt == NULL)
|
||||
return NULL; /* EVP_KEYMGMT_fetch() recorded an error */
|
||||
|
||||
|
||||
+98
-34
@@ -314,6 +314,17 @@ EVP_SIGNATURE *EVP_SIGNATURE_fetch(OSSL_LIB_CTX *ctx, const char *algorithm,
|
||||
(void (*)(void *))EVP_SIGNATURE_free);
|
||||
}
|
||||
|
||||
EVP_SIGNATURE *evp_signature_fetch_from_prov(OSSL_PROVIDER *prov,
|
||||
const char *algorithm,
|
||||
const char *properties)
|
||||
{
|
||||
return evp_generic_fetch_from_prov(prov, OSSL_OP_SIGNATURE,
|
||||
algorithm, properties,
|
||||
evp_signature_from_algorithm,
|
||||
(int (*)(void *))EVP_SIGNATURE_up_ref,
|
||||
(void (*)(void *))EVP_SIGNATURE_free);
|
||||
}
|
||||
|
||||
int EVP_SIGNATURE_is_a(const EVP_SIGNATURE *signature, const char *name)
|
||||
{
|
||||
return evp_is_a(signature->prov, signature->name_id, NULL, name);
|
||||
@@ -386,7 +397,9 @@ static int evp_pkey_signature_init(EVP_PKEY_CTX *ctx, int operation,
|
||||
void *provkey = NULL;
|
||||
EVP_SIGNATURE *signature = NULL;
|
||||
EVP_KEYMGMT *tmp_keymgmt = NULL;
|
||||
const OSSL_PROVIDER *tmp_prov = NULL;
|
||||
const char *supported_sig = NULL;
|
||||
int iter;
|
||||
|
||||
if (ctx == NULL) {
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
|
||||
@@ -401,55 +414,102 @@ static int evp_pkey_signature_init(EVP_PKEY_CTX *ctx, int operation,
|
||||
if (evp_pkey_ctx_is_legacy(ctx))
|
||||
goto legacy;
|
||||
|
||||
if (ctx->pkey == NULL) {
|
||||
ERR_clear_last_mark();
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_NO_KEY_SET);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ensure that the key is provided, either natively, or as a cached export.
|
||||
* If not, go legacy
|
||||
* Try to derive the supported signature from |ctx->keymgmt|.
|
||||
*/
|
||||
tmp_keymgmt = ctx->keymgmt;
|
||||
provkey = evp_pkey_export_to_provider(ctx->pkey, ctx->libctx,
|
||||
&tmp_keymgmt, ctx->propquery);
|
||||
if (tmp_keymgmt == NULL)
|
||||
goto legacy;
|
||||
if (!EVP_KEYMGMT_up_ref(tmp_keymgmt)) {
|
||||
if (!ossl_assert(ctx->pkey->keymgmt == NULL
|
||||
|| ctx->pkey->keymgmt == ctx->keymgmt)) {
|
||||
ERR_clear_last_mark();
|
||||
ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
supported_sig = evp_keymgmt_util_query_operation_name(ctx->keymgmt,
|
||||
OSSL_OP_SIGNATURE);
|
||||
if (supported_sig == NULL) {
|
||||
ERR_clear_last_mark();
|
||||
ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
|
||||
goto err;
|
||||
}
|
||||
EVP_KEYMGMT_free(ctx->keymgmt);
|
||||
ctx->keymgmt = tmp_keymgmt;
|
||||
|
||||
if (ctx->keymgmt->query_operation_name != NULL)
|
||||
supported_sig = ctx->keymgmt->query_operation_name(OSSL_OP_SIGNATURE);
|
||||
|
||||
/*
|
||||
* If we didn't get a supported sig, assume there is one with the
|
||||
* same name as the key type.
|
||||
* We perform two iterations:
|
||||
*
|
||||
* 1. Do the normal signature fetch, using the fetching data given by
|
||||
* the EVP_PKEY_CTX.
|
||||
* 2. Do the provider specific signature fetch, from the same provider
|
||||
* as |ctx->keymgmt|
|
||||
*
|
||||
* We then try to fetch the keymgmt from the same provider as the
|
||||
* signature, and try to export |ctx->pkey| to that keymgmt (when
|
||||
* this keymgmt happens to be the same as |ctx->keymgmt|, the export
|
||||
* is a no-op, but we call it anyway to not complicate the code even
|
||||
* more).
|
||||
* If the export call succeeds (returns a non-NULL provider key pointer),
|
||||
* we're done and can perform the operation itself. If not, we perform
|
||||
* the second iteration, or jump to legacy.
|
||||
*/
|
||||
if (supported_sig == NULL)
|
||||
supported_sig = ctx->keytype;
|
||||
for (iter = 1; iter < 3 && provkey == NULL; iter++) {
|
||||
EVP_KEYMGMT *tmp_keymgmt_tofree = NULL;
|
||||
|
||||
/*
|
||||
* Because we cleared out old ops, we shouldn't need to worry about
|
||||
* checking if signature is already there.
|
||||
*/
|
||||
signature =
|
||||
EVP_SIGNATURE_fetch(ctx->libctx, supported_sig, ctx->propquery);
|
||||
|
||||
if (signature == NULL
|
||||
|| (EVP_KEYMGMT_get0_provider(ctx->keymgmt)
|
||||
!= EVP_SIGNATURE_get0_provider(signature))) {
|
||||
/*
|
||||
* We don't need to free ctx->keymgmt here, as it's not necessarily
|
||||
* tied to this operation. It will be freed by EVP_PKEY_CTX_free().
|
||||
* If we're on the second iteration, free the results from the first.
|
||||
* They are NULL on the first iteration, so no need to check what
|
||||
* iteration we're on.
|
||||
*/
|
||||
EVP_SIGNATURE_free(signature);
|
||||
EVP_KEYMGMT_free(tmp_keymgmt);
|
||||
|
||||
switch (iter) {
|
||||
case 1:
|
||||
signature =
|
||||
EVP_SIGNATURE_fetch(ctx->libctx, supported_sig, ctx->propquery);
|
||||
if (signature != NULL)
|
||||
tmp_prov = EVP_SIGNATURE_get0_provider(signature);
|
||||
break;
|
||||
case 2:
|
||||
tmp_prov = EVP_KEYMGMT_get0_provider(ctx->keymgmt);
|
||||
signature =
|
||||
evp_signature_fetch_from_prov((OSSL_PROVIDER *)tmp_prov,
|
||||
supported_sig, ctx->propquery);
|
||||
if (signature == NULL)
|
||||
goto legacy;
|
||||
break;
|
||||
}
|
||||
if (signature == NULL)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Ensure that the key is provided, either natively, or as a cached
|
||||
* export. We start by fetching the keymgmt with the same name as
|
||||
* |ctx->pkey|, but from the provider of the signature method, using
|
||||
* the same property query as when fetching the signature method.
|
||||
* With the keymgmt we found (if we did), we try to export |ctx->pkey|
|
||||
* to it (evp_pkey_export_to_provider() is smart enough to only actually
|
||||
|
||||
* export it if |tmp_keymgmt| is different from |ctx->pkey|'s keymgmt)
|
||||
*/
|
||||
tmp_keymgmt_tofree = tmp_keymgmt =
|
||||
evp_keymgmt_fetch_from_prov((OSSL_PROVIDER *)tmp_prov,
|
||||
EVP_KEYMGMT_get0_name(ctx->keymgmt),
|
||||
ctx->propquery);
|
||||
if (tmp_keymgmt != NULL)
|
||||
provkey = evp_pkey_export_to_provider(ctx->pkey, ctx->libctx,
|
||||
&tmp_keymgmt, ctx->propquery);
|
||||
if (tmp_keymgmt == NULL)
|
||||
EVP_KEYMGMT_free(tmp_keymgmt_tofree);
|
||||
}
|
||||
|
||||
if (provkey == NULL) {
|
||||
EVP_SIGNATURE_free(signature);
|
||||
goto legacy;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we don't have the full support we need with provided methods,
|
||||
* let's go see if legacy does.
|
||||
*/
|
||||
ERR_pop_to_mark();
|
||||
|
||||
/* No more legacy from here down to legacy: */
|
||||
@@ -507,6 +567,8 @@ static int evp_pkey_signature_init(EVP_PKEY_CTX *ctx, int operation,
|
||||
* let's go see if legacy does.
|
||||
*/
|
||||
ERR_pop_to_mark();
|
||||
EVP_KEYMGMT_free(tmp_keymgmt);
|
||||
tmp_keymgmt = NULL;
|
||||
|
||||
if (ctx->pmeth == NULL
|
||||
|| (operation == EVP_PKEY_OP_SIGN && ctx->pmeth->sign == NULL)
|
||||
@@ -545,10 +607,12 @@ static int evp_pkey_signature_init(EVP_PKEY_CTX *ctx, int operation,
|
||||
ret = evp_pkey_ctx_use_cached_data(ctx);
|
||||
#endif
|
||||
|
||||
EVP_KEYMGMT_free(tmp_keymgmt);
|
||||
return ret;
|
||||
err:
|
||||
evp_pkey_ctx_free_old_ops(ctx);
|
||||
ctx->operation = EVP_PKEY_OP_UNDEFINED;
|
||||
EVP_KEYMGMT_free(tmp_keymgmt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -582,7 +646,7 @@ int EVP_PKEY_sign(EVP_PKEY_CTX *ctx,
|
||||
goto legacy;
|
||||
|
||||
ret = ctx->op.sig.signature->sign(ctx->op.sig.algctx, sig, siglen,
|
||||
SIZE_MAX, tbs, tbslen);
|
||||
(sig == NULL) ? 0 : *siglen, tbs, tbslen);
|
||||
|
||||
return ret;
|
||||
legacy:
|
||||
|
||||
+56
-27
@@ -369,12 +369,13 @@ static OSSL_HTTP_REQ_CTX *http_req_ctx_new(int free_wbio, BIO *wbio, BIO *rbio,
|
||||
|
||||
/*
|
||||
* Parse first HTTP response line. This should be like this: "HTTP/1.0 200 OK".
|
||||
* We need to obtain the numeric code and (optional) informational message.
|
||||
* We need to obtain the status code and (optional) informational message.
|
||||
* Return any received HTTP response status code, or 0 on fatal error.
|
||||
*/
|
||||
|
||||
static int parse_http_line1(char *line, int *found_keep_alive)
|
||||
{
|
||||
int i, retcode;
|
||||
int i, retcode, err;
|
||||
char *code, *reason, *end;
|
||||
|
||||
if (!HAS_PREFIX(line, HTTP_PREFIX_VERSION))
|
||||
@@ -430,22 +431,21 @@ static int parse_http_line1(char *line, int *found_keep_alive)
|
||||
case HTTP_STATUS_CODE_FOUND:
|
||||
return retcode;
|
||||
default:
|
||||
err = HTTP_R_RECEIVED_ERROR;
|
||||
if (retcode < 400)
|
||||
retcode = HTTP_R_STATUS_CODE_UNSUPPORTED;
|
||||
else
|
||||
retcode = HTTP_R_RECEIVED_ERROR;
|
||||
err = HTTP_R_STATUS_CODE_UNSUPPORTED;
|
||||
if (*reason == '\0')
|
||||
ERR_raise_data(ERR_LIB_HTTP, retcode, "code=%s", code);
|
||||
ERR_raise_data(ERR_LIB_HTTP, err, "code=%s", code);
|
||||
else
|
||||
ERR_raise_data(ERR_LIB_HTTP, retcode,
|
||||
"code=%s, reason=%s", code, reason);
|
||||
return 0;
|
||||
ERR_raise_data(ERR_LIB_HTTP, err, "code=%s, reason=%s", code,
|
||||
reason);
|
||||
return retcode;
|
||||
}
|
||||
|
||||
err:
|
||||
i = 0;
|
||||
while (i < 60 && ossl_isprint(line[i]))
|
||||
i++;
|
||||
for (i = 0; i < 60 && line[i] != '\0'; i++)
|
||||
if (!ossl_isprint(line[i]))
|
||||
line[i] = ' ';
|
||||
line[i] = '\0';
|
||||
ERR_raise_data(ERR_LIB_HTTP, HTTP_R_HEADER_PARSE_ERROR, "content=%s", line);
|
||||
return 0;
|
||||
@@ -464,6 +464,21 @@ static int check_set_resp_len(OSSL_HTTP_REQ_CTX *rctx, size_t len)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int may_still_retry(time_t max_time, int *ptimeout)
|
||||
{
|
||||
time_t time_diff, now = time(NULL);
|
||||
|
||||
if (max_time != 0) {
|
||||
if (max_time < now) {
|
||||
ERR_raise(ERR_LIB_HTTP, HTTP_R_RETRY_TIMEOUT);
|
||||
return 0;
|
||||
}
|
||||
time_diff = max_time - now;
|
||||
*ptimeout = time_diff > INT_MAX ? INT_MAX : (int)time_diff;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Try exchanging request and response via HTTP on (non-)blocking BIO in rctx.
|
||||
* Returns 1 on success, 0 on error or redirection, -1 on BIO_should_retry.
|
||||
@@ -474,7 +489,7 @@ int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx)
|
||||
long n;
|
||||
size_t resp_len;
|
||||
const unsigned char *p;
|
||||
char *key, *value, *line_end = NULL;
|
||||
char *buf, *key, *value, *line_end = NULL;
|
||||
|
||||
if (rctx == NULL) {
|
||||
ERR_raise(ERR_LIB_HTTP, ERR_R_PASSED_NULL_PARAMETER);
|
||||
@@ -487,11 +502,20 @@ int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx)
|
||||
|
||||
rctx->redirection_url = NULL;
|
||||
next_io:
|
||||
buf = (char *)rctx->buf;
|
||||
if ((rctx->state & OHS_NOREAD) == 0) {
|
||||
if (rctx->expect_asn1)
|
||||
if (rctx->expect_asn1) {
|
||||
n = BIO_read(rctx->rbio, rctx->buf, rctx->buf_size);
|
||||
else
|
||||
n = BIO_gets(rctx->rbio, (char *)rctx->buf, rctx->buf_size);
|
||||
} else {
|
||||
(void)ERR_set_mark();
|
||||
n = BIO_gets(rctx->rbio, buf, rctx->buf_size);
|
||||
if (n == -2) { /* unsupported method */
|
||||
(void)ERR_pop_to_mark();
|
||||
n = BIO_get_line(rctx->rbio, buf, rctx->buf_size);
|
||||
} else {
|
||||
(void)ERR_clear_last_mark();
|
||||
}
|
||||
}
|
||||
if (n <= 0) {
|
||||
if (BIO_should_retry(rctx->rbio))
|
||||
return -1;
|
||||
@@ -592,7 +616,7 @@ int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx)
|
||||
}
|
||||
goto next_io;
|
||||
}
|
||||
n = BIO_gets(rctx->mem, (char *)rctx->buf, rctx->buf_size);
|
||||
n = BIO_gets(rctx->mem, buf, rctx->buf_size);
|
||||
|
||||
if (n <= 0) {
|
||||
if (BIO_should_retry(rctx->mem))
|
||||
@@ -610,7 +634,7 @@ int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx)
|
||||
|
||||
/* First line */
|
||||
if (rctx->state == OHS_FIRSTLINE) {
|
||||
switch (parse_http_line1((char *)rctx->buf, &found_keep_alive)) {
|
||||
switch (parse_http_line1(buf, &found_keep_alive)) {
|
||||
case HTTP_STATUS_CODE_OK:
|
||||
rctx->state = OHS_HEADERS;
|
||||
goto next_line;
|
||||
@@ -625,10 +649,10 @@ int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx)
|
||||
/* fall through */
|
||||
default:
|
||||
rctx->state = OHS_ERROR;
|
||||
return 0;
|
||||
goto next_line;
|
||||
}
|
||||
}
|
||||
key = (char *)rctx->buf;
|
||||
key = buf;
|
||||
value = strchr(key, ':');
|
||||
if (value != NULL) {
|
||||
*(value++) = '\0';
|
||||
@@ -684,11 +708,6 @@ int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx)
|
||||
if (*p != '\0') /* not end of headers */
|
||||
goto next_line;
|
||||
|
||||
if (rctx->expected_ct != NULL && !found_expected_ct) {
|
||||
ERR_raise_data(ERR_LIB_HTTP, HTTP_R_MISSING_CONTENT_TYPE,
|
||||
"expected=%s", rctx->expected_ct);
|
||||
return 0;
|
||||
}
|
||||
if (rctx->keep_alive != 0 /* do not let server initiate keep_alive */
|
||||
&& !found_keep_alive /* otherwise there is no change */) {
|
||||
if (rctx->keep_alive == 2) {
|
||||
@@ -699,6 +718,14 @@ int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx)
|
||||
rctx->keep_alive = 0;
|
||||
}
|
||||
|
||||
if (rctx->state == OHS_ERROR)
|
||||
return 0;
|
||||
|
||||
if (rctx->expected_ct != NULL && !found_expected_ct) {
|
||||
ERR_raise_data(ERR_LIB_HTTP, HTTP_R_MISSING_CONTENT_TYPE,
|
||||
"expected=%s", rctx->expected_ct);
|
||||
return 0;
|
||||
}
|
||||
if (rctx->state == OHS_REDIRECT) {
|
||||
/* http status code indicated redirect but there was no Location */
|
||||
ERR_raise(ERR_LIB_HTTP, HTTP_R_MISSING_REDIRECT_LOCATION);
|
||||
@@ -959,7 +986,7 @@ int OSSL_HTTP_set1_request(OSSL_HTTP_REQ_CTX *rctx, const char *path,
|
||||
return 0;
|
||||
}
|
||||
use_http_proxy = rctx->proxy != NULL && !rctx->use_ssl;
|
||||
if (use_http_proxy && (rctx->server == NULL || rctx->port == NULL)) {
|
||||
if (use_http_proxy && rctx->server == NULL) {
|
||||
ERR_raise(ERR_LIB_HTTP, ERR_R_PASSED_INVALID_ARGUMENT);
|
||||
return 0;
|
||||
}
|
||||
@@ -1069,6 +1096,7 @@ BIO *OSSL_HTTP_get(const char *url, const char *proxy, const char *no_proxy,
|
||||
int use_ssl;
|
||||
OSSL_HTTP_REQ_CTX *rctx;
|
||||
BIO *resp = NULL;
|
||||
time_t max_time = timeout > 0 ? time(NULL) + timeout : 0;
|
||||
|
||||
if (url == NULL) {
|
||||
ERR_raise(ERR_LIB_HTTP, ERR_R_PASSED_NULL_PARAMETER);
|
||||
@@ -1099,7 +1127,8 @@ BIO *OSSL_HTTP_get(const char *url, const char *proxy, const char *no_proxy,
|
||||
}
|
||||
OPENSSL_free(path);
|
||||
if (resp == NULL && redirection_url != NULL) {
|
||||
if (redirection_ok(++n_redirs, current_url, redirection_url)) {
|
||||
if (redirection_ok(++n_redirs, current_url, redirection_url)
|
||||
&& may_still_retry(max_time, &timeout)) {
|
||||
(void)BIO_reset(bio);
|
||||
OPENSSL_free(current_url);
|
||||
current_url = redirection_url;
|
||||
|
||||
+1
@@ -55,6 +55,7 @@ static const ERR_STRING_DATA HTTP_str_reasons[] = {
|
||||
"response line too long"},
|
||||
{ERR_PACK(ERR_LIB_HTTP, 0, HTTP_R_RESPONSE_PARSE_ERROR),
|
||||
"response parse error"},
|
||||
{ERR_PACK(ERR_LIB_HTTP, 0, HTTP_R_RETRY_TIMEOUT), "retry timeout"},
|
||||
{ERR_PACK(ERR_LIB_HTTP, 0, HTTP_R_SERVER_CANCELED_CONNECTION),
|
||||
"server canceled connection"},
|
||||
{ERR_PACK(ERR_LIB_HTTP, 0, HTTP_R_SOCK_NOT_SUPPORTED),
|
||||
|
||||
+15
@@ -309,11 +309,23 @@ void ossl_ctx_thread_stop(OSSL_LIB_CTX *ctx)
|
||||
static void init_thread_stop(void *arg, THREAD_EVENT_HANDLER **hands)
|
||||
{
|
||||
THREAD_EVENT_HANDLER *curr, *prev = NULL, *tmp;
|
||||
#ifndef FIPS_MODULE
|
||||
GLOBAL_TEVENT_REGISTER *gtr;
|
||||
#endif
|
||||
|
||||
/* Can't do much about this */
|
||||
if (hands == NULL)
|
||||
return;
|
||||
|
||||
#ifndef FIPS_MODULE
|
||||
gtr = get_global_tevent_register();
|
||||
if (gtr == NULL)
|
||||
return;
|
||||
|
||||
if (!CRYPTO_THREAD_write_lock(gtr->lock))
|
||||
return;
|
||||
#endif
|
||||
|
||||
curr = *hands;
|
||||
while (curr != NULL) {
|
||||
if (arg != NULL && curr->arg != arg) {
|
||||
@@ -332,6 +344,9 @@ static void init_thread_stop(void *arg, THREAD_EVENT_HANDLER **hands)
|
||||
|
||||
OPENSSL_free(tmp);
|
||||
}
|
||||
#ifndef FIPS_MODULE
|
||||
CRYPTO_THREAD_unlock(gtr->lock);
|
||||
#endif
|
||||
}
|
||||
|
||||
int ossl_init_thread_start(const void *index, void *arg,
|
||||
|
||||
+7
-1
@@ -66,8 +66,14 @@ static int obj_name_cmp(const OBJ_NAME *a, const OBJ_NAME *b);
|
||||
static CRYPTO_ONCE init = CRYPTO_ONCE_STATIC_INIT;
|
||||
DEFINE_RUN_ONCE_STATIC(o_names_init)
|
||||
{
|
||||
names_lh = lh_OBJ_NAME_new(obj_name_hash, obj_name_cmp);
|
||||
names_lh = NULL;
|
||||
obj_lock = CRYPTO_THREAD_lock_new();
|
||||
if (obj_lock != NULL)
|
||||
names_lh = lh_OBJ_NAME_new(obj_name_hash, obj_name_cmp);
|
||||
if (names_lh == NULL) {
|
||||
CRYPTO_THREAD_lock_free(obj_lock);
|
||||
obj_lock = NULL;
|
||||
}
|
||||
return names_lh != NULL && obj_lock != NULL;
|
||||
}
|
||||
|
||||
|
||||
+3
-5
@@ -58,13 +58,11 @@ OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, const char *path, OCSP_REQUEST *req)
|
||||
if (ctx == NULL)
|
||||
return NULL;
|
||||
mem = OSSL_HTTP_REQ_CTX_exchange(ctx);
|
||||
resp = (OCSP_RESPONSE *)
|
||||
ASN1_item_d2i_bio(ASN1_ITEM_rptr(OCSP_RESPONSE), mem, NULL);
|
||||
BIO_free(mem);
|
||||
/* ASN1_item_d2i_bio handles NULL bio gracefully */
|
||||
resp = (OCSP_RESPONSE *)ASN1_item_d2i_bio(ASN1_ITEM_rptr(OCSP_RESPONSE),
|
||||
mem, NULL);
|
||||
|
||||
/* this indirectly calls ERR_clear_error(): */
|
||||
OSSL_HTTP_REQ_CTX_free(ctx);
|
||||
|
||||
return resp;
|
||||
}
|
||||
#endif /* !defined(OPENSSL_NO_OCSP) */
|
||||
+6
@@ -204,6 +204,12 @@ int OSSL_PARAM_BLD_push_BN_pad(OSSL_PARAM_BLD *bld, const char *key,
|
||||
OSSL_PARAM_BLD_DEF *pd;
|
||||
|
||||
if (bn != NULL) {
|
||||
if (BN_is_negative(bn)) {
|
||||
ERR_raise_data(ERR_LIB_CRYPTO, ERR_R_UNSUPPORTED,
|
||||
"Negative big numbers are unsupported for OSSL_PARAM");
|
||||
return 0;
|
||||
}
|
||||
|
||||
n = BN_num_bytes(bn);
|
||||
if (n < 0) {
|
||||
ERR_raise(ERR_LIB_CRYPTO, CRYPTO_R_ZERO_LENGTH_NUMBER);
|
||||
|
||||
Loaded 100 of 509 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user