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

3 years agoExtend the EVP_PKEY KDF to KDF provider bridge to the FIPS provider
Matt Caswell [Fri, 7 Aug 2020 11:22:29 +0000 (12:22 +0100)]
Extend the EVP_PKEY KDF to KDF provider bridge to the FIPS provider

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

3 years agoMinimise the size of the macros in kdf_exch.c
Matt Caswell [Tue, 4 Aug 2020 13:43:11 +0000 (14:43 +0100)]
Minimise the size of the macros in kdf_exch.c

Use proper functions with just a macro wrapper around them to minimise
the amount of code inside the macros. We also update the "settable"
functions now that they take a "provctx" parameter.

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

3 years agoUpdate KDF documentation
Matt Caswell [Tue, 4 Aug 2020 13:34:07 +0000 (14:34 +0100)]
Update KDF documentation

Following the previous commits where we moved the KDF bridge into
provider side code, we need to update the documentation accordingly.

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

3 years agoDelete old KDF bridge EVP_PKEY_METHODS
Matt Caswell [Fri, 31 Jul 2020 15:43:04 +0000 (16:43 +0100)]
Delete old KDF bridge EVP_PKEY_METHODS

The KDF bridge is now done provider side so the old EVP_PKEY_METHODS for
this are no longer required.

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

3 years agoExtend the EVP_PKEY KDF to KDF provider bridge to also support Scrypt
Matt Caswell [Fri, 31 Jul 2020 14:05:57 +0000 (15:05 +0100)]
Extend the EVP_PKEY KDF to KDF provider bridge to also support Scrypt

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

3 years agoExtend the EVP_PKEY KDF to KDF provider bridge to also support HKDF
Matt Caswell [Mon, 20 Jul 2020 17:06:55 +0000 (18:06 +0100)]
Extend the EVP_PKEY KDF to KDF provider bridge to also support HKDF

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

3 years agoImplement a EVP_PKEY KDF to KDF provider bridge
Matt Caswell [Fri, 3 Jul 2020 15:18:03 +0000 (16:18 +0100)]
Implement a EVP_PKEY KDF to KDF provider bridge

Some KDF implementations were available before the current EVP_KDF API.
They were used via EVP_PKEY_derive. There exists a bridge between the old
API and the EVP_KDF API however this bridge itself uses a legacy
EVP_PKEY_METHOD. This commit implements a provider side bridge without
having to use any legacy code.

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

3 years agoInitial Apple Silicon support.
C.W. Betts [Wed, 5 Aug 2020 08:08:07 +0000 (02:08 -0600)]
Initial Apple Silicon support.

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

3 years agoFix memory leak in drbgtest
Shane Lontis [Sun, 9 Aug 2020 07:26:39 +0000 (17:26 +1000)]
Fix memory leak in drbgtest

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/12613)

3 years agoAdd 'on demand self test' and status test to providers
Shane Lontis [Sun, 9 Aug 2020 08:06:52 +0000 (18:06 +1000)]
Add 'on demand self test' and status test to providers

The default and legacy providers currently return 1 for status and self test checks.
Added test to show the 3 different stages the self test can be run (for installation, loading and on demand).

For the fips provider:
  - If the on demand self test fails, then any subsequent fetches should also fail. To implement this the
    cached algorithms are flushed on failure.
  - getting the self test callback in the fips provider is a bit complicated since the callback hangs off the core
    libctx (as it is set by the application) not the actual fips library context. Also the callback can be set at
    any time not just during the OSSL_provider_init() so it is calculated each time before doing any self test.

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

3 years agoAdd some of the missing CMS API documentation
Shane Lontis [Thu, 6 Aug 2020 03:56:57 +0000 (13:56 +1000)]
Add some of the missing CMS API documentation

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

3 years agoChange CMS tests to use a library context.
Shane Lontis [Sun, 26 Jul 2020 07:36:33 +0000 (17:36 +1000)]
Change CMS tests to use a library context.

A DHX related test has been commented out and TODO(3) added, until DHX is added correctly to a provider.
Added generated files.

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

