openssl.git
3 years agoFix coverity CID #1465795 - Incorrect free deallocator used in SSL_add1_host()
Shane Lontis [Tue, 11 Aug 2020 05:21:30 +0000 (15:21 +1000)]
Fix coverity CID #1465795 - Incorrect free deallocator used in SSL_add1_host()

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

3 years agoFix coverity CID #1465797 - Negative loop bound in collect_deserializer
Shane Lontis [Tue, 11 Aug 2020 05:17:17 +0000 (15:17 +1000)]
Fix coverity CID #1465797 - Negative loop bound in collect_deserializer

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

3 years agoFix coverity CID #1465594 - Null dereference in EVP_PKEY_get0()
Shane Lontis [Tue, 11 Aug 2020 05:03:42 +0000 (15:03 +1000)]
Fix coverity CID #1465594 - Null dereference in EVP_PKEY_get0()

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

3 years agorun_tests.pl: Add warning that HARNESS_JOBS > 1 overrides HARNESS_VERBOSE
Dr. David von Oheimb [Wed, 19 Aug 2020 10:23:52 +0000 (12:23 +0200)]
run_tests.pl: Add warning that HARNESS_JOBS > 1 overrides HARNESS_VERBOSE

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12682)

3 years agoFix CMS so that it still works with non fetchable algorithms.
Shane Lontis [Thu, 20 Aug 2020 03:28:11 +0000 (13:28 +1000)]
Fix CMS so that it still works with non fetchable algorithms.

Fixes #12633

For CMS the Gost engine still requires calls to EVP_get_digestbyname() and EVP_get_cipherbyname() when
EVP_MD_fetch() and EVP_CIPHER_fetch() return NULL.

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/12689)

3 years agoWindows get ENV value as UTF-8 encoded string instead of a raw string
Robert Jędrzejczyk [Sat, 22 Aug 2020 05:05:56 +0000 (15:05 +1000)]
Windows get ENV value as UTF-8 encoded string instead of a raw string

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12657)

3 years agoAdd Explicit EC parameter support to providers.
Shane Lontis [Sat, 22 Aug 2020 04:55:41 +0000 (14:55 +1000)]
Add Explicit EC parameter support to providers.

This was added for backward compatability.
Added EC_GROUP_new_from_params() that supports explicit curve parameters.

This fixes the 15-test_genec.t TODO.

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

3 years agoClean away some declarations
Richard Levitte [Thu, 20 Aug 2020 07:33:01 +0000 (09:33 +0200)]
Clean away some declarations

dsa_algorithmidentifier_encoding(), ecdsa_algorithmidentifier_encoding(),
rsa_algorithmidentifier_encoding() have been replaced with DER writer
functions, so they aren't useful any more.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12693)

3 years agoRemove the OSSL_SERIALIZER / OSSL_DESERIALIZER renaming scripts
Richard Levitte [Sun, 16 Aug 2020 19:26:13 +0000 (21:26 +0200)]
Remove the OSSL_SERIALIZER / OSSL_DESERIALIZER renaming scripts

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12660)

3 years agoRename OSSL_SERIALIZER / OSSL_DESERIALIZER to OSSL_ENCODE / OSSL_DECODE
Richard Levitte [Sun, 16 Aug 2020 19:25:08 +0000 (21:25 +0200)]
Rename OSSL_SERIALIZER / OSSL_DESERIALIZER to OSSL_ENCODE / OSSL_DECODE

Fixes #12455

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12660)

3 years agoRename OSSL_SERIALIZER / OSSL_DESERIALIZER to OSSL_ENCODE / OSSL_DECODE
Richard Levitte [Sun, 16 Aug 2020 19:22:02 +0000 (21:22 +0200)]
Rename OSSL_SERIALIZER / OSSL_DESERIALIZER to OSSL_ENCODE / OSSL_DECODE

These are the scripts that do the deed.

Fixes #12455

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12660)

3 years agoAdd libctx/provider support to cmp_msg_test
Dr. David von Oheimb [Tue, 18 Aug 2020 22:48:57 +0000 (00:48 +0200)]
Add libctx/provider support to cmp_msg_test

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11808)

3 years agoAdd libctx/provider support to cmp_protect_test
Dr. David von Oheimb [Tue, 18 Aug 2020 15:14:19 +0000 (17:14 +0200)]
Add libctx/provider support to cmp_protect_test

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11808)

3 years agoAdd libctx/provider support to cmp_vfy_test
Dr. David von Oheimb [Tue, 18 Aug 2020 15:04:54 +0000 (17:04 +0200)]
Add libctx/provider support to cmp_vfy_test

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11808)

3 years agoAdd libctx/provider support to cmp_client_test
Dr. David von Oheimb [Wed, 12 Aug 2020 20:20:23 +0000 (22:20 +0200)]
Add libctx/provider support to cmp_client_test

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11808)

3 years agoUse in CMP+CRMF libctx and propq param added to sign/verify/HMAC/decrypt
Dr. David von Oheimb [Thu, 13 Aug 2020 15:44:54 +0000 (17:44 +0200)]
Use in CMP+CRMF libctx and propq param added to sign/verify/HMAC/decrypt

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11808)

