openssl.git
2 years agoAdapt all public EVP_XXX_do_all_provided() for the changed evp_generic_do_all()
Richard Levitte [Wed, 9 Jun 2021 05:52:09 +0000 (07:52 +0200)]
Adapt all public EVP_XXX_do_all_provided() for the changed evp_generic_do_all()

Fixes #15538
Fixes #14837

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15604)

2 years agoRefactor evp_generic_do_all() to behave like evp_generic_fetch()
Richard Levitte [Wed, 9 Jun 2021 05:50:08 +0000 (07:50 +0200)]
Refactor evp_generic_do_all() to behave like evp_generic_fetch()

This is refactored to use inner_evp_generic_fetch() without any given
name, which is just there to ensure all decoder implementations are
made into methods, and then use ossl_method_store_do_all() to list
them all.

This also adds the internal evp_generic_do_all_prefetched(), which
can be used if pre-fetching needs to be done separately from listing
all the decoder implementations, or if listing may happen multiple
times.

Fixes #15538
Fixes #14837

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15604)

2 years agoRefactor OSSL_ENCODER_do_all_provided() to behave like OSSL_ENCODER_fetch()
Richard Levitte [Wed, 9 Jun 2021 05:47:41 +0000 (07:47 +0200)]
Refactor OSSL_ENCODER_do_all_provided() to behave like OSSL_ENCODER_fetch()

This is refactored to use inner_ossl_encoder_fetch() without any given
name, which is just there to ensure all encoder implementations are
made into methods, and then use ossl_method_store_do_all() to list
them all.

This also adds the internal ossl_encoder_do_all_prefetched(), which
can be used if pre-fetching needs to be done separately from listing
all the encoder implementations, or if listing may happen multiple
times.

Fixes #15538
Fixes #14837

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15604)

2 years agoRefactor OSSL_DECODER_do_all_provided() to behave like OSSL_DECODER_fetch()
Richard Levitte [Fri, 4 Jun 2021 12:29:07 +0000 (14:29 +0200)]
Refactor OSSL_DECODER_do_all_provided() to behave like OSSL_DECODER_fetch()

This is refactored to use inner_ossl_decoder_fetch() without any given
name, which is just there to ensure all decoder implementations are
made into methods, and then use ossl_method_store_do_all() to list
them all.

This also adds the internal ossl_decoder_do_all_prefetched(), which
can be used if pre-fetching needs to be done separately from listing
all the decoder implementations, or if listing may happen multiple
times.

Fixes #15538
Fixes #14837

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15604)

2 years agoAdd the internal function ossl_method_store_do_all()
Richard Levitte [Thu, 3 Jun 2021 07:09:19 +0000 (09:09 +0200)]
Add the internal function ossl_method_store_do_all()

It will simply call the given callback for every method found in the
given store.

Fixes #15538
Fixes #14837

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15604)

2 years agos_server: make -rev option easier to find (mention echo)
Hubert Kario [Mon, 14 Jun 2021 11:38:02 +0000 (13:38 +0200)]
s_server: make -rev option easier to find (mention echo)

Since the service is echo-like (see TCP port 7 from RFC 862 or
gnutls-serv --echo), make it easier to find by mentioning "echo" in
the description of it in the help message an man page

Also fixes the man page inconsistency ("sends it back to the server")

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/15739)

2 years agoCORE: Move away the allocation of the temporary no_cache method store
Richard Levitte [Mon, 14 Jun 2021 07:25:53 +0000 (09:25 +0200)]
CORE: Move away the allocation of the temporary no_cache method store

The responsibility for managing the temporary store for methods from
algorithm implementations flaged "no_store" is moved up to the diverse
method fetching functions.  This allows them to allocate it "just in
time", or in other words not at all if there is not such algorithm
implementation.

This makes this temporary store more flexible if it's needed outside
of the core fetching functionality, and slightly faster when this
temporary store isn't necessary at all.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15737)

2 years agoASN1_parse_dump(): allow NULL BIO input, to simplify applications not needing output
Dr. David von Oheimb [Mon, 14 Jun 2021 10:58:40 +0000 (12:58 +0200)]
ASN1_parse_dump(): allow NULL BIO input, to simplify applications not needing output

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15722)