3 years agoAdd EVP signature with libctx methods.
Shane Lontis [Sun, 26 Jul 2020 07:32:05 +0000 (17:32 +1000)]
Add EVP signature with libctx methods.

-Added EVP_SignFinal_with_libctx() and EVP_VerifyFinal_with_libctx()
-Renamed EVP_DigestSignInit_ex() and EVP_DigestVerifyInit_with_libctx() to
  EVP_DigestSignInit_with_libctx() and EVP_DigestVerifyInit_with_libctx()

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

3 years agoUse libctx for EVP_CIPHER_CTX_rand_key() method.
Shane Lontis [Sun, 26 Jul 2020 07:26:43 +0000 (17:26 +1000)]
Use libctx for EVP_CIPHER_CTX_rand_key() method.

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

3 years agoAdd libctx to ecdh_KDF_X9_63.
Shane Lontis [Sun, 26 Jul 2020 07:23:41 +0000 (17:23 +1000)]
Add libctx to ecdh_KDF_X9_63.

Code is now correctly included in the fips provider.

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

3 years agoFix EVP_PKEY_CTX_get_rsa_oaep_md() & EVP_PKEY_CTX_get_rsa_mgf1_md() so they use a...
Shane Lontis [Sat, 25 Jul 2020 09:28:14 +0000 (19:28 +1000)]
Fix EVP_PKEY_CTX_get_rsa_oaep_md() & EVP_PKEY_CTX_get_rsa_mgf1_md() so they use a libctx to retrieve the digest

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

3 years agoAdd libctx support to PKCS7.
Shane Lontis [Sat, 25 Jul 2020 09:11:03 +0000 (19:11 +1000)]
Add libctx support to PKCS7.

-Public PKCS7 methods that create a PKCS7 object now have variants that also add a libctx and propq.
 This includes PKCS7_new_with_libctx(), PKCS7_sign_with_libctx() and PKCS7_encrypt_with_libctx()
-Added SMIME_read_PKCS7_ex() so that a created PKCS7 object can be passed to the read.
-d2i_PKCS7_bio() has been modified so that after it loads the PKCS7 object it then resolves any subobjects that require
 the libctx/propq (such as objects containing X509 certificates).

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

3 years agoAdd libctx to SMIME ASN1
Shane Lontis [Sat, 25 Jul 2020 08:59:28 +0000 (18:59 +1000)]
Add libctx to SMIME ASN1

Added SMIME_write_ASN1_with_libctx() since it fetches rand internally.
Added SMIME_read_CMS_ex() so that a created object (CMS_ContentInfo) can be passed to the read.

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

3 years agoAdd internal method x509_set0_libctx().
Shane Lontis [Sat, 25 Jul 2020 08:44:25 +0000 (18:44 +1000)]
Add internal method x509_set0_libctx().

This should only be called during (or right after) using d2iXXX on a object that contains embedded certificate(s)
that require a non default library context. X509_new_with_libctx() should be used if possible.

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

3 years agoAdd libctx support to CMS.
Shane Lontis [Sat, 25 Jul 2020 08:04:55 +0000 (18:04 +1000)]
Add libctx support to CMS.

-Public CMS methods that create a CMS_ContentInfo object now have variants that also add a libctx and propq.
 This includes CMS_ContentInfo_new_with_libctx(), CMS_sign_with_libctx(), CMS_data_create_with_libctx(),
 CMS_digest_create_with_libctx(), CMS_EncryptedData_encrypt_with_libctx(), CMS_EnvelopedData_create_with_libctx().
-Added CMS_ReceiptRequest_create0_with_libctx().
-Added SMIME_read_CMS_ex() so that a new CMS_ContentInfo object (created using CMS_ContentInfo_new_with_libctx()) can
be passed to the read.
-d2i_CMS_bio() has been modified so that after it loads the CMS_ContentInfo() it then resolves any subobjects that require
 the libctx/propq (such as objects containing X509 certificates).

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

3 years agorand: fix typo in parameter name
Dr. Matthias St. Pierre [Fri, 7 Aug 2020 15:48:29 +0000 (17:48 +0200)]
rand: fix typo in parameter name

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/12608)

