openssl.git
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)

2 years agoevp: fix Coverity 1485670 argument cannot be negative
Pauli [Sun, 6 Jun 2021 23:49:04 +0000 (09:49 +1000)]
evp: fix Coverity 1485670 argument cannot be negative

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

2 years agoevp: fix Coverity 1485669 improper use of negative value
Pauli [Sun, 6 Jun 2021 23:45:40 +0000 (09:45 +1000)]
evp: fix Coverity 1485669 improper use of negative value

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

2 years agoevp: fix Coverity 1485668 argument cannot be negative
Pauli [Sun, 6 Jun 2021 23:42:54 +0000 (09:42 +1000)]
evp: fix Coverity 1485668 argument cannot be negative

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

2 years agopkcs12: fix Coverity 1485667 logically dead code
Pauli [Sun, 6 Jun 2021 23:39:55 +0000 (09:39 +1000)]
pkcs12: fix Coverity 1485667 logically dead code

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

2 years agoevp: fix coverity 1485666 argument cannot be negative
Pauli [Sun, 6 Jun 2021 23:36:04 +0000 (09:36 +1000)]
evp: fix coverity 1485666 argument cannot be negative

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

2 years agoevp: fix improper use of negative value issues
Pauli [Sun, 6 Jun 2021 23:28:49 +0000 (09:28 +1000)]
evp: fix improper use of negative value issues

Coverity issues 14856621485663 & 1485664.

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

2 years agoafalg: fix coverity 1485661 improper use of negative value
Pauli [Sun, 6 Jun 2021 23:26:42 +0000 (09:26 +1000)]
afalg: fix coverity 1485661 improper use of negative value

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

2 years agofix coverity 1485660 improper use of negative value
Pauli [Sun, 6 Jun 2021 23:23:41 +0000 (09:23 +1000)]
fix coverity 1485660 improper use of negative value

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

2 years agobio: improve error checking fixing coverity 1485659 & 1485665
Pauli [Sun, 6 Jun 2021 23:20:16 +0000 (09:20 +1000)]
bio: improve error checking fixing coverity 1485659 & 1485665

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

2 years agodoc: add PKEY life cycle documentation
Pauli [Mon, 7 Jun 2021 09:05:54 +0000 (19:05 +1000)]
doc: add PKEY life cycle documentation

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

2 years agodoc: build changes for PKEY life cycle documentation
Pauli [Mon, 7 Jun 2021 09:07:30 +0000 (19:07 +1000)]
doc: build changes for PKEY life cycle documentation

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

2 years agodoc: add build info for cipher life cycle documentation
Pauli [Mon, 7 Jun 2021 05:14:47 +0000 (15:14 +1000)]
doc: add build info for cipher life cycle documentation

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

2 years agodoc: add references to cipher life cycle documentation
Pauli [Mon, 7 Jun 2021 05:14:25 +0000 (15:14 +1000)]
doc: add references to cipher life cycle documentation

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

2 years agodoc: add cipher life cycle documentation
Pauli [Mon, 7 Jun 2021 05:11:28 +0000 (15:11 +1000)]
doc: add cipher life cycle documentation

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

2 years agodoc: improve the cipher life cycle diagram
Pauli [Mon, 7 Jun 2021 04:41:27 +0000 (14:41 +1000)]
doc: improve the cipher life cycle diagram

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

2 years agodoc-nits: support out of source execution
Pauli [Mon, 7 Jun 2021 02:38:25 +0000 (12:38 +1000)]
doc-nits: support out of source execution

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

2 years agodoc: remove empty section
Pauli [Mon, 7 Jun 2021 02:35:06 +0000 (12:35 +1000)]
doc: remove empty section

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

2 years agodoc: add references to digest life cycle documentation
Pauli [Mon, 7 Jun 2021 02:28:29 +0000 (12:28 +1000)]
doc: add references to digest life cycle documentation

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

2 years agodoc: add digest life cycle documentation
Pauli [Mon, 7 Jun 2021 02:28:02 +0000 (12:28 +1000)]
doc: add digest life cycle documentation

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

2 years agodoc: add digest lifecycle diagram
Pauli [Mon, 7 Jun 2021 02:27:39 +0000 (12:27 +1000)]
doc: add digest lifecycle diagram

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

2 years agolife-cycles: update digest state table
Pauli [Mon, 7 Jun 2021 02:27:17 +0000 (12:27 +1000)]
life-cycles: update digest state table

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