2 years agoBIO_write_ex(): Make handing of BIO b == NULL and dlen == 0 less redundant
Dr. David von Oheimb [Sat, 12 Jun 2021 09:49:22 +0000 (11:49 +0200)]
BIO_write_ex(): Make handing of BIO b == NULL and dlen == 0 less redundant

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15722)

2 years agoBIO: Make source file names in crypto/bio/ consistent
Dr. David von Oheimb [Sat, 12 Jun 2021 11:47:38 +0000 (13:47 +0200)]
BIO: Make source file names in crypto/bio/ consistent

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15722)

2 years agoBIO_dum_indent_cb(): Fix handling of cb return value
Dr. David von Oheimb [Sat, 12 Jun 2021 11:41:19 +0000 (13:41 +0200)]
BIO_dum_indent_cb(): Fix handling of cb return value

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15722)

2 years agofuzz/asn1parse.c: Clean up non-portable code and catch malloc failure
Dr. David von Oheimb [Sat, 12 Jun 2021 09:35:09 +0000 (11:35 +0200)]
fuzz/asn1parse.c: Clean up non-portable code and catch malloc failure

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15722)

2 years agoBIO: prevent crash on NULL BIO for prefix_ctrl() and thus for BIO_set_prefix(), BIO_s...
Dr. David von Oheimb [Sat, 12 Jun 2021 09:27:28 +0000 (11:27 +0200)]
BIO: prevent crash on NULL BIO for prefix_ctrl() and thus for BIO_set_prefix(), BIO_set_indent(), etc.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15722)

2 years agoASN1: rename asn1_par.c to asn1_parse.c for clarity; simplify asn1_parse2()
Dr. David von Oheimb [Sat, 12 Jun 2021 09:25:07 +0000 (11:25 +0200)]
ASN1: rename asn1_par.c to asn1_parse.c for clarity; simplify asn1_parse2()

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15722)

2 years agoUse getauxval on Android with API level > 18
Lars Immisch [Thu, 5 Mar 2020 10:26:06 +0000 (11:26 +0100)]
Use getauxval on Android with API level > 18

We received analytics that devices of the device family Oppo A37x
are crashing with SIGILL when trying to load libcrypto.so.
These crashes were fixed by using the system-supplied getauxval function.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/11257)

2 years agoRemove "-immedate_renegotiation" option
Rich Salz [Sun, 13 Jun 2021 14:49:47 +0000 (10:49 -0400)]
Remove "-immedate_renegotiation" option

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15415)

2 years agoMove AllowClientRenegotiation tests
Rich Salz [Fri, 21 May 2021 17:26:33 +0000 (13:26 -0400)]
Move AllowClientRenegotiation tests

Move them from test_renegotiation to renegotiation in ssl_new

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15415)

2 years agoremove end of line whitespace
Pauli [Tue, 15 Jun 2021 09:01:00 +0000 (19:01 +1000)]
remove end of line whitespace

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
2 years agocms: free PKEY_CTX
Pauli [Mon, 14 Jun 2021 11:22:55 +0000 (21:22 +1000)]
cms: free PKEY_CTX

Preventing a memory leak.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/15731)

2 years agocms: fix coverity 1485981: unchecked return value
Pauli [Sun, 13 Jun 2021 23:50:36 +0000 (09:50 +1000)]
cms: fix coverity 1485981: unchecked return value

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/15731)

2 years agoapps: move global libctx and property query into their own file
Pauli [Thu, 10 Jun 2021 06:58:12 +0000 (16:58 +1000)]
apps: move global libctx and property query into their own file

The header has been split out so the functions should be as well.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15687)

2 years agospeed: make sure to free any allocated EVP_MAC structures
Pauli [Thu, 10 Jun 2021 02:05:28 +0000 (12:05 +1000)]
speed: make sure to free any allocated EVP_MAC structures

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15687)

2 years agopkcs12: use the app's libctx and property query when searching for algorithms
Pauli [Thu, 10 Jun 2021 01:27:44 +0000 (11:27 +1000)]
pkcs12: use the app's libctx and property query when searching for algorithms

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15687)

2 years agospeed: use the app's libctx and property query when searching for algorithms
Pauli [Thu, 10 Jun 2021 01:27:31 +0000 (11:27 +1000)]
speed: use the app's libctx and property query when searching for algorithms

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15687)