3 years agoUpdate gost-engine to fix API rename
Dmitry Belyavskiy [Thu, 6 Aug 2020 15:24:48 +0000 (18:24 +0300)]
Update gost-engine to fix API rename

[extended tests]

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

3 years agoUse .cnf for config files, not .conf
Kelvin Lee [Thu, 6 Aug 2020 05:07:39 +0000 (15:07 +1000)]
Use .cnf for config files, not .conf

CLA: trivial

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

3 years agoAdd evp_test fixes.
Shane Lontis [Fri, 7 Aug 2020 04:29:00 +0000 (14:29 +1000)]
Add evp_test fixes.

Changed many tests so they also test fips (and removed 'availablein = default' from some tests).
Seperated the monolithic evppkey.txt file into smaller maintainable groups.
Changed the availablein option so it must be first - this then skips the entire test before any fetching happens.
Changed the code so that all the OPENSSL_NO_XXXX tests are done in code via methods such as is_cipher_disabled(alg),
before the fetch happens.
Added missing libctx's found by adding a libctx to test_evp.
Broke up large data files for cipher, kdf's and mac's into smaller pieces so they no longer need 'AvailableIn = default'
Added missing algorithm aliases for cipher/digests to the providers.

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

3 years agodrbgtest: avoid a memory leak
Pauli [Thu, 6 Aug 2020 01:11:44 +0000 (11:11 +1000)]
drbgtest: avoid a memory leak

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/12509)

3 years agorand_drbg: remove RAND_DRBG.
Pauli [Wed, 22 Jul 2020 02:55:31 +0000 (12:55 +1000)]
rand_drbg: remove RAND_DRBG.

The RAND_DRBG API did not fit well into the new provider concept as
implemented by EVP_RAND and EVP_RAND_CTX. The main reason is that the
RAND_DRBG API is a mixture of 'front end' and 'back end' API calls
and some of its API calls are rather low-level. This holds in particular
for the callback mechanism (RAND_DRBG_set_callbacks()) and the RAND_DRBG
type changing mechanism (RAND_DRBG_set()).

Adding a compatibility layer to continue supporting the RAND_DRBG API as
a legacy API for a regular deprecation period turned out to come at the
price of complicating the new provider API unnecessarily. Since the
RAND_DRBG API exists only since version 1.1.1, it was decided by the OMC
to drop it entirely.

Other related changes:

Use RNG instead of DRBG in EVP_RAND documentation.  The documentation was
using DRBG in places where it should have been RNG or CSRNG.

Move the RAND_DRBG(7) documentation to EVP_RAND(7).

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/12509)

3 years agoPROV: Fix MSBLOB / PVK deserializer
Richard Levitte [Fri, 7 Aug 2020 02:44:06 +0000 (04:44 +0200)]
PROV: Fix MSBLOB / PVK deserializer

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

3 years agoEVP: Fix the returned value for ASN1_PKEY_CTRL_DEFAULT_MD_NID
Richard Levitte [Wed, 5 Aug 2020 08:40:01 +0000 (10:40 +0200)]
EVP: Fix the returned value for ASN1_PKEY_CTRL_DEFAULT_MD_NID

Trust the returned value from EVP_PKEY_get_default_digest_name()!  It
mimics exactly the values that EVP_PKEY_get_default_digest_nid() is
supposed to return, and that value should simply be passed unchanged.
Callers depend on it.

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

3 years agoTEST: Adjust the serdes test to include MSBLOB and PVK
Richard Levitte [Mon, 3 Aug 2020 19:10:19 +0000 (21:10 +0200)]
TEST: Adjust the serdes test to include MSBLOB and PVK

Because PVK uses RC4, we must ensure that default + legacy providers
are active.

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

3 years agoPEM: Fix i2b_PvK to use EVP_Encrypt calls consistently
Richard Levitte [Mon, 3 Aug 2020 19:09:26 +0000 (21:09 +0200)]
PEM: Fix i2b_PvK to use EVP_Encrypt calls consistently

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