2 years agoAdd aix64-gcc-as architecture and p2align callback
Daniel Bevenius [Mon, 7 Jun 2021 04:01:54 +0000 (06:01 +0200)]
Add aix64-gcc-as architecture and p2align callback

This commit adds an architecture named aix64-gcc-as which can generate
assembler source code compatible with AIX assembler (as) instead of the
GNU Assembler (gas). This architecture name is then used in a callback
for the .p2align directive which is not available in AIX as.

The motivation for this addition came out of an issue we ran into when
working on upgrading OpenSSL in Node.js. We ran into the following
compilation error on one of the CI machines that uses AIX:

  05:39:05 Assembler:
  05:39:05 crypto/bn/ppc64-mont-fixed.s: line 4: Error In Syntax

This machine is using AIX Version 7.2 and does not have gas installed
and the .p2align directive is causing this error. After asking around if
it would be possible to install GAS on this machine I learned that AIX
GNU utils are not maintained as well as the native AIX ones and we
(Red Hat/IBM) have run into issues with the GNU utils in the past and if
possible it would be preferable to be able to use the AIX native
assembler.

Refs: https://github.com/nodejs/node/pull/38512

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

2 years agoX509_digest_sig: Handle RSA-PSS and EDDSA certificates
Tomas Mraz [Fri, 4 Jun 2021 11:56:41 +0000 (13:56 +0200)]
X509_digest_sig: Handle RSA-PSS and EDDSA certificates

Identify digest from sigalg params for RSA-PSS and fallback
to SHA-256 for EDDSA.

Fixes #15477

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

2 years agoMove trust-related decls from x509.h.in to x509_vfy.h.in
Dr. David von Oheimb [Thu, 4 Mar 2021 07:47:51 +0000 (08:47 +0100)]
Move trust-related decls from x509.h.in to x509_vfy.h.in

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

2 years agox509.h.in: extended 'documenting' comment on X509_TRUST_OK_ANY_EKU
Dr. David von Oheimb [Thu, 4 Mar 2021 06:36:21 +0000 (07:36 +0100)]
x509.h.in: extended 'documenting' comment on X509_TRUST_OK_ANY_EKU

This hopefully alleviates the fact that the name is unclear/misleading.

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

2 years agoImprove the documentation of cert path building and validation
Dr. David von Oheimb [Wed, 23 Dec 2020 22:29:04 +0000 (23:29 +0100)]
Improve the documentation of cert path building and validation

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

2 years agoX509_STORE_CTX_new.pod and x509_vfy.h.in: rename some params for clarity, improve...
Dr. David von Oheimb [Mon, 4 Jan 2021 07:50:42 +0000 (08:50 +0100)]
X509_STORE_CTX_new.pod and x509_vfy.h.in: rename some params for clarity, improve their doc

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

2 years agox509_vfy.c: Improve a couple of internally documenting comments
Dr. David von Oheimb [Mon, 4 Jan 2021 07:49:17 +0000 (08:49 +0100)]
x509_vfy.c: Improve a couple of internally documenting comments

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

2 years agox509_trs.c: rename to x509_trust.c and correct comment in trust_compat()
Dr. David von Oheimb [Mon, 4 Jan 2021 07:48:24 +0000 (08:48 +0100)]
x509_trs.c: rename to x509_trust.c and correct comment in trust_compat()

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

2 years agoFix AIX FIPS DEP.
Shane Lontis [Mon, 7 Jun 2021 01:33:28 +0000 (11:33 +1000)]
Fix AIX FIPS DEP.

The entry point needs the option 'binitfini', but it was not being
added since the perl code to detect the match did not work.

The entry point for AIX is no longer static - so a wrapper has been
added to call the static version.

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

2 years agoBIO_write-ex(): Improve behavior in corner cases and documentation
Dr. David von Oheimb [Thu, 3 Jun 2021 10:56:11 +0000 (12:56 +0200)]
BIO_write-ex(): Improve behavior in corner cases and documentation

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

2 years agoAdd a gettable for provider ciphers to return the EVP_CIPH_RAND_KEY flag
Shane Lontis [Thu, 3 Jun 2021 09:09:38 +0000 (19:09 +1000)]
Add a gettable for provider ciphers to return the EVP_CIPH_RAND_KEY flag

Fixes #15531

DES and TDES set this flag which could possibly be used by applications.
The gettable cipher param OSSL_CIPHER_PARAM_HAS_RAND_KEY has been added.