2 years agolist: use the app's libctx and property query when searching for algorithms
Pauli [Thu, 10 Jun 2021 00:26:43 +0000 (10:26 +1000)]
list: use the app's libctx and property query when searching for algorithms

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15687)

2 years agokdf: use the app's libctx and property query when searching for algorithms
Pauli [Thu, 10 Jun 2021 00:26:43 +0000 (10:26 +1000)]
kdf: use the app's libctx and property query when searching for algorithms

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15687)

2 years agofipsinstall: use the app's libctx and property query when searching for algorithms
Pauli [Thu, 10 Jun 2021 00:26:43 +0000 (10:26 +1000)]
fipsinstall: use the app's libctx and property query when searching for algorithms

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15687)

2 years agoadd libctx and property query to fetch functions
Pauli [Thu, 10 Jun 2021 01:35:26 +0000 (11:35 +1000)]
add libctx and property query to fetch functions

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15687)

2 years agotest: add SPKAC command test
Pauli [Thu, 10 Jun 2021 00:48:51 +0000 (10:48 +1000)]
test: add SPKAC command test

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15687)

2 years agospkac: document -digest option
Pauli [Thu, 10 Jun 2021 00:33:13 +0000 (10:33 +1000)]
spkac: document -digest option

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15687)

2 years agospkac: allow digests other than MD5 to be used for signing
Pauli [Thu, 10 Jun 2021 00:06:20 +0000 (10:06 +1000)]
spkac: allow digests other than MD5 to be used for signing

Fixes #15683

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15687)

2 years agoAdd missing NULL check in OSSL_DECODER_from_bio().
Shane Lontis [Mon, 14 Jun 2021 06:43:28 +0000 (16:43 +1000)]
Add missing NULL check in OSSL_DECODER_from_bio().

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15733)

2 years agoAvoid excessive OSSL_DECODER_do_all_provided calls
Matt Caswell [Fri, 11 Jun 2021 11:43:00 +0000 (12:43 +0100)]
Avoid excessive OSSL_DECODER_do_all_provided calls

OSSL_DECODER_CTX_add_extra was calling OSSL_DECODER_do_all_provided in a
loop which was resulting in a large number of calls. Since
OSSL_DECODER_do_all_provided is quite "heavy" this was causing performance
issues.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15716)

2 years agoAdd a generic SubjectPublicKeyInfo decoder
Matt Caswell [Tue, 8 Jun 2021 10:49:06 +0000 (11:49 +0100)]
Add a generic SubjectPublicKeyInfo decoder

Previously all the SubjectPublicKeyInfo decoders were specific to a key
type. We would iterate over all them until a match was found for the correct
key type. Each one would fully decode the key before then testing whether
it was a match or not - throwing it away if not. This was very inefficient.

Instead we introduce a generic SubjectPublicKeyInfo decoder which figures
out what type of key is contained within it, before subsequently passing on
the data to a key type specific SubjectPublicKeyInfo decoder.

Fixes #15646

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15662)

2 years agoFix DH/DHX named groups to not overwrite the private key length.
Shane Lontis [Thu, 10 Jun 2021 08:14:03 +0000 (18:14 +1000)]
Fix DH/DHX named groups to not overwrite the private key length.

The only reason(s) the DH private key length should be set are:
(1) The user sets it during key generation via EVP_PKEY_CTX_set_params
    using OSSL_PKEY_PARAM_DH_PRIV_LEN.
(2) When loading a PKCS3 (DH) key the optional value
    'privateValueLength' is set.

Now that the named groups contain a value for 'q' there is no reason to
automatically overwrite the private key length.

Issue detected by @davidmakepeace

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15695)

2 years agoWhen linking to static libssl always link to static libcrypto
Tomas Mraz [Fri, 11 Jun 2021 10:32:39 +0000 (12:32 +0200)]
When linking to static libssl always link to static libcrypto

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15714)

2 years agoDo not duplicate symbols between libcrypto and libssl in static builds
Tomas Mraz [Fri, 11 Jun 2021 09:18:54 +0000 (11:18 +0200)]
Do not duplicate symbols between libcrypto and libssl in static builds

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15714)

2 years agoAdd -latomic only for architectures where needed
Tomas Mraz [Mon, 7 Jun 2021 06:54:20 +0000 (08:54 +0200)]
Add -latomic only for architectures where needed

Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15640)