3 years agoPROV: Add MSBLOB and PVK to DSA and RSA deserializers
Richard Levitte [Mon, 3 Aug 2020 19:08:40 +0000 (21:08 +0200)]
PROV: Add MSBLOB and PVK to DSA and RSA deserializers

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

3 years agoDESERIALIZER: Adjust to allow the use several deserializers with same name
Richard Levitte [Mon, 3 Aug 2020 19:04:05 +0000 (21:04 +0200)]
DESERIALIZER: Adjust to allow the use several deserializers with same name

A key type may be deserialized from one of several sources, which
means that more than one deserializer with the same name should be
possible to add to the stack of deserializers to try, in the
OSSL_DESERIALIZER_CTX collection.

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

3 years agoPEM: Make general MSBLOB reader functions exposed internally
Richard Levitte [Mon, 3 Aug 2020 19:01:35 +0000 (21:01 +0200)]
PEM: Make general MSBLOB reader functions exposed internally

Fly-by fix is to move crypto/include/internal/pem_int.h to
include/internal/pem.h.

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

3 years agoRSA: Be less strict on PSS parameters when exporting to provider
Richard Levitte [Wed, 5 Aug 2020 06:01:59 +0000 (08:01 +0200)]
RSA: Be less strict on PSS parameters when exporting to provider

We have a key in test/recipes/30-test_evp_data/evppkey.txt with bad
PSS parameters (RSA-PSS-BAD), which is supposed to trigger signature
computation faults.  However, if this key needs to be exported to the
RSA provider implementation, the result would be an earlier error,
giving the computation that's supposed to be checked n chance to even
be reached.

Either way, the legacy to provider export is no place to validate the
values of the key.

We also ensure that the provider implementation can handle and detect
signed (negative) saltlen values.

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

3 years agomac: add some consistency to setting the XXX_final output length.
Pauli [Wed, 5 Aug 2020 05:26:48 +0000 (15:26 +1000)]
mac: add some consistency to setting the XXX_final output length.

The various MACs were all over the place with respects to what they did with
the output length in the final call.  Now they all unconditionally set the
output length and the EVP layer handles the possibility of a NULL pointer.

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

3 years agogettables: documentation changes to pass the provider context.
Pauli [Wed, 5 Aug 2020 03:24:04 +0000 (13:24 +1000)]
gettables: documentation changes to pass the provider context.

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

3 years agogettables: test changes to pass the provider context.
Pauli [Wed, 5 Aug 2020 03:23:52 +0000 (13:23 +1000)]
gettables: test changes to pass the provider context.

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

3 years agogettables: provider changes to pass the provider context.
Pauli [Wed, 5 Aug 2020 03:23:32 +0000 (13:23 +1000)]
gettables: provider changes to pass the provider context.

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

3 years agogettables: core changes to pass the provider context.
Pauli [Wed, 5 Aug 2020 03:23:16 +0000 (13:23 +1000)]
gettables: core changes to pass the provider context.

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

3 years agoAdd new APIs to get PKCS12 secretBag OID and value
Jon Spillett [Thu, 19 Sep 2019 05:39:13 +0000 (15:39 +1000)]
Add new APIs to get PKCS12 secretBag OID and value

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

3 years agoapps/pkcs12: Change defaults from RC2 to PBES2 with PBKDF2
Sahana Prasad [Wed, 22 Jul 2020 11:36:36 +0000 (13:36 +0200)]
apps/pkcs12: Change defaults from RC2 to PBES2 with PBKDF2

Fixes #11672

Add "-legacy" option to load the legacy provider and
fall back to the old legacy default algorithms.

doc/man1/openssl-pkcs12.pod.in: updates documentation about the new
"-legacy" option

Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12540)

3 years agoPrepare for 3.0 alpha 7
Matt Caswell [Thu, 6 Aug 2020 13:02:31 +0000 (14:02 +0100)]
Prepare for 3.0 alpha 7

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
3 years agoPrepare for release of 3.0 alpha 6 openssl-3.0.0-alpha6
Matt Caswell [Thu, 6 Aug 2020 13:00:13 +0000 (14:00 +0100)]
Prepare for release of 3.0 alpha 6

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
3 years agoUpdate copyright year
Matt Caswell [Thu, 6 Aug 2020 12:22:30 +0000 (13:22 +0100)]
Update copyright year

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