3 years agocmp_msg.c: Copy libctx and propq of CMP_CTX to newly enrolled certificate
Dr. David von Oheimb [Wed, 12 Aug 2020 20:15:24 +0000 (22:15 +0200)]
cmp_msg.c: Copy libctx and propq of CMP_CTX to newly enrolled certificate

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11808)

3 years agocmp_util.c: Add OPENSSL_CTX parameter to ossl_cmp_build_cert_chain(), improve its doc
Dr. David von Oheimb [Wed, 13 May 2020 14:03:26 +0000 (16:03 +0200)]
cmp_util.c: Add OPENSSL_CTX parameter to ossl_cmp_build_cert_chain(), improve its doc

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11808)

3 years agocmp_hdr.c: Adapt ossl_cmp_hdr_init() to use OPENSSL_CTX for random number generation
Dr. David von Oheimb [Wed, 13 May 2020 10:19:16 +0000 (12:19 +0200)]
cmp_hdr.c: Adapt ossl_cmp_hdr_init() to use OPENSSL_CTX for random number generation

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11808)

3 years agocrypto/cmp: Prevent misleading errors in case x509v3_cache_extensions() fails
Dr. David von Oheimb [Wed, 12 Aug 2020 17:16:03 +0000 (19:16 +0200)]
crypto/cmp: Prevent misleading errors in case x509v3_cache_extensions() fails

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11808)

3 years agoAdd libctx/provider support to cmp_server_test
Shane Lontis [Thu, 14 May 2020 02:32:44 +0000 (12:32 +1000)]
Add libctx/provider support to cmp_server_test

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

3 years agoAdd OPENSSL_CTX parameter to OSSL_CRMF_pbmp_new() and improve its doc
Dr. David von Oheimb [Wed, 13 May 2020 09:58:52 +0000 (11:58 +0200)]
Add OPENSSL_CTX parameter to OSSL_CRMF_pbmp_new() and improve its doc

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11808)

3 years agoAdd libctx and propq parameters to OSSL_CMP_{SRV_},CTX_new() and ossl_cmp_mock_srv_new()
Dr. David von Oheimb [Wed, 13 May 2020 07:28:24 +0000 (09:28 +0200)]
Add libctx and propq parameters to OSSL_CMP_{SRV_},CTX_new() and ossl_cmp_mock_srv_new()

Also remove not really to-the-point error message if call fails in apps/cmp.c

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11808)

3 years agocmp_vfy.c: Fix bug: must verify msg signature also in 3GPP mode
Dr. David von Oheimb [Tue, 18 Aug 2020 14:03:29 +0000 (16:03 +0200)]
cmp_vfy.c: Fix bug: must verify msg signature also in 3GPP mode

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11808)

3 years agoUpdate CMP header file references in internal CMP documentation
Dr. David von Oheimb [Wed, 13 May 2020 12:04:18 +0000 (14:04 +0200)]
Update CMP header file references in internal CMP documentation

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11808)

3 years agoAdd libctx and propq param to ASN.1 sign/verify/HMAC/decrypt
Dr. David von Oheimb [Thu, 14 May 2020 19:09:49 +0000 (21:09 +0200)]
Add libctx and propq param to ASN.1 sign/verify/HMAC/decrypt

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11808)

3 years agox_x509.c: Simplify X509_new_with_libctx() using x509_set0_libctx()
Dr. David von Oheimb [Wed, 12 Aug 2020 19:07:12 +0000 (21:07 +0200)]
x_x509.c: Simplify X509_new_with_libctx() using x509_set0_libctx()

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11808)

3 years agoRe-word null->empty property; improve iteration.count example in property.pod
Dr. David von Oheimb [Thu, 14 May 2020 09:27:43 +0000 (11:27 +0200)]
Re-word null->empty property; improve iteration.count example in property.pod

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11808)

3 years agotestutil: Add provider.c with test_get_libctx(), to use at least for SSL and CMP
Dr. David von Oheimb [Wed, 12 Aug 2020 05:46:57 +0000 (07:46 +0200)]
testutil: Add provider.c with test_get_libctx(), to use at least for SSL and CMP

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11808)

3 years agotestutil: Make SETUP_TEST_FIXTURE return 0 on fixture == NULL
Dr. David von Oheimb [Wed, 12 Aug 2020 18:24:26 +0000 (20:24 +0200)]
testutil: Make SETUP_TEST_FIXTURE return 0 on fixture == NULL

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11808)

3 years agoCorrect the #define's of EVP_PKEY_CTRL_SET1_ID and EVP_PKEY_CTRL_GET1_ID{,_LEN}
Dr. David von Oheimb [Fri, 15 May 2020 16:46:59 +0000 (18:46 +0200)]
Correct the #define's of EVP_PKEY_CTRL_SET1_ID and EVP_PKEY_CTRL_GET1_ID{,_LEN}

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11808)

3 years agoAdd prerequisite #include directives to include/crypto/x509.h
Dr. David von Oheimb [Wed, 12 Aug 2020 20:11:42 +0000 (22:11 +0200)]
Add prerequisite #include directives to include/crypto/x509.h

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11808)

3 years agoMake sure x509v3_cache_extensions() does not modify the error queue
Dr. David von Oheimb [Wed, 12 Aug 2020 20:07:51 +0000 (22:07 +0200)]
Make sure x509v3_cache_extensions() does not modify the error queue

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11808)