2 years agoAvoid duplicating prov_running.o in libdefault and libcrypto
Tomas Mraz [Thu, 10 Jun 2021 16:27:02 +0000 (18:27 +0200)]
Avoid duplicating prov_running.o in libdefault and libcrypto

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15704)

2 years agoAPPS: Remove an unreachable statement in s_client.c
Richard Levitte [Fri, 11 Jun 2021 16:11:07 +0000 (18:11 +0200)]
APPS: Remove an unreachable statement in s_client.c

A Solaris compiler complains:

    "apps/s_client.c", line 2994: statement not reached

It takes a bit of scrutiny to see that this is true, on all platforms.

Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15719)

2 years agoAdd AES consttime code for no-asm configurations
Bernd Edlinger [Thu, 9 Jan 2020 22:02:54 +0000 (23:02 +0100)]
Add AES consttime code for no-asm configurations

This adds optional constant time support for AES
when building openssl for no-asm.

Enable with: ./config no-asm -DOPENSSL_AES_CONST_TIME
Disable with: ./config no-asm -DOPENSSL_NO_AES_CONST_TIME

This is by default enabled.

[extended tests]

Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/10828)

2 years agoci: run the on pull request CIs on push to master
Pauli [Fri, 11 Jun 2021 05:13:02 +0000 (15:13 +1000)]
ci: run the on pull request CIs on push to master

This will help catch problems caused by merging.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15711)

2 years agod2i_X509: revert calling X509v3_cache_extensions()
Dr. David von Oheimb [Thu, 10 Jun 2021 17:36:35 +0000 (19:36 +0200)]
d2i_X509: revert calling X509v3_cache_extensions()

Fixes #13754

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15705)

2 years agoWindows GitHub CI: Introduce --strict-warnings
Richard Levitte [Fri, 11 Jun 2021 02:30:22 +0000 (04:30 +0200)]
Windows GitHub CI: Introduce --strict-warnings

This involves making a more comprehensive matrix for the different
architectures we build for.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15709)

2 years agoWindows Github CI: test in Windows 2016 as well
Richard Levitte [Fri, 11 Jun 2021 01:58:49 +0000 (03:58 +0200)]
Windows Github CI: test in Windows 2016 as well

This brings an older version of MSVC, which may bring some "interesting"
failures.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15709)

2 years agoBuilding: Add necessary dependencies for linker scripts and .rc files
Richard Levitte [Fri, 11 Jun 2021 15:22:44 +0000 (17:22 +0200)]
Building: Add necessary dependencies for linker scripts and .rc files

These files depend on the data from configdata.pm, so need a dependency
on that one to always be properly updated.  The same goes for .rc files.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15717)

2 years agoConfigure: Allow spaces around '=' in all build.info statements
Richard Levitte [Thu, 10 Jun 2021 07:15:58 +0000 (09:15 +0200)]
Configure: Allow spaces around '=' in all build.info statements

This was allowed already for some statements, but not consistently for all.

Fixes #15684

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15691)

2 years agoRename OSSL_HTTP_set_request() to OSSL_HTTP_set1_request() for clarity
Dr. David von Oheimb [Wed, 9 Jun 2021 07:40:48 +0000 (09:40 +0200)]
Rename OSSL_HTTP_set_request() to OSSL_HTTP_set1_request() for clarity

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15697)

2 years agoHTTP client: Fix GET request handling when rctx is reused (keep-alive)
Dr. David von Oheimb [Wed, 9 Jun 2021 07:35:32 +0000 (09:35 +0200)]
HTTP client: Fix GET request handling when rctx is reused (keep-alive)

This also updates the documentation of OSSL_HTTP_REQ_CTX_set1_req().

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15697)

2 years agoAdd support for ISO 8601 datetime format
William Edmisten [Mon, 1 Mar 2021 23:33:29 +0000 (18:33 -0500)]
Add support for ISO 8601 datetime format

Fixes #5430

Added the configuration file option "date_opt" to the openssl applications ca,
crl and x509.
Added ASN1_TIME_print_ex which supports the new datetime format using the
flag ASN1_DTFLGS_ISO8601

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14384)

2 years agoUpdate krb5 module and re-enable pkinit tests
Robbie Harwood [Mon, 24 May 2021 21:11:53 +0000 (17:11 -0400)]
Update krb5 module and re-enable pkinit tests