Note that EVP_CIPHER_CTX_rand_key() uses this flag.

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

2 years agoDocument missing EC/SM2 params
Shane Lontis [Thu, 3 Jun 2021 00:54:13 +0000 (10:54 +1000)]
Document missing EC/SM2 params

Fixes #15548

Document OSSL_PKEY_PARAM_EC_PUB_X, OSSL_PKEY_PARAM_EC_PUB_Y and OSSL_PKEY_PARAM_DEFAULT_DIGEST
Added a section related to parameters for SM2.

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

2 years agoTest EVP_CipherInit sequences and resets
Juergen Christ [Wed, 2 Jun 2021 17:33:50 +0000 (19:33 +0200)]
Test EVP_CipherInit sequences and resets

Various EVP_CipherInit sequences including partial inits and initializations
with different "enc" flags caused problems on s390x.  Similarly, cipher
reinitialization and especially GCM reinitialization with different tag length
led to wrong results.  Add some unit tests to cover these rather exotic use
cases.

Signed-off-by: Juergen Christ <jchrist@linux.ibm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15521)

2 years agoFix CipherInit on s390x.
Juergen Christ [Fri, 28 May 2021 13:02:52 +0000 (15:02 +0200)]
Fix CipherInit on s390x.

Various different initialization sequences led to bugs on s390x due to caching
and processing during key setting.  Since, e.g., the direction does not
necessarily have to be correct during initialization, this produced bugs in
s390x which were not present on other architectures.  Fix this by recomputing
the function codes on the fly during updates and final operations.

Signed-off-by: Juergen Christ <jchrist@linux.ibm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15521)

2 years agoUse rd instead rmdir
FdaSilvaYY [Thu, 3 Jun 2021 14:28:21 +0000 (16:28 +0200)]
Use rd instead rmdir

to avoid collision with rmdir.exe from cygwin or msys

Original idea by Mladen Turk @mturk

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

2 years agoFix generate_ssl_tests.pl
Matt Caswell [Fri, 4 Jun 2021 08:39:32 +0000 (09:39 +0100)]
Fix generate_ssl_tests.pl

Fix the generate_ssl_tests.pl script so that it can be run standalone from
the command line according to the instructions in test/README.ssltest.md

Fixes #11430

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

2 years agoElimination of some sources not needed in the FIPS_MODULE
Tomas Mraz [Fri, 4 Jun 2021 15:01:24 +0000 (17:01 +0200)]
Elimination of some sources not needed in the FIPS_MODULE

Unfortunately in terms of fips.sources this does not mean much
given the way how the .h files are added via the dependency
information from the compiler.

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

2 years agotest/recipes/80-test_cmp_http.t: Don't trust $server_port in start_mock_server()
Richard Levitte [Wed, 2 Jun 2021 19:19:18 +0000 (21:19 +0200)]
test/recipes/80-test_cmp_http.t: Don't trust $server_port in start_mock_server()

Even if $server_port isn't touched, it's still a number coming from
configuration.  It's therefore not trustable as an indicator that the
ACCEPT line delivered a port number or an error indication.

$accept_msg is used instead to capture the port if there is one, and
be a better indicator of error.

Fixes #15557
Fixes #15571

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

2 years agotest/recipes/80-test_cmp_http.t: Simplify test_cmp_http()
Richard Levitte [Wed, 2 Jun 2021 06:14:08 +0000 (08:14 +0200)]
test/recipes/80-test_cmp_http.t: Simplify test_cmp_http()

test_cmp_http() made some assumptions about what values that exit_checker
could get that aren't quite right.

Furthermore, the expected result isn't about exit codes, but about
true or false.  This is better served by getting the value from
OpenSSL::Test::run(), and checking that value against $expected_result
with Test::More::is().

Fixes #15557
Fixes #15571

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

2 years agodoc: update generated image files
Pauli [Fri, 4 Jun 2021 10:14:07 +0000 (20:14 +1000)]
doc: update generated image files

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

2 years agodoc: update Graphviz images to have a transparent background
Pauli [Fri, 4 Jun 2021 10:13:15 +0000 (20:13 +1000)]
doc: update Graphviz images to have a transparent background

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

2 years agoproperty: move additional query functions to property_query.c
Pauli [Fri, 4 Jun 2021 04:35:53 +0000 (14:35 +1000)]
property: move additional query functions to property_query.c

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