3 years agoFix incorrect selection flags for ec serializer.
Shane Lontis [Wed, 19 Aug 2020 09:38:03 +0000 (19:38 +1000)]
Fix incorrect selection flags for ec serializer.

Fixes #12630

ec_import requires domain parameters to be part of the selection.
The public and private serialisers were not selecting the correct flags so the import was failing.
Added a test that uses the base provider so that a export/import happens for serialization.

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

3 years agoTest mte with stitched ciphersuites in TLSv1.0
Matt Caswell [Tue, 18 Aug 2020 16:25:51 +0000 (17:25 +0100)]
Test mte with stitched ciphersuites in TLSv1.0

The previous commit fixed a bug with mte, stitched ciphersuites and
TLSv1.0. We now add a test for that scenario.

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

3 years agoFix stitched ciphersuites in TLS1.0
Matt Caswell [Tue, 18 Aug 2020 11:28:45 +0000 (12:28 +0100)]
Fix stitched ciphersuites in TLS1.0

TLS1.0 does not have an explicit IV in the record, and therefore we should
not attempt to remove it.

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

3 years agoMake better use of new load_cert_pass() variant of load_cert() in apps/
Dr. David von Oheimb [Sun, 16 Aug 2020 13:25:27 +0000 (15:25 +0200)]
Make better use of new load_cert_pass() variant of load_cert() in apps/

allows loading password-protected PKCS#12 files in x509, ca, s_client, s_server

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

3 years agoapps: make use of OSSL_STORE for generalized certs and CRLs loading
Dr. David von Oheimb [Fri, 14 Aug 2020 19:58:34 +0000 (21:58 +0200)]
apps: make use of OSSL_STORE for generalized certs and CRLs loading

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

3 years agoFix mem leaks on PKCS#12 read error in PKCS12_key_gen_{asc,utf8}
Dr. David von Oheimb [Wed, 12 Aug 2020 15:37:50 +0000 (17:37 +0200)]
Fix mem leaks on PKCS#12 read error in PKCS12_key_gen_{asc,utf8}

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

3 years agoTEST: Use PEM_read_bio_PUBKEY_ex() and PEM_read_bio_PrivateKey_ex()
Richard Levitte [Tue, 18 Aug 2020 19:45:19 +0000 (21:45 +0200)]
TEST: Use PEM_read_bio_PUBKEY_ex() and PEM_read_bio_PrivateKey_ex()

test/evp_test.c and test/sslapitest.c are affected.  This allows them
to decode keys found in stanza files via provider decoder implementations
when a library context other than the default should be used.

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

3 years agoPEM: Add more library context aware PEM readers
Richard Levitte [Tue, 18 Aug 2020 19:38:56 +0000 (21:38 +0200)]
PEM: Add more library context aware PEM readers

PEM_read_bio_PUBKEY_ex() and PEM_read_bio_Parameters_ex() are added to
complete PEM_read_bio_PrivateKey_ex().  They are all refactored to be
wrappers around the same internal function.

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

3 years agoSTORE: Distinguish public keys from private keys
Richard Levitte [Thu, 30 Jul 2020 08:09:43 +0000 (10:09 +0200)]
STORE: Distinguish public keys from private keys

While public keys and private keys use the same type (EVP_PKEY), just
with different contents, callers still need to distinguish between the
two to be able to know what functions to call with them (for example,
to be able to choose between EVP_PKEY_print_private() and
EVP_PKEY_print_public()).
The OSSL_STORE backend knows what it loaded, so it has the capacity to
inform.

Note that the same as usual still applies, that a private key EVP_PKEY
contains the public parts, but not necessarily the other way around.

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

3 years agoPROV: Fix DSA and DH private key serializers
Richard Levitte [Thu, 30 Jul 2020 08:14:27 +0000 (10:14 +0200)]
PROV: Fix DSA and DH private key serializers

If those private key serializer were given a key structure with just
the public key material, they crashed, because they tried to
de-reference NULL.  This adds better checking.

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

3 years agoX509: Add d2i_PUBKEY_ex(), which take a libctx and propq
Richard Levitte [Tue, 18 Aug 2020 18:39:45 +0000 (20:39 +0200)]
X509: Add d2i_PUBKEY_ex(), which take a libctx and propq

Just like d2i_PrivateKey() / d2i_PrivateKey_ex(), there's a need to
associate an EVP_PKEY extracted from a PUBKEY to a library context and
a property query string.  Without it, a provider-native EVP_PKEY can
only fetch necessary internal algorithms from the default library
context, even though an application specific context should be used.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12671)

3 years agocmp: handle error return from OBJ_obj2txt()
Pauli [Wed, 19 Aug 2020 03:57:00 +0000 (13:57 +1000)]
cmp: handle error return from OBJ_obj2txt()

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

3 years agopkeyutil: check return value reading password
Pauli [Wed, 19 Aug 2020 03:40:22 +0000 (13:40 +1000)]
pkeyutil: check return value reading password

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

3 years agoPROV: Fix EC OSSL_FUNC_keymgmt_match() to work in the FIPS provider
Richard Levitte [Tue, 18 Aug 2020 21:13:29 +0000 (23:13 +0200)]
PROV: Fix EC OSSL_FUNC_keymgmt_match() to work in the FIPS provider