pkinit tests were disabled in cd0aca532091de4dfadf2f12b18dd99e9cba7615

Signed-off-by: Robbie Harwood <rharwood@redhat.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15444)

2 years agoDo not depend on the exact exit failure value of dgst app
Tomas Mraz [Thu, 10 Jun 2021 07:58:43 +0000 (09:58 +0200)]
Do not depend on the exact exit failure value of dgst app

On most platforms the EXIT_FAILURE is 1 but on NonStop platform
the EXIT_FAILURE is -1 truncated to 255.

Fixes #15633

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15694)

2 years agoClean away remaining Travis related files
Richard Levitte [Thu, 10 Jun 2021 07:41:22 +0000 (09:41 +0200)]
Clean away remaining Travis related files

Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15692)

2 years agofuzz/asn1parse: Use BIO_s_mem() as fallback output
Tomas Mraz [Thu, 10 Jun 2021 14:55:37 +0000 (16:55 +0200)]
fuzz/asn1parse: Use BIO_s_mem() as fallback output

/dev/null is not available everywhere.

Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15672)

2 years agoBIO_write_ex: No error only on 0 bytes to write
Tomas Mraz [Wed, 9 Jun 2021 11:48:21 +0000 (13:48 +0200)]
BIO_write_ex: No error only on 0 bytes to write

Fixes #15682

Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15672)

2 years agoWindows CI: Enable fuzz test in plain build
Tomas Mraz [Wed, 9 Jun 2021 10:27:51 +0000 (12:27 +0200)]
Windows CI: Enable fuzz test in plain build

Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15672)

2 years agoapps/lib/s_socket.c: Alias getpid with _getpid for _WIN32
Richard Levitte [Fri, 11 Jun 2021 02:55:03 +0000 (04:55 +0200)]
apps/lib/s_socket.c: Alias getpid with _getpid for _WIN32

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15710)

2 years agoFix FIPS provider value in docs
Todd Short [Wed, 9 Jun 2021 14:03:10 +0000 (10:03 -0400)]
Fix FIPS provider value in docs

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15676)

2 years agoSTORE: Make OSSL_STORE_LOADER_fetch() consistent with all other fetch functions
Richard Levitte [Thu, 10 Jun 2021 05:25:56 +0000 (07:25 +0200)]
STORE: Make OSSL_STORE_LOADER_fetch() consistent with all other fetch functions

The argument order was different on this one.

Fixes #15688

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15689)

2 years agoDocument that provider name can be a full path
Tomas Mraz [Wed, 9 Jun 2021 15:04:12 +0000 (17:04 +0200)]
Document that provider name can be a full path

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15680)

2 years agodl_name_converter: Avoid unnecessary overallocation
Tomas Mraz [Wed, 9 Jun 2021 14:42:35 +0000 (16:42 +0200)]
dl_name_converter: Avoid unnecessary overallocation

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15680)

2 years agoossl_provider_set_module_path: Prevent potential UAF
Tomas Mraz [Wed, 9 Jun 2021 14:27:05 +0000 (16:27 +0200)]
ossl_provider_set_module_path: Prevent potential UAF

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15680)

2 years agoOpenSSL::Test: If __cwd() is to create the directory, do it early
Richard Levitte [Thu, 10 Jun 2021 14:43:27 +0000 (16:43 +0200)]
OpenSSL::Test: If __cwd() is to create the directory, do it early

This is to ensure that abs_path() has an existing directory to look at.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15701)

2 years agoFix s_server app to not report an error when using a non DH certificate.
Shane Lontis [Wed, 9 Jun 2021 07:34:55 +0000 (17:34 +1000)]
Fix s_server app to not report an error when using a non DH certificate.

Fixes #15071

It always tries loading the cert as DH which previously did not produce
an error. The errors are not suppressed for these operations.
The output now matches previous versions of OpenSSL.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15670)

2 years agoOpenSSL::Test: Treat SRCDATA directory specially, as it might not exist
Richard Levitte [Thu, 10 Jun 2021 11:00:54 +0000 (13:00 +0200)]
OpenSSL::Test: Treat SRCDATA directory specially, as it might not exist

Not all tests come with a SRCDATA directory.  if it doesn't exist, we
simply drop it from the internal table of directories.