2 years agoproperty: improve ossl_property_find_property() function
Pauli [Fri, 4 Jun 2021 04:25:14 +0000 (14:25 +1000)]
property: improve ossl_property_find_property() function

This function searches a property list for a specific property and returns
a pointer to the definition if found.  The existing version was O(n) time,
the improved O(log n).

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

2 years agoRename `n` field to `num_properties` in property definition structure.
Pauli [Fri, 4 Jun 2021 03:19:23 +0000 (13:19 +1000)]
Rename `n` field to `num_properties` in property definition structure.

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

2 years agoPROV: drop get_params() and gettable_params() from all encoder implementatio
Richard Levitte [Wed, 2 Jun 2021 04:49:09 +0000 (06:49 +0200)]
PROV: drop get_params() and gettable_params() from all encoder implementatio

They aren't needed at all any more, since the properties contain the
same information.

This also drops the parameter names OSSL_ENCODER_PARAM_OUTPUT_TYPE
and OSSL_ENCODER_PARAM_OUTPUT_STRUCTURE

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

2 years agoENCODER: use property definitions instead of getting implementation parameters
Richard Levitte [Wed, 2 Jun 2021 04:37:43 +0000 (06:37 +0200)]
ENCODER: use property definitions instead of getting implementation parameters

The OSSL_ENCODER library used to ask each encoder implementation for
certain data in form of parameters to place them correctly in the
encoder chain, if at all.  These parameters were duplicates of
properties of those same implementations, and therefore unnecessarily
redundant.

Now that we have functionality to query property definition values,
those duplicates are no longer needed, and are therefore not looked at
any more.

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

2 years agoENCODER: Drop OSSL_ENCODER_PARAM_INPUT_TYPE
Richard Levitte [Wed, 2 Jun 2021 04:32:00 +0000 (06:32 +0200)]
ENCODER: Drop OSSL_ENCODER_PARAM_INPUT_TYPE

This was a poor substitute for using the name of the decoder implementation,
and since there is functionality to get the latter now, this parameter
can be dropped.

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

2 years agoPROV: drop get_params() and gettable_params() from all decoder implementations
Richard Levitte [Tue, 1 Jun 2021 18:10:45 +0000 (20:10 +0200)]
PROV: drop get_params() and gettable_params() from all decoder implementations

They aren't needed at all any more, since the properties contain the
same information.

This also drops the parameter names OSSL_DECODER_PARAM_INPUT_TYPE
and OSSL_DECODER_PARAM_INPUT_STRUCTURE.

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

2 years agoDECODER: use property definitions instead of getting implementation parameters
Richard Levitte [Tue, 1 Jun 2021 18:04:59 +0000 (20:04 +0200)]
DECODER: use property definitions instead of getting implementation parameters

The OSSL_DECODER library used to ask each decoder implementation for
certain data in form of parameters to place them correctly in the
decoder chain, if at all.  These parameters were duplicates of
properties of those same implementations, and therefore unnecessarily
redundant.

Now that we have functionality to query property definition values,
those duplicates are no longer needed, and are therefore not looked at
any more.

This adds the "global" error reason ERR_R_INVALID_PROPERTY_DEFINITION,
which can be re-used elsewhere.

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

2 years agoproperty: Add functionality to query data from a property definition
Richard Levitte [Tue, 1 Jun 2021 18:02:24 +0000 (20:02 +0200)]
property: Add functionality to query data from a property definition

This required making some OSSL_PROPERTY types a little less private.

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

2 years agomake update-fips-checksums
Richard Levitte [Fri, 4 Jun 2021 08:25:00 +0000 (10:25 +0200)]
make update-fips-checksums

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

2 years agoFIPS: don't include crypto/passphrase.c in libfips.a
Richard Levitte [Fri, 4 Jun 2021 08:19:40 +0000 (10:19 +0200)]
FIPS: don't include crypto/passphrase.c in libfips.a

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

2 years agoAdd documentation for newly added ASN1 functions
Matt Caswell [Tue, 1 Jun 2021 14:17:38 +0000 (15:17 +0100)]
Add documentation for newly added ASN1 functions

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

2 years agoEnsure libctx/propq is propagated when handling X509_REQ
Matt Caswell [Thu, 27 May 2021 14:03:06 +0000 (15:03 +0100)]
Ensure libctx/propq is propagated when handling X509_REQ

When we create via d2i or dup an X509_REQ we should ensure that the libctx
is properly propagated. We also ensure we create X509_REQ objects with the
proper libctx assigned in the CMP tests.

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