In the FIPS provider, calling EC_GROUP_cmp() with NULL for the BN_CTX
argument is forbidden.  Since that's what ec_match() does, it simply
cannot work in the FIPS provider.  Therefore, we allocate a BN_CTX
with the library context asssociated with one of the input keys
(doesn't matter which) and use that.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12677)

3 years agoRSA: Fix rsa_todata() to only add params for existing data
Richard Levitte [Tue, 18 Aug 2020 21:00:24 +0000 (23:00 +0200)]
RSA: Fix rsa_todata() to only add params for existing data

The RSA key could be a public key, and yet, rsa_todata() always tries
to add the private parts as well.  The resulting parameters will look
a bit odd, such as a zero |d|, resulting in an invalid key.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12676)

3 years agoTEST: separate out NIST ECC tests from non-NIST
Richard Levitte [Tue, 18 Aug 2020 19:17:58 +0000 (21:17 +0200)]
TEST: separate out NIST ECC tests from non-NIST

ECC keys with non-NIST group names aren't supported when running with
the FIPS provider.

Keys with such groups that are included in evp_test stanza files
aren't even possible to decode if provider side decoders are used,
since those depend on available EVP_KEYMGMT implementations and what
they support.

Those keys could only be decoded because the legacy decoders were
used.

To make these tests future proof, we separate out the stanzas having
keys with NIST approved group names into separate files, and adjust
the file lists in test/recipes/30-test_evp.t aaccordingly.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12672)

3 years agoEVP: Have evp_pkey_cmp_any() detect if export wasn't possible
Richard Levitte [Fri, 7 Aug 2020 16:47:04 +0000 (18:47 +0200)]
EVP: Have evp_pkey_cmp_any() detect if export wasn't possible

There are some EC keys that can't be exported to provider keymgmt,
because the keymgmt implementation doesn't support certain forms of EC
keys.  This could lead to a crash caused by dereferencing a NULL
pointer, so we need to cover that case by returning an error instead.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12610)

3 years agoPKCS12_parse(): Clean up code and correct documentation
Dr. David von Oheimb [Fri, 14 Aug 2020 08:24:33 +0000 (10:24 +0200)]
PKCS12_parse(): Clean up code and correct documentation

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

3 years agoPKCS12_parse(): Fix reversed order of certs parsed and output via *ca
Dr. David von Oheimb [Wed, 12 Aug 2020 16:06:00 +0000 (18:06 +0200)]
PKCS12_parse(): Fix reversed order of certs parsed and output via *ca

Fixes #6698

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

3 years agoOSSL_STORE file_load_try_decode(): Avoid flooding error queue by failed tries
Dr. David von Oheimb [Fri, 14 Aug 2020 08:39:17 +0000 (10:39 +0200)]
OSSL_STORE file_load_try_decode(): Avoid flooding error queue by failed tries

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

3 years agoFix no-cms build errors.
Shane Lontis [Wed, 19 Aug 2020 03:27:31 +0000 (13:27 +1000)]
Fix no-cms build errors.

Fixes #12640

The X942-KDF is now indepedent of the CMS code (since it no longer uses CMS_SharedInfo_encode).
Any code related to EVP_PKEY_DH_KDF_X9_42 needs to not be wrapped by !defined(OPENSSL_NO_CMS).

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

3 years agoOCSP: Add return value checks.
Pauli [Sat, 15 Aug 2020 00:35:59 +0000 (10:35 +1000)]
OCSP: Add return value checks.

The calls are unlikely to fail but better checking their return than not.

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

3 years agoApps: change provider_path option to provider-path.
Pauli [Mon, 17 Aug 2020 05:40:00 +0000 (15:40 +1000)]
Apps: change provider_path option to provider-path.

The applications use '-' in options not '_'.

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

3 years agoFix DSA/DH so that legacy keys can still be generated by the default provider
Shane Lontis [Tue, 11 Aug 2020 00:15:28 +0000 (10:15 +1000)]
Fix DSA/DH so that legacy keys can still be generated by the default provider

Fixes #12589

The 'type' parameter needed to be propagated to the ffc params during keygen,
so that the simple validation of params done during keygen can handle legacy keys for the default provider.
The fips provider ignores this change and only allows fips186-4 approved sizes.

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/12623)

3 years agoFix broken windows builds.
Shane Lontis [Mon, 17 Aug 2020 02:34:17 +0000 (12:34 +1000)]
Fix broken windows builds.

A miscellaneous '\' was accidently added to set FIPSKEY=$(FIPSKEY) which was causing some
external CI build loops to not produce test results.
It looks like it was accidently copied from the unix variant which requires the '\'.
Thanks to Wolfgang Beck for tracking down the issue.

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

3 years agoTest that EVP_default_properties_is_fips_enabled() works early
Matt Caswell [Wed, 5 Aug 2020 13:46:48 +0000 (14:46 +0100)]
Test that EVP_default_properties_is_fips_enabled() works early

We check that EVP_default_properties_is_fips_enabled() is working even
before other function calls have auto-loaded the config file.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12567)

3 years agoLoad the default config file before working with default properties
Matt Caswell [Fri, 31 Jul 2020 16:29:21 +0000 (17:29 +0100)]
Load the default config file before working with default properties