3 years agoFix provider cipher reinit after init/update with a partial update block.
Shane Lontis [Tue, 4 Aug 2020 22:45:29 +0000 (08:45 +1000)]
Fix provider cipher reinit after init/update with a partial update block.

The test added previously used a 16 byte block during the update which does not cause internal buffering in the provider.
Some internal variables related to the buffering were not being cleared in the init, which meant that the second
update would use the buffered data from the first update.
Added test for this scenario with exclusions for ciphers that do not support partial block updates.

Found by guidovranken.

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

3 years agoMark an argument of an inline function as unused
Peter Eisentraut [Thu, 16 Jul 2020 08:18:16 +0000 (10:18 +0200)]
Mark an argument of an inline function as unused

This allows users of this header file to compile their own code with
the gcc option -Wunused-parameter.

CLA: trivial

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

3 years agoopenssl-cmp.pod.in: Update and extend example using Insta Demo CA
Dr. David von Oheimb [Sat, 25 Jul 2020 11:47:04 +0000 (13:47 +0200)]
openssl-cmp.pod.in: Update and extend example using Insta Demo CA

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

3 years agoDESERIALIZER: Fix EVP_PKEY construction by export
Richard Levitte [Mon, 3 Aug 2020 05:22:37 +0000 (07:22 +0200)]
DESERIALIZER: Fix EVP_PKEY construction by export

When the keymgmt provider and the deserializer provider differ,
deserialization uses the deserializer export function instead of the
keymgmt load, with a selection of what parts should be exported.  That
selection was set to OSSL_KEYMGMT_SELECT_ALL_PARAMETERS when it should
have been OSSL_KEYMGMT_SELECT_ALL.

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

3 years agoFix error message on setting cert validity period in apps/cmp.c
Dr. David von Oheimb [Sat, 27 Jun 2020 08:29:55 +0000 (10:29 +0200)]
Fix error message on setting cert validity period in apps/cmp.c

Fixes #12268

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

3 years agoapps: Correct and extend diagnostics of parse_name()
Dr. David von Oheimb [Sat, 27 Jun 2020 08:28:45 +0000 (10:28 +0200)]
apps: Correct and extend diagnostics of parse_name()

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

3 years agoAdd 'section=...' info in error output of X509V3_EXT_nconf() as far as appropriate
Dr. David von Oheimb [Fri, 26 Jun 2020 18:40:19 +0000 (20:40 +0200)]
Add 'section=...' info in error output of X509V3_EXT_nconf() as far as appropriate

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

3 years agoRename misleading X509V3_R_INVALID_NULL_NAME to X509V3_R_INVALID_EMPTY_NAME
Dr. David von Oheimb [Fri, 26 Jun 2020 18:13:47 +0000 (20:13 +0200)]
Rename misleading X509V3_R_INVALID_NULL_NAME to X509V3_R_INVALID_EMPTY_NAME

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

3 years agoCorrect confusing X509V3 conf error output by removing needless 'section:<NULL>'...
Dr. David von Oheimb [Fri, 26 Jun 2020 14:16:00 +0000 (16:16 +0200)]
Correct confusing X509V3 conf error output by removing needless 'section:<NULL>' etc.

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

3 years agoCorrect misleading diagnostics of OBJ_txt2obj on unknown object name
Dr. David von Oheimb [Fri, 26 Jun 2020 14:16:56 +0000 (16:16 +0200)]
Correct misleading diagnostics of OBJ_txt2obj on unknown object name

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

3 years agoapps/cmp.c: Defer diagnostic output on server+proxy to be contacted
Dr. David von Oheimb [Fri, 26 Jun 2020 10:37:12 +0000 (12:37 +0200)]
apps/cmp.c: Defer diagnostic output on server+proxy to be contacted

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