OpenSSL::Test::srcdata_dir() and OpenSSL::Test::srcdata_file() may
return undef in that case.  However, recipes shouldn't try to refer to
a non-existing data directory, so if that happens, it's a programming
error and must be corrected.

Fixes #15679

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15700)

2 years agodoc: fix OSSL_PARAM_BLD pointers in the example
Petr Gotthard [Tue, 8 Jun 2021 17:57:48 +0000 (19:57 +0200)]
doc: fix OSSL_PARAM_BLD pointers in the example

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15663)

2 years agostore: Avoid spurious error from decoding at EOF
Tomas Mraz [Tue, 8 Jun 2021 16:25:09 +0000 (18:25 +0200)]
store: Avoid spurious error from decoding at EOF

Fixes #15596

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15661)

2 years agoEnable ssl-trace by default
Arran Cudbard-Bell [Tue, 8 Jun 2021 21:45:38 +0000 (16:45 -0500)]
Enable ssl-trace by default

There doesn't appear to be a good reason to omit protocol message tracing by default.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15665)

2 years agoOptimize session cache flushing
Todd Short [Fri, 5 Apr 2019 18:17:22 +0000 (14:17 -0400)]
Optimize session cache flushing

Sort SSL_SESSION structures by timeout in the linked list.
Iterate over the linked list for timeout, stopping when no more
session can be flushed.
Do SSL_SESSION_free() outside of SSL_CTX lock
Update timeout upon use

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8687)

2 years agoFix use after free in OSSL_HTTP_REQ_CTX_set1_req()
Tomas Mraz [Mon, 7 Jun 2021 14:56:20 +0000 (16:56 +0200)]
Fix use after free in OSSL_HTTP_REQ_CTX_set1_req()

Fixes #15647

Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15648)

2 years agoerr: clear flags better when clearing errors.
Pauli [Wed, 9 Jun 2021 01:58:48 +0000 (11:58 +1000)]
err: clear flags better when clearing errors.

An attempt to clear an error with malloced data didn't clear the flags.
Now it clears all flags except the malloced flag.

Fixes #12530

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15667)

2 years agoAPPS: Restore the possibility to combine -pubout with -text
Richard Levitte [Tue, 8 Jun 2021 10:22:31 +0000 (12:22 +0200)]
APPS: Restore the possibility to combine -pubout with -text

This applies to the 'openssl pkey' command.

Fixes #15645

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15658)

2 years agoutil: convert SHA* one shots back to being functions
Pauli [Wed, 9 Jun 2021 03:40:54 +0000 (13:40 +1000)]
util: convert SHA* one shots back to being functions

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/15668)

2 years agochanges: fix woring that mentions SHA* one shot functions are deprecated
Pauli [Wed, 9 Jun 2021 03:40:27 +0000 (13:40 +1000)]
changes: fix woring that mentions SHA* one shot functions are deprecated

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/15668)

2 years agosha: convert SHA one shot macros back to being functions
Pauli [Wed, 9 Jun 2021 03:38:30 +0000 (13:38 +1000)]
sha: convert SHA one shot macros back to being functions

Fixes #15655

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/15668)

2 years agoDECODER & ENCODER: Add better tracing
Richard Levitte [Thu, 27 May 2021 10:51:04 +0000 (12:51 +0200)]
DECODER & ENCODER: Add better tracing

Now that we have functions to get the name and properties of the
diverse implementations, we can as well display them for clarity.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15498)

2 years agoDECODER: Adapt addition of extra decoder implementations
Richard Levitte [Thu, 27 May 2021 10:44:19 +0000 (12:44 +0200)]
DECODER: Adapt addition of extra decoder implementations

The new PKCS#8 decoder implementation decodes from DER to DER.
OSSL_DECODER_CTX_add_extra() wasn't suited for this case; we had to
modify it to walk through all existing decoder implementations, and
filter out those that aren't suitable.
This also turns out to fix the possibility to have more than one extra
decoder implementation that produces the same type of encoding, for
example several different wrapper formats that all decoder into DER.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15498)

2 years agoDecoding PKCS#8: separate decoding of encrypted and unencrypted PKCS#8
Richard Levitte [Thu, 27 May 2021 10:34:03 +0000 (12:34 +0200)]
Decoding PKCS#8: separate decoding of encrypted and unencrypted PKCS#8