A config file can change the global default properties. Therefore we
must ensure that the config file is loaded before reading or amending
them.

Fixes #12565

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12567)

3 years agoprovider: disable fall-backs if OSSL_PROVIDER_load() fails.
Pauli [Thu, 13 Aug 2020 00:02:01 +0000 (10:02 +1000)]
provider: disable fall-backs if OSSL_PROVIDER_load() fails.

If an attempt is made to load a provider and it fails, the fall-back mechanism
should be disabled to prevent the user getting some weird happening.  E.g. a
failure to load the FIPS provider should not allow the default to load as a
fall-back.

The OSSL_PROVIDER_try_load() call has been added, to allow a provider to be
loaded without disabling the fall-back mechanism if it fails.

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

3 years agoPKCS#12 KDF: don't run tests with the FIPS provider.
Pauli [Tue, 11 Aug 2020 03:19:40 +0000 (13:19 +1000)]
PKCS#12 KDF: don't run tests with the FIPS provider.

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

3 years agoMove PKCS#12 KDF to provider.
Pauli [Tue, 11 Aug 2020 00:29:02 +0000 (10:29 +1000)]
Move PKCS#12 KDF to provider.

This KDF is defined in RFC7292 in appendix B.  It is widely used in PKCS#12
and should be provided.

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

3 years agoAppease -Werror=stringop-overflow=
Patrick Steuer [Tue, 11 Aug 2020 11:51:04 +0000 (13:51 +0200)]
Appease -Werror=stringop-overflow=

gcc 10 seems to think of assigning to an (unsigned) char
array as a stringop and demands additional space for a
terminating '\0':

In function 'ssl3_generate_key_block',
    inlined from 'ssl3_setup_key_block' at ssl/s3_enc.c:304:11:
ssl/s3_enc.c:51:20: error: writing 1 byte into a region of size 0
[-Werror=stringop-overflow=]
   51 |             buf[j] = c;
      |             ~~~~~~~^~~
ssl/s3_enc.c: In function 'ssl3_setup_key_block':
ssl/s3_enc.c:23:19: note: at offset 16 to object 'buf' with size 16
declared here
   23 |     unsigned char buf[16], smd[SHA_DIGEST_LENGTH];
      |                   ^~~

Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12632)

3 years agoRemove needless #ifndef OPENSSL_NO_SOCK for X509_{CRL_}load_http
Dr. David von Oheimb [Thu, 4 Jun 2020 08:23:42 +0000 (10:23 +0200)]
Remove needless #ifndef OPENSSL_NO_SOCK for X509_{CRL_}load_http

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

3 years agosslapitest: Add test for premature call of SSL_export_keying_material
Tomas Mraz [Thu, 6 Aug 2020 13:14:29 +0000 (15:14 +0200)]
sslapitest: Add test for premature call of SSL_export_keying_material

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

3 years agoAvoid segfault in SSL_export_keying_material if there is no session
Tomas Mraz [Thu, 6 Aug 2020 09:20:43 +0000 (11:20 +0200)]
Avoid segfault in SSL_export_keying_material if there is no session

Fixes #12588

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

3 years agoMark SSL_CTX_set_ssl_version() as deprecated in 3.0
Benjamin Kaduk [Thu, 20 Sep 2018 02:14:04 +0000 (21:14 -0500)]
Mark SSL_CTX_set_ssl_version() as deprecated in 3.0

Also, document its unusual semantics of resetting the
cipher list (but preserving other configuration).

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/7274)

3 years agoIntroduce X509_add_cert[s] simplifying various additions to cert lists
Dr. David von Oheimb [Sun, 26 Apr 2020 16:30:45 +0000 (18:30 +0200)]
Introduce X509_add_cert[s] simplifying various additions to cert lists

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

3 years agoAdd public API for gettables and settables for keymanagement, signatures and key...
Shane Lontis [Wed, 12 Aug 2020 01:59:43 +0000 (11:59 +1000)]
Add public API for gettables and settables for keymanagement, signatures and key exchange.

The openssl provider app will now display these params.

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

3 years agoFix serializer_EVP_PKEY_to_bio so that that the key is exported if the serializer...
Shane Lontis [Mon, 10 Aug 2020 00:16:26 +0000 (10:16 +1000)]
Fix serializer_EVP_PKEY_to_bio so that that the key is exported if the serializer provider does not match the key provider.

RSA keys in the 'base' provider are different from a fips provider RSA key (since they have different object structures).
To use a fips provider key in the base serializer the key needs to be exported.
The fix was suggested by @levitte.

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

3 years agoAdd fix for RSA keygen in FIPS using keysizes 2048 < bits < 3072
Shane Lontis [Tue, 16 Jun 2020 03:04:57 +0000 (13:04 +1000)]
Add fix for RSA keygen in FIPS using keysizes 2048 < bits < 3072

Fixes #11863

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

3 years agoprovider: add the unused paramater tag to the gettable and settable functions
Pauli [Fri, 7 Aug 2020 03:20:18 +0000 (13:20 +1000)]
provider: add the unused paramater tag to the gettable and settable functions

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

3 years agoExpose S390x HW ciphers' IV state to provider layer
Benjamin Kaduk [Tue, 21 Jul 2020 23:23:19 +0000 (16:23 -0700)]
Expose S390x HW ciphers' IV state to provider layer