3 years agoPROV: Make the DER to KEY deserializer decode parameters too
Richard Levitte [Sun, 2 Aug 2020 11:12:54 +0000 (13:12 +0200)]
PROV: Make the DER to KEY deserializer decode parameters too

It should be noted that this may be dodgy if we ever encounter
parameter objects that look like something else.  However, experience
with the OSSL_STORE 'file:' loader, which does exactly this kind of
thing, has worked fine so far.

A possibility could be that to decode parameters specifically, we
demand that there's an incoming data type specifying this, which
demands by extension that parameters can only come from a file format
that has the parameter type encoded, such as PEM.  This would be a
future effort.

Fixes #12568

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

3 years agoCoverity Fixes for issue #12531
Norman Ashley [Tue, 4 Aug 2020 02:34:22 +0000 (12:34 +1000)]
Coverity Fixes for issue #12531

Fixes #12531 on master branch.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12557)

3 years agoChange the provider implementation of X942kdf to use wpacket to do der encoding of...
Shane Lontis [Tue, 4 Aug 2020 02:18:51 +0000 (12:18 +1000)]
Change the provider implementation of X942kdf to use wpacket to do der encoding of sharedInfo

Added der_writer functions for writing octet string primitives.
Generate OID's for key wrapping algorithms used by X942 KDF.

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

3 years agoAdd CHANGES.md entry for SSL_set1_host()/SSL_add1_host() taking IP literals
David Woodhouse [Tue, 19 May 2020 10:51:14 +0000 (11:51 +0100)]
Add CHANGES.md entry for SSL_set1_host()/SSL_add1_host() taking IP literals

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

3 years agoDisallow setting more than one IP address with SSL_add1_host()
David Woodhouse [Mon, 11 May 2020 18:28:03 +0000 (19:28 +0100)]
Disallow setting more than one IP address with SSL_add1_host()

The X509_VERIFY_PARAM can only take a single IP address, although it can
have multiple hostnames. When SSL_add1_host() is given an IP address,
don't accept it if there is already one configured.

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

3 years agoFix certificate validation for IPv6 literals in sconnect demo
David Woodhouse [Thu, 20 Jun 2019 20:39:38 +0000 (21:39 +0100)]
Fix certificate validation for IPv6 literals in sconnect demo

Instead of naïvely trying to truncate at the first colon, use
BIO_get_conn_hostname(). That handles IPv6 literals correctly, even
stripping the [] from around them.

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

3 years agoMake SSL_set1_host() and SSL_add1_host() take IP addresses
David Woodhouse [Mon, 14 Oct 2019 09:46:07 +0000 (10:46 +0100)]
Make SSL_set1_host() and SSL_add1_host() take IP addresses

There is a slight mismatch here because X509_VERIFY_PARAM copes only
with a single IP address, and doesn't let it be cleared once it's set.
But this fixes up the major use case, making things easier for users to
get it right.

The sconnect demo now works for Legacy IP literals; for IPv6 it needs to
fix up the way it tries to split the host:port string, which will happen
in a subsequent patch.

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

3 years ago81-test_cmp_cli.t: Skip tests with mock server if server cannot be started
Dr. David von Oheimb [Mon, 27 Jul 2020 06:50:27 +0000 (08:50 +0200)]
81-test_cmp_cli.t: Skip tests with mock server if server cannot be started

Fixes #12514

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

3 years agoFix an ENGINE leak in asn1_item_digest_with_libctx
Matt Caswell [Thu, 30 Jul 2020 14:15:05 +0000 (15:15 +0100)]
Fix an ENGINE leak in asn1_item_digest_with_libctx

Commit 6725682d introduced a call to ENGINE_get_digest_engine() into
the function asn1_item_digest_with_libctx() to determine whether there
is an ENGINE registered to handle the specified digest. However that
function increases the ref count on the returned ENGINE object, so it
must be freed.

Fixes #12558

[extended tests]

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/12560)

3 years agoDESERIALIZER: Small bugfix in the deser_process()
Richard Levitte [Mon, 27 Jul 2020 20:11:53 +0000 (22:11 +0200)]
DESERIALIZER: Small bugfix in the deser_process()

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