This has us switch from the 'structure' "pkcs8" to "PrivateKeyInfo",
which is sensible considering we already have "SubjectPublicKeyInfo".
We also add "EncryptedPrivateKeyInfo", and use it for a special decoder
that detects and decrypts an EncryptedPrivateKeyInfo structured DER
blob into a PrivateKeyInfo structured DER blob and passes that on to
the next decoder implementation.

The result of this change is that PKCS#8 decryption should only happen
once per decoding instead of once for every expected key type.
Furthermore, this new decoder implementation sets the data type to the
OID of the algorithmIdentifier field, thus reducing how many decoder
implementations are tentativaly run further down the call chain.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15498)

2 years ago25-test_verify.t: Add test case: accept trusted self-signed EE cert with key usage...
Dr. David von Oheimb [Tue, 8 Jun 2021 09:54:20 +0000 (11:54 +0200)]
25-test_verify.t: Add test case: accept trusted self-signed EE cert with key usage keyCertSign also when strict

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15656)

2 years agotest/certs/mkcert.sh: Correct description of geneealt parameters
Dr. David von Oheimb [Tue, 8 Jun 2021 09:23:34 +0000 (11:23 +0200)]
test/certs/mkcert.sh: Correct description of geneealt parameters

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15656)

2 years ago25-test_verify.t: Prevent expiration of test case 'Name constraints bad othername...
Dr. David von Oheimb [Mon, 7 Jun 2021 10:16:25 +0000 (12:16 +0200)]
25-test_verify.t: Prevent expiration of test case 'Name constraints bad othername name constraint'

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15656)

2 years ago80-test_cmp_http.t: Improve the way the test server is launched and killed
Dr. David von Oheimb [Mon, 7 Jun 2021 09:50:43 +0000 (11:50 +0200)]
80-test_cmp_http.t: Improve the way the test server is launched and killed

Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15642)

2 years ago80-test_cmp_http.t: Simplify and prevent hangs on server not launching/behaving correctly
Dr. David von Oheimb [Mon, 7 Jun 2021 09:44:23 +0000 (11:44 +0200)]
80-test_cmp_http.t: Simplify and prevent hangs on server not launching/behaving correctly

Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15642)

2 years agoRemove I_CAN_LIVE_WITH_LNK4049
Rich Salz [Mon, 7 Jun 2021 16:06:26 +0000 (12:06 -0400)]
Remove I_CAN_LIVE_WITH_LNK4049

Fixes #9332

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15649)

2 years agokeymgmt: better detect when a key manager can be reused
Pauli [Tue, 8 Jun 2021 03:50:38 +0000 (13:50 +1000)]
keymgmt: better detect when a key manager can be reused

Fixes #14159

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15652)

2 years agoOpenSSL::Test.pm: Replace all uses of rel2abs() with abs_path()
Richard Levitte [Mon, 7 Jun 2021 12:10:17 +0000 (14:10 +0200)]
OpenSSL::Test.pm: Replace all uses of rel2abs() with abs_path()

rel2abs() doesn't clean the path well enough, which may lead to odd
results when calculating new paths.  abs_path() works better for this
sort of thing.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15644)

2 years agoCorrectly detect decode errors when checking if a key is supported
Matt Caswell [Mon, 7 Jun 2021 13:54:24 +0000 (14:54 +0100)]
Correctly detect decode errors when checking if a key is supported

If we have an unsupported key type we may get a decode error and
therefore we should detect that.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15504)

2 years agoSimplify error reporting in X509_PUBKEY_get0()
Matt Caswell [Fri, 4 Jun 2021 13:16:42 +0000 (14:16 +0100)]
Simplify error reporting in X509_PUBKEY_get0()

The X509_PUBKEY_get0() was attempting to recreate any errors that might
have occurred from the earlier decode process when obtaining the EVP_PKEY.
This is brittle at best and the approach would only work with legacy keys.
We remove this and just report an error directly.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15504)

2 years agoUse the fips-and-base.cnf config file in CMP tests
Matt Caswell [Fri, 28 May 2021 13:03:25 +0000 (14:03 +0100)]
Use the fips-and-base.cnf config file in CMP tests

Two CMP tests were using the fips.cnf config file. However to
ensure that decoders are available the fips-and-base.cnf config
file needs to be used instead.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15504)