The S390x hardware-accelerated cipher implementations keep their IV
state in an internal structure tied to the underlying implementation.
However, the provider itself needs to be able to expose the IV state
to libcrypto when processing the "iv-state" parameter.  In the absence
of a S390x hardware-specific get_ctx_params() implementation,  be sure
to copy the IV state from the hw-specific structure back to the
generic PROV_CIPHER_CTX object after each cipher operation in order to
synchronize the internal and fetchable state.

[extended tests]

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

3 years agoAvoid deprecated API in evp_test.c
Benjamin Kaduk [Thu, 9 Jul 2020 21:29:33 +0000 (14:29 -0700)]
Avoid deprecated API in evp_test.c

Use EVP_CIPHER_CTX_get_iv_state() in cipher_test_enc() rather than
the deprecated EVP_CIPHER_CTX_iv().

[extended tests]

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

3 years agoAvoid deprecated function in evp_lib.c
Benjamin Kaduk [Thu, 2 Jul 2020 23:27:03 +0000 (16:27 -0700)]
Avoid deprecated function in evp_lib.c

Use EVP_CIPHER_CTX_get_iv() to implement EVP_CIPHER_set_asn1_iv(),
rather than the deprecated EVP_CIPHER_CTX_original_iv().

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

3 years agoUse local IV storage in EVP BLOCK_* macros
Benjamin Kaduk [Thu, 2 Jul 2020 21:12:33 +0000 (14:12 -0700)]
Use local IV storage in EVP BLOCK_* macros

Inline the pre-13273237a65d46186b6bea0b51aec90670d4598a versions
of EVP_CIPHER_CTX_iv(), EVP_CIPHER_CTX_original_iv(), and
EVP_CIPHER_CTX_iv_noconst() in evp.h.

These macros are internal-only, used to implement legacy libcrypto
EVP ciphers, with no real provider involvement.  Accordingly, just use the
EVP_CIPHER_CTX storage directly and don't try to reach into a provider-side
context.

This does necessitate including evp_local.h in several more files.

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

3 years agoUse local IV storage in e_rc2.c
Benjamin Kaduk [Thu, 2 Jul 2020 21:12:33 +0000 (14:12 -0700)]
Use local IV storage in e_rc2.c

Inline the pre-13273237a65d46186b6bea0b51aec90670d4598a versions
of EVP_CIPHER_CTX_iv(), EVP_CIPHER_CTX_original_iv(), and
EVP_CIPHER_CTX_iv_noconst() in e_rc2.c.

For the legacy implementations, there's no need to use an
in-provider storage for the IV, when the crypto operations
themselves will be performed outside of the provider.

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

3 years agoUse local IV storage in e_xcbc_d.c
Benjamin Kaduk [Thu, 2 Jul 2020 21:12:33 +0000 (14:12 -0700)]
Use local IV storage in e_xcbc_d.c

Inline the pre-13273237a65d46186b6bea0b51aec90670d4598a versions
of EVP_CIPHER_CTX_iv(), EVP_CIPHER_CTX_original_iv(), and
EVP_CIPHER_CTX_iv_noconst() in e_xcbc_d.c.

For the legacy implementations, there's no need to use an
in-provider storage for the IV, when the crypto operations
themselves will be performed outside of the provider.

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

3 years agoUse local IV storage in e_sm4.c
Benjamin Kaduk [Thu, 2 Jul 2020 21:12:33 +0000 (14:12 -0700)]
Use local IV storage in e_sm4.c

Inline the pre-13273237a65d46186b6bea0b51aec90670d4598a versions
of EVP_CIPHER_CTX_iv(), EVP_CIPHER_CTX_original_iv(), and
EVP_CIPHER_CTX_iv_noconst() in e_sm4.c.

For the legacy implementations, there's no need to use an
in-provider storage for the IV, when the crypto operations
themselves will be performed outside of the provider.

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

3 years agoUse local IV storage in e_des3.c
Benjamin Kaduk [Thu, 2 Jul 2020 21:12:33 +0000 (14:12 -0700)]
Use local IV storage in e_des3.c

Inline the pre-13273237a65d46186b6bea0b51aec90670d4598a versions
of EVP_CIPHER_CTX_iv(), EVP_CIPHER_CTX_original_iv(), and
EVP_CIPHER_CTX_iv_noconst() in e_des3.c.

For the legacy implementations, there's no need to use an
in-provider storage for the IV, when the crypto operations
themselves will be performed outside of the provider.

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

3 years agoUse local IV storage in e_des.c
Benjamin Kaduk [Thu, 2 Jul 2020 21:12:33 +0000 (14:12 -0700)]
Use local IV storage in e_des.c

Inline the pre-13273237a65d46186b6bea0b51aec90670d4598a versions
of EVP_CIPHER_CTX_iv(), EVP_CIPHER_CTX_original_iv(), and
EVP_CIPHER_CTX_iv_noconst() in e_des.c.

For the legacy implementations, there's no need to use an
in-provider storage for the IV, when the crypto operations
themselves will be performed outside of the provider.

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

3 years agoUse local IV storage in e_camellia.c
Benjamin Kaduk [Thu, 2 Jul 2020 21:12:33 +0000 (14:12 -0700)]
Use local IV storage in e_camellia.c