2 years agoGive ASN.1 objects the ability to report their libctx/propq
Matt Caswell [Thu, 27 May 2021 09:56:02 +0000 (10:56 +0100)]
Give ASN.1 objects the ability to report their libctx/propq

Some ASN.1 objects have an embedded libctx/propq. If they have one we
give the ASN.1 code the ability to find these values and use them where
needed. This is used for OSSL_CMP_MSG_dup() and X509_dup().

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

2 years agoMake sure X509_dup() also dup's any associated EVP_PKEY
Matt Caswell [Thu, 27 May 2021 08:00:47 +0000 (09:00 +0100)]
Make sure X509_dup() also dup's any associated EVP_PKEY

Otherwise we can end up with a blank EVP_PKEY. If it is later recreated
it can end up with the wrong libctx/propq.

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

2 years agoUse the new ASN.1 libctx aware capabilities in CMP
Matt Caswell [Wed, 26 May 2021 16:18:13 +0000 (17:18 +0100)]
Use the new ASN.1 libctx aware capabilities in CMP

Make sure we pass the libctx/propq around everywhere that we need it to
ensure we get provider keys when needed.

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

2 years agoUse the new ASN.1 libctx aware functions in CMS
Matt Caswell [Tue, 25 May 2021 16:46:11 +0000 (17:46 +0100)]
Use the new ASN.1 libctx aware functions in CMS

Make sure we pass the libctx around when working with CMS structures

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

2 years agoTeach more of the ASN.1 code about libctx/propq
Matt Caswell [Tue, 25 May 2021 16:16:18 +0000 (17:16 +0100)]
Teach more of the ASN.1 code about libctx/propq

Make sure we pass libctx/propq down to all the layers so that objects that
are created during parsing have the right values. Then use this new
capability for PKCS7.

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

2 years agoTeach the ASN.1 code how to create embedded objects with libctx/propq
Matt Caswell [Fri, 21 May 2021 16:25:05 +0000 (17:25 +0100)]
Teach the ASN.1 code how to create embedded objects with libctx/propq

An ASN.1 object such as an X509 may have embedded objects in it such as
an X509_PUBKEY. If there is a libctx/propq in use then we need to make sure
we pass these down to the constructors of these embedded objects.

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

2 years agoFix evp_extra_test to use libctx in an X509_PUBKEY
Matt Caswell [Fri, 21 May 2021 14:50:43 +0000 (15:50 +0100)]
Fix evp_extra_test to use libctx in an X509_PUBKEY

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

2 years agoProvide the ability to create an X509_PUBKEY with a libctx/propq
Matt Caswell [Fri, 21 May 2021 14:50:09 +0000 (15:50 +0100)]
Provide the ability to create an X509_PUBKEY with a libctx/propq

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

2 years agoTest a bad SmtpUTF8Mailbox name constraint
Matt Caswell [Thu, 3 Jun 2021 10:50:48 +0000 (11:50 +0100)]
Test a bad SmtpUTF8Mailbox name constraint

We add a verify test with a cert with a SAN and a bad SmtpUTF8Mailbox
entry, with an intermediate certificate with email name constraints.

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

2 years agoCheck that we got the expected name type when verifying name constraints
Matt Caswell [Thu, 3 Jun 2021 10:08:25 +0000 (11:08 +0100)]
Check that we got the expected name type when verifying name constraints

If a SAN field contains an SmtpUTF8Mailbox name then it is expected to
have a UTF8String type. We should verify that it really does before we
attempt to use the value in it.

Reported by Corey Bonnell

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

2 years agoUpdate fips checksums to drop the ssl headers
Tomas Mraz [Thu, 3 Jun 2021 13:26:52 +0000 (15:26 +0200)]
Update fips checksums to drop the ssl headers

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

2 years agoMove libssl related defines used by fips provider to prov_ssl.h
Tomas Mraz [Thu, 3 Jun 2021 13:22:05 +0000 (15:22 +0200)]
Move libssl related defines used by fips provider to prov_ssl.h

This nicely reduces the number of files considered as fips
provider sources.

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

2 years agoreq: detect a bad choice of digest early
Pauli [Thu, 3 Jun 2021 04:27:28 +0000 (14:27 +1000)]
req: detect a bad choice of digest early

This is a regression against 1.1.1 when an unknown digest was detected
early.

Fixes #15285

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