2 years agoMark some priv/public key paris as only available in the default provider
Matt Caswell [Fri, 28 May 2021 12:39:17 +0000 (13:39 +0100)]
Mark some priv/public key paris as only available in the default provider

Now that we actually load public keys from providers we need to mark some
key paris in the evp tests as only available there. Otherwise we get test
failures when only the FIPS Provider is loaded.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15504)

2 years agoActually use a legacy route in pem_read_bio_key_legacy()
Matt Caswell [Fri, 28 May 2021 10:07:24 +0000 (11:07 +0100)]
Actually use a legacy route in pem_read_bio_key_legacy()

The function pem_read_bio_key_legacy() is a fallback route if we
failed to load a key via a provider. We should be using the legacy
specific d2i functions to force legacy otherwise we end up using a
provider anyway

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15504)

2 years agoJust look for "Unable to load Public Key" if no SM2
Matt Caswell [Thu, 27 May 2021 17:00:07 +0000 (18:00 +0100)]
Just look for "Unable to load Public Key" if no SM2

The X509 test was looking for some specific errors when printing an SM2
X509 certificate when SM2 is disabled. In fact these errors appear in the
middle of the certificate printing which is quite odd. There is also a
separate error "Unable to load Public Key" which is more cleanly printed.

With the recent change to using provided keys in certs the old errors are
no longer output. However printing them in the middle of the cert is
probably not right anyway. So we just rely on the "Unable to load Public
Key" message.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15504)

2 years agoOnly use the legacy route to decode a public key if we have to
Matt Caswell [Thu, 27 May 2021 15:48:37 +0000 (16:48 +0100)]
Only use the legacy route to decode a public key if we have to

We should use a provider to decode a SubjectPublicKeyInfo structure if
we can. We should only use the legacy route if we are forcing legacy, or
if an ENGINE is in use.

Fixes #15393
Fixes #15327

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15504)

2 years agoEnsure that we consume all the data when decoding an SPKI
Matt Caswell [Thu, 27 May 2021 15:47:14 +0000 (16:47 +0100)]
Ensure that we consume all the data when decoding an SPKI

If we are decoding a SubjectPublicKeyInfo structure then we must use all
of the data and must not have bytes "left over".

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15504)

2 years agoUse the right class/tag when decoding an embedded key
Matt Caswell [Thu, 27 May 2021 15:24:00 +0000 (16:24 +0100)]
Use the right class/tag when decoding an embedded key

When a key (SubjectPublicKeyInfo) is embedded in some other structure
it may use an implicit tag. However the decoders can only handle the
universal class and don't know how to interpret the implicit tag.
Therefore we modify the data into a form the decoders can handle.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15504)

2 years agoFix CTLOG_new_from_base64_ex()
Matt Caswell [Tue, 25 May 2021 14:19:56 +0000 (15:19 +0100)]
Fix CTLOG_new_from_base64_ex()

Ensure that the libctx/propq are passed to d2i_PUBKEY_ex()

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15504)

2 years agoFix the expected output of printing certificates
Matt Caswell [Fri, 21 May 2021 16:26:35 +0000 (17:26 +0100)]
Fix the expected output of printing certificates

Now that we are using provided keys when loading a certificate the pretty
printing formatting is cosmetically different. We need to adjust expected
test output accordingly.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15504)

2 years agoEVP_PKEY_new_raw_private_key: Allow zero length keys
Tomas Mraz [Mon, 7 Jun 2021 09:54:04 +0000 (11:54 +0200)]
EVP_PKEY_new_raw_private_key: Allow zero length keys

Allocate at least one byte to distinguish a zero length key
from an unset key.

Fixes #15632

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15643)

2 years agoFix compilation on systems with empty _POSIX_TIMERS
Larkin Nickle [Wed, 2 Jun 2021 18:17:40 +0000 (14:17 -0400)]
Fix compilation on systems with empty _POSIX_TIMERS

Systems such as Tru64 ship with broken headers that
have _POSIX_TIMERS defined but empty.

CLA: trivial

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15598)

2 years agoevp: avoid some calls to EVP_CIPHER_CTX_get_iv_length() because it's been called...
Pauli [Mon, 7 Jun 2021 11:07:21 +0000 (21:07 +1000)]
evp: avoid some calls to EVP_CIPHER_CTX_get_iv_length() because it's been called already

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15635)