Inline the pre-13273237a65d46186b6bea0b51aec90670d4598a versions
of EVP_CIPHER_CTX_iv(), EVP_CIPHER_CTX_original_iv(), and
EVP_CIPHER_CTX_iv_noconst() in e_camellia.c.

For the legacy implementations, there's no need to use an
in-provider storage for the IV, when the crypto operations
themselves will be performed outside of the provider.

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

3 years agoUse local IV storage in e_aria.c
Benjamin Kaduk [Thu, 2 Jul 2020 21:12:33 +0000 (14:12 -0700)]
Use local IV storage in e_aria.c

Inline the pre-13273237a65d46186b6bea0b51aec90670d4598a versions
of EVP_CIPHER_CTX_iv(), EVP_CIPHER_CTX_original_iv(), and
EVP_CIPHER_CTX_iv_noconst() in e_aria.c.

For the legacy implementations, there's no need to use an
in-provider storage for the IV, when the crypto operations
themselves will be performed outside of the provider.

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

3 years agoUse local IV storage in e_aes_ebc_hmac_sha256.c
Benjamin Kaduk [Thu, 2 Jul 2020 21:12:33 +0000 (14:12 -0700)]
Use local IV storage in e_aes_ebc_hmac_sha256.c

Inline the pre-13273237a65d46186b6bea0b51aec90670d4598a versions
of EVP_CIPHER_CTX_iv(), EVP_CIPHER_CTX_original_iv(), and
EVP_CIPHER_CTX_iv_noconst() in e_aes_cbc_hmac_sha256.c.

For the legacy implementations, there's no need to use an
in-provider storage for the IV, when the crypto operations
themselves will be performed outside of the provider.

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

3 years agoUse local IV storage in e_aes_ebc_hmac_sha1.c
Benjamin Kaduk [Thu, 2 Jul 2020 21:12:33 +0000 (14:12 -0700)]
Use local IV storage in e_aes_ebc_hmac_sha1.c

Inline the pre-13273237a65d46186b6bea0b51aec90670d4598a versions
of EVP_CIPHER_CTX_iv(), EVP_CIPHER_CTX_original_iv(), and
EVP_CIPHER_CTX_iv_noconst() in e_aes_cbc_hmac_sha1.c.

For the legacy implementations, there's no need to use an
in-provider storage for the IV, when the crypto operations
themselves will be performed outside of the provider.

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

3 years agoUse local IV storage in e_aes.c
Benjamin Kaduk [Thu, 2 Jul 2020 21:12:33 +0000 (14:12 -0700)]
Use local IV storage in e_aes.c

Inline the pre-13273237a65d46186b6bea0b51aec90670d4598a versions
of EVP_CIPHER_CTX_iv(), EVP_CIPHER_CTX_original_iv(), and
EVP_CIPHER_CTX_iv_noconst() in e_aes.c.

For the legacy implementations, there's no need to use an
in-provider storage for the IV, when the crypto operations
themselves will be performed outside of the provider.

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

3 years agoRetire EVP_CTRL_GET_IV
Benjamin Kaduk [Thu, 2 Jul 2020 20:03:58 +0000 (13:03 -0700)]
Retire EVP_CTRL_GET_IV

It is superseded by EVP_CIPHER_CTX_get_iv(), is only present on master,
and had only a couple of in-tree callers that are easy to convert.

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

3 years agoDocument EVP_CIPHER_CTX IV accessors
Benjamin Kaduk [Mon, 22 Jun 2020 18:37:31 +0000 (11:37 -0700)]
Document EVP_CIPHER_CTX IV accessors

Including the ones that were added in commit
83b06347023a573433b6aa23c8042f89df869f9e with a note that they "may go
away" and are now deprecated.

Remove the missingcrypto.txt entries for the now-deprecated functions.

[extended tests]

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

3 years agoMake GCM providers more generous about fetching IVs
Benjamin Kaduk [Sat, 20 Jun 2020 05:31:41 +0000 (22:31 -0700)]
Make GCM providers more generous about fetching IVs

The current check for iv_gen and iv_gen_rand only lets you fetch
the IV for the case when it was set internally.  It might also make
sense to fetch the IV if one was set at cipher-context creation time,
so switch to checking the iv_state, which should be enough to ensure
that there is valid data in the context to be copied out.

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

3 years agoAdd tests for new EVP_CIPHER_CTX IV accessors
Benjamin Kaduk [Sat, 20 Jun 2020 03:42:29 +0000 (20:42 -0700)]
Add tests for new EVP_CIPHER_CTX IV accessors

Test that EVP_CIPHER_CTX_get_iv() returns the same IV that was
given at initialization time, and that EVP_CIPHER_CTX_get_iv_state()
returns the expected value after performing an encryption operation
(which will differ from the previous value for CBC and OFB modes),
for various modes of AES.

Do this both for the implicit fetch and explicit fetch paths,
at the cost of a slightly more complicated switch statement.

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

3 years agoDeprecate and replace EVP_CIPHER_CTX_iv()/etc.
Benjamin Kaduk [Sat, 20 Jun 2020 01:43:58 +0000 (18:43 -0700)]
Deprecate and replace EVP_CIPHER_CTX_iv()/etc.