3 years agoDESERIALIZER: Make OSSL_DESERIALIZER_from_{bio,fp} use BIO_tell() / BIO_seek()
Richard Levitte [Mon, 27 Jul 2020 20:02:07 +0000 (22:02 +0200)]
DESERIALIZER: Make OSSL_DESERIALIZER_from_{bio,fp} use BIO_tell() / BIO_seek()

Depending on the BIO used, using BIO_reset() may lead to "interesting"
results.  For example, a BIO_f_buffer() on top of another BIO that
handles BIO_reset() as a BIO_seek(bio, 0), the deserialization process
may find itself with a file that's rewound more than expected.

Therefore, OSSL_DESERIALIZER_from_{bio,fp}'s behaviour is changed to
rely purely on BIO_tell() / BIO_seek(), and since BIO_s_mem() is used
internally, it's changed to handle BIO_tell() and BIO_seek() better.

This does currently mean that OSSL_DESERIALIZER can't be easily used
with streams that don't support BIO_tell() / BIO_seek().

Fixes #12541

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

3 years agoDESERIALIZER: Refactor the constructor setting API
Richard Levitte [Mon, 27 Jul 2020 19:51:44 +0000 (21:51 +0200)]
DESERIALIZER: Refactor the constructor setting API

It's not the best idea to set a whole bunch of parameters in one call,
that leads to functions that are hard to update.  Better to re-model
this into several function made to set one parameter each.

This also renames "finalizer" to "constructor", which was suggested
earlier but got lost at the time.

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

3 years agoTEST: Add testutil tests to compare unterminated strings of different lengths
Richard Levitte [Mon, 27 Jul 2020 16:40:11 +0000 (18:40 +0200)]
TEST: Add testutil tests to compare unterminated strings of different lengths

We use this in test/serdes_test.c, to compare serializations into PEM,
which aren't necessarily terminated with a NUL byte when they were
written to a BIO_s_mem().

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

3 years agoDESERIALIZER: Add deserializers for the rest of our asymmetric key types
Richard Levitte [Mon, 27 Jul 2020 16:40:05 +0000 (18:40 +0200)]
DESERIALIZER: Add deserializers for the rest of our asymmetric key types

To be able to implement this, there was a need for the standard
EVP_PKEY_set1_, EVP_PKEY_get0_ and EVP_PKEY_get1_ functions for
ED25519, ED448, X25519 and X448, as well as the corresponding
EVP_PKEY_assign_ macros.  There was also a need to extend the list of
hard coded names that EVP_PKEY_is_a() recognise.

Along with this, OSSL_FUNC_keymgmt_load() are implemented for all
those key types.

The deserializers for these key types are all implemented generically,
in providers/implementations/serializers/deserializer_der2key.c.

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

3 years agoDESERIALIZER: Make it possible to deserialize public keys too
Richard Levitte [Mon, 27 Jul 2020 16:40:02 +0000 (18:40 +0200)]
DESERIALIZER: Make it possible to deserialize public keys too

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

3 years agoDESERIALIZER: Rethink password handling
Richard Levitte [Mon, 27 Jul 2020 16:39:58 +0000 (18:39 +0200)]
DESERIALIZER: Rethink password handling

The OSSL_DESERIALIZER API makes the incorrect assumption that the
caller must cipher and other pass phrase related parameters to the
individual desserializer implementations, when the reality is that
they only need a passphrase callback, and will be able to figure out
the rest themselves from the input they get.

We simplify it further by never passing any explicit passphrase to the
provider implementation, and simply have them call the passphrase
callback unconditionally when they need, leaving it to libcrypto code
to juggle explicit passphrases, cached passphrases and actual
passphrase callback calls.

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

3 years agoRSA: Better synchronisation between ASN1 PSS params and RSA_PSS_PARAMS_30
Richard Levitte [Mon, 27 Jul 2020 16:39:55 +0000 (18:39 +0200)]
RSA: Better synchronisation between ASN1 PSS params and RSA_PSS_PARAMS_30

This is needed so RSA keys created from different code paths have a
chance to compare as equal.

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