The EVP_CIPHER_CTX_iv() family of functions are incompatible with
the libcrypto/provider separation, since the implied API contract
(they are undocumented) involves a pointer into the active cipher
context structure.  However, the active IV data in a provider-side
context need not even be in the same address space as libcrypto,
so a replacement API is needed.

The existing functions for accessing the (even the "original") IV had
remained undocumented for quite some time, presumably due to unease
about exposing the internals of the cipher state in such a manner.

Provide more maintainable new APIs for accessing the initial ("oiv") and
current-state ("iv") IV data, that copy the value into a caller-provided
array, eliminating the need to provide a pointer into the internal
cipher context, which accordingly no longer provides the ability to
write to the internal cipher state.

Unfortunately, in order to maintain API compatibility with OpenSSL
1.1.1, the old functionality is still available, but is marked as
deprecated for future removal.  This would entail removing the "octet
pointer" parameter access, leaving only the "octet string" parameter
type.

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

3 years agoSupport cipher provider "iv state"
Benjamin Kaduk [Fri, 19 Jun 2020 20:50:22 +0000 (13:50 -0700)]
Support cipher provider "iv state"

Some modes (e.g., CBC and OFB) update the effective IV with each
block-cipher invocation, making the "IV" stored in the (historically)
EVP_CIPHER_CTX or (current) PROV_CIPHER_CTX distinct from the initial
IV passed in at cipher initialization time.  The latter is stored in
the "oiv" (original IV) field, and has historically been accessible
via the EVP_CIPHER_CTX_original_iv() API.  The "effective IV" has
also historically been accessible, via both EVP_CIPHER_CTX_iv()
and EVP_CIPHER_CTX_iv_noconst(), the latter of which allows for
*write* access to the internal cipher state.  This is particularly
problematic given that provider-internal cipher state need not, in
general, even be accessible from the same address space as libcrypto,
so these APIs are not sustainable in the long term.  However, it still
remains necessary to provide access to the contents of the "IV state"
(e.g., when serializing cipher state for in-kernel TLS); a subsequent
reinitialization of a cipher context using the "IV state" as the
input IV will be able to resume processing of data in a compatible
manner.

This problem was introduced in commit
089cb623be76b88a1eea6fcd135101037661bbc3, which effectively caused
all IV queries to return the "original IV", removing access to the
current IV state of the cipher.

These functions for accessing the (even the "original") IV had remained
undocumented for quite some time, presumably due to unease about
exposing the internals of the cipher state in such a manner.

Note that this also as a side effect "fixes" some "bugs" where things
had been referring to the 'iv' field that should have been using the
'oiv' field.  It also fixes the EVP_CTRL_GET_IV cipher control,
which was clearly intended to expose the non-original IV, for
use exporting the cipher state into the kernel for kTLS.

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

3 years agoAdd DHX serialization
Shane Lontis [Tue, 4 Aug 2020 01:39:49 +0000 (11:39 +1000)]
Add DHX serialization

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

3 years agoAdd dh_kdf support to provider
Shane Lontis [Tue, 4 Aug 2020 01:21:21 +0000 (11:21 +1000)]
Add dh_kdf support to provider

Similiar to ecdh this supports the legacy kdf inside the provider dh key exchange.
The supporting EVP_PKEY_CTX macros have been changed into mehtods and moved into dh_ctrl.c
New kdfs such as SSKDF should be done as a seperate pass after doing the derive.

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

3 years agoAdd DHX support to keymanager
Shane Lontis [Tue, 4 Aug 2020 01:15:18 +0000 (11:15 +1000)]
Add DHX support to keymanager

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

3 years agoREADME.md: remove incorrect link to openssl.github.io
Dr. Matthias St. Pierre [Thu, 2 Jul 2020 18:04:44 +0000 (20:04 +0200)]
README.md: remove incorrect link to openssl.github.io

The link to the OpenSSL Project Pages <openssl.github.io>
actually points to an unfinished draft <mspncp.github.io>.

The original intention of this pet project of mine was to
have a website dedicated to describing the OpenSSL workflow
on GitHub and to answer frequently asked questions related
to pull requests and the review process.

The progress on that project has stalled and I'm not so sure
anymore whether it is good idea to have yet another project
website. In particular since the OpenSSL Wiki has seen some
revival and increased activity caused by the upcoming
OpenSSL 3.0 release.

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

3 years agoREADME.md: replace incorrect access token for the AppVeyor badge
Dr. Matthias St. Pierre [Thu, 2 Jul 2020 18:00:03 +0000 (20:00 +0200)]
README.md: replace incorrect access token for the AppVeyor badge

The AppVeyor badge was still showing the build state for
the mspncp/openssl fork.

This commit fixes a forgotten todo from #10545.

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

3 years agoconf: add an error if the openssl_conf section isn't found.
Pauli [Fri, 7 Aug 2020 02:59:49 +0000 (12:59 +1000)]
conf: add an error if the openssl_conf section isn't found.

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/12602)

3 years agoRemove a TODO from evp_test
Matt Caswell [Fri, 7 Aug 2020 11:23:07 +0000 (12:23 +0100)]
Remove a TODO from evp_test

Now that the EVP_PKEY KDF bridge is based on provider code a TODO item
can be removed from evp_test.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12573)