openssl.git
3 years agoExtend the provider MAC bridge for Poly1305
Matt Caswell [Tue, 11 Aug 2020 14:28:07 +0000 (15:28 +0100)]
Extend the provider MAC bridge for Poly1305

The previous commits added support for HMAC and SIPHASH into the provider
MAC bridge. We now extend that for Poly1305 too.

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

3 years agoDon't require a default digest from signature algorithms
Matt Caswell [Tue, 11 Aug 2020 13:55:04 +0000 (14:55 +0100)]
Don't require a default digest from signature algorithms

Some signature algorithms don't need a default digest, so don't fail if
we don't have one.

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

3 years agoExtend the provider MAC bridge for SIPHASH
Matt Caswell [Tue, 11 Aug 2020 13:54:18 +0000 (14:54 +0100)]
Extend the provider MAC bridge for SIPHASH

The previous commits added support for HMAC into the provider MAC bridge.
We now extend that for SIPHASH too.

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

3 years agoEnsure libssl creates libctx aware MAC keys
Matt Caswell [Tue, 11 Aug 2020 10:50:04 +0000 (11:50 +0100)]
Ensure libssl creates libctx aware MAC keys

Convert various mac key creation function calls to use the _with_libctx
variants.

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

3 years agoFix some EVP_MD_CTX_* functions
Matt Caswell [Mon, 10 Aug 2020 16:11:39 +0000 (17:11 +0100)]
Fix some EVP_MD_CTX_* functions

Fixes some issues with EVP_MD_CTX_* functions when doing EVP_DigestSign*
and EVP_DigestVerify* functions.

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

3 years agoConvert EVP_PKEY_CTX_set_mac_key() into a function
Matt Caswell [Mon, 10 Aug 2020 08:16:01 +0000 (09:16 +0100)]
Convert EVP_PKEY_CTX_set_mac_key() into a function

Previously it was a macro. We now make it into a function that is params
aware.

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

3 years agoFix evp_extra_test to not assume that HMAC is legacy
Matt Caswell [Fri, 7 Aug 2020 16:20:18 +0000 (17:20 +0100)]
Fix evp_extra_test to not assume that HMAC is legacy

evp_extra_test had a test that checks whether an EVP_PKEY_CTX can still
be created for HMAC even though there are no providers loaded because it
is a legacy algorithm. However after the earlier commits this is no longer
the case. We swap the check to a different legacy algorithm (SM2).
Hopefully before too long there will be no legacy algorithms left and the
test can be deleted.

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

3 years agoMake the provider side EVP PKEY MAC bridge available in default and fips
Matt Caswell [Fri, 7 Aug 2020 15:55:42 +0000 (16:55 +0100)]
Make the provider side EVP PKEY MAC bridge available in default and fips

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

3 years agoImplement signature functions for EVP_PKEY MAC to EVP_MAC provider bridge
Matt Caswell [Fri, 7 Aug 2020 15:42:02 +0000 (16:42 +0100)]
Implement signature functions for EVP_PKEY MAC to EVP_MAC provider bridge

Some MAC implementations were available before the current EVP_MAC API. They
were used via EVP_DigestSign*. There exists a bridge between the oldAPI and
the EVP_MAC API however this bridge itself uses a legacy EVP_PKEY_METHOD.
This commit implements the signature functions for the 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/12637)

3 years agoImplement key management for the EVP_PKEY MAC to EVP_MAC provider bridge
Matt Caswell [Fri, 7 Aug 2020 15:40:25 +0000 (16:40 +0100)]
Implement key management for the EVP_PKEY MAC to EVP_MAC provider bridge

Some MAC implementations were available before the current EVP_MAC API. They
were used via EVP_DigestSign*. There exists a bridge between the old API and
the EVP_MAC API however this bridge itself uses a legacy EVP_PKEY_METHOD.
This commit implements the key management for provider side bridge without
having to useany legacy code.

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

3 years agoTEST: Adapt some tests for a stricter PEM_write_bio_PrivateKey_traditional()
Richard Levitte [Thu, 27 Aug 2020 14:05:53 +0000 (16:05 +0200)]
TEST: Adapt some tests for a stricter PEM_write_bio_PrivateKey_traditional()

- test/endecode_test.c

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

3 years agoFix PEM_write_bio_PrivateKey_traditional() to not output PKCS#8
Richard Levitte [Thu, 27 Aug 2020 05:18:55 +0000 (07:18 +0200)]
Fix PEM_write_bio_PrivateKey_traditional() to not output PKCS#8

PEM_write_bio_PrivateKey_traditional() uses i2d_PrivateKey() to do the
actual encoding to DER.  However, i2d_PrivateKey() is a generic
function that will do what it can to produce output according to what
the associated EVP_PKEY_ASN1_METHOD offers.  If that method offers a
function 'old_priv_encode', which is expected to produce the
"traditional" encoded form, then i2d_PrivateKey() uses that.  If not,
i2d_PrivateKey() will go on and used more modern methods, which are
all expected to produce PKCS#8.

To ensure that PEM_write_bio_PrivateKey_traditional() never produces
more modern encoded forms, an extra check that 'old_priv_encode' is
non-NULL is added.  If it is NULL, an error is returned.

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

3 years agoCorrect description of BN_mask_bits
T.Yanagisawa [Thu, 27 Aug 2020 02:11:23 +0000 (11:11 +0900)]
Correct description of BN_mask_bits

CLA: trivial

Correct right shift to left shift.
Pseudo code `a&=~((~0)>>n)` means "get higher n-bits of a", but actually crypto lib gives lower n-bits.

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

3 years agoconf: add diagnostic option
Pauli [Wed, 26 Aug 2020 03:41:30 +0000 (13:41 +1000)]
conf: add diagnostic option

Add an option to configuration files "config_diagnostics" that when set to a
non-zero value, overrides the error ignoring flags.  The outcome is that
diagnostic option is produced when e.g. sections are missing.

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

3 years agoprovider_conf: report missing section on error
Pauli [Wed, 19 Aug 2020 11:13:58 +0000 (21:13 +1000)]
provider_conf: report missing section on error

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

3 years agoIgnore vendor name in Clang version number.
Jung-uk Kim [Wed, 26 Aug 2020 18:00:56 +0000 (14:00 -0400)]
Ignore vendor name in Clang version number.

For example, FreeBSD prepends "FreeBSD" to version string, e.g.,

FreeBSD clang version 11.0.0 (git@github.com:llvm/llvm-project.git llvmorg-11.0.0-rc2-0-g414f32a9e86)
Target: x86_64-unknown-freebsd13.0
Thread model: posix
InstalledDir: /usr/bin

This prevented us from properly detecting AVX support, etc.

CLA: trivial

Reviewed-by: Richard Levitte <levitte@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/12725)

3 years agorand: instantiate the DRBGs upon first use.
Pauli [Wed, 26 Aug 2020 04:11:49 +0000 (14:11 +1000)]
rand: instantiate the DRBGs upon first use.

Fixes #12714

[skip ci]

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/12717)

3 years agorand: add a note about a potentially misleading code analyzer warning.
Pauli [Wed, 26 Aug 2020 13:56:55 +0000 (23:56 +1000)]
rand: add a note about a potentially misleading code analyzer warning.

When seeding from a parent DRBG, the pointer to the child is used as
additional data.  This triggers static code analysers.  Rearrange and
expand the comments to make this more obvious.

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

3 years agoapps/pkcs12.c: Add -untrusted option
Dr. David von Oheimb [Mon, 10 Aug 2020 12:23:46 +0000 (14:23 +0200)]
apps/pkcs12.c: Add -untrusted option

Also improve EE cert selection, user guidance, and documentation.

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

3 years agoX509_add_certs(): Add to doc some warning notes on memory management
Dr. David von Oheimb [Thu, 13 Aug 2020 11:52:29 +0000 (13:52 +0200)]
X509_add_certs(): Add to doc some warning notes on memory management

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

3 years agoAdd OCSP_PARTIAL_CHAIN to OCSP_basic_verify()
Rich Salz [Mon, 17 Aug 2020 19:31:42 +0000 (15:31 -0400)]
Add OCSP_PARTIAL_CHAIN to OCSP_basic_verify()

This adds a flag, OCSP_PARTIAL_CHAIN, to the OCSP_basic_verify()
function.  This is equivlent to X509_V_FLAG_PARTIAL_CHAIN, in that
if any certificate in the OCSP response is in the trust store, then
trust it.

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

3 years agoapps: -msg flag enhancement 2/2
Marc [Sun, 28 Jun 2020 23:45:04 +0000 (00:45 +0100)]
apps: -msg flag enhancement 2/2

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/12310)

3 years agoapps: -msg flag enhancement 1/2
Marc [Sun, 28 Jun 2020 23:43:37 +0000 (00:43 +0100)]
apps: -msg flag enhancement 1/2

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/12310)

3 years agoEVP: NULL pctx pointer after free.
Pauli [Wed, 26 Aug 2020 04:36:50 +0000 (14:36 +1000)]
EVP: NULL pctx pointer after free.

Not doing so can result in a double free.

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

3 years agoReplace hierogliphs with stub to pass tests
Dmitry Belyavskiy [Wed, 1 Jul 2020 07:24:51 +0000 (10:24 +0300)]
Replace hierogliphs with stub to pass tests

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

3 years agoDocumentation for internal PUNYCODE-related functions
Dmitry Belyavskiy [Mon, 14 Oct 2019 13:35:42 +0000 (16:35 +0300)]
Documentation for internal PUNYCODE-related functions

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

3 years agoEAI test script and data
Dmitry Belyavskiy [Wed, 18 Sep 2019 18:27:17 +0000 (21:27 +0300)]
EAI test script and data

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

3 years agoRFC 8398: documentation
Dmitry Belyavskiy [Wed, 21 Aug 2019 15:36:10 +0000 (18:36 +0300)]
RFC 8398: documentation

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

3 years agoAdd NID_id_on_SmtpUTF8Mailbox to table of X.509 attributes
Dmitry Belyavskiy [Wed, 21 Aug 2019 15:35:45 +0000 (18:35 +0300)]
Add NID_id_on_SmtpUTF8Mailbox to table of X.509 attributes

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

3 years agoRFC 8398: EAI comparison
Dmitry Belyavskiy [Wed, 21 Aug 2019 15:34:27 +0000 (18:34 +0300)]
RFC 8398: EAI comparison

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

3 years agoRFC 8398: Name constraints validation
Dmitry Belyavskiy [Wed, 21 Aug 2019 15:33:14 +0000 (18:33 +0300)]
RFC 8398: Name constraints validation

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

3 years agoPunycode decoding implementation
Dmitry Belyavskiy [Wed, 21 Aug 2019 15:31:43 +0000 (18:31 +0300)]
Punycode decoding implementation

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

3 years agocrypto/x509/v3_utl.c: Fix IPv6 output in ipaddr_to_asc()
Richard Levitte [Thu, 20 Aug 2020 19:31:33 +0000 (21:31 +0200)]
crypto/x509/v3_utl.c: Fix IPv6 output in ipaddr_to_asc()

Fixes #12695

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

3 years agoTEST: Fix CMP tests so they load keys in the current library context
Richard Levitte [Sun, 23 Aug 2020 08:06:06 +0000 (10:06 +0200)]
TEST: Fix CMP tests so they load keys in the current library context

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

3 years agoAdd CLI tests in FIPS configuration
Nicola Tuveri [Fri, 26 Jun 2020 22:40:30 +0000 (01:40 +0300)]
Add CLI tests in FIPS configuration

Add positive and negative tests of CLI apps using configuration files
via environment variables to force FIPS mode.

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

3 years agoSTORE: Change all error recording to use ERR_raise() / ERR_raise_data()
Richard Levitte [Thu, 23 Jul 2020 14:12:10 +0000 (16:12 +0200)]
STORE: Change all error recording to use ERR_raise() / ERR_raise_data()

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

3 years agoSTORE: Modify to support loading with provider based loaders
Richard Levitte [Wed, 22 Jul 2020 20:55:00 +0000 (22:55 +0200)]
STORE: Modify to support loading with provider based loaders

This adds the needed code to make the OSSL_STORE API functions handle
provided STORE implementations.

This also modifies OSSL_STORE_attach() for have the URI, the
library context and the properties in the same order as
OSSL_STORE_open_with_libctx().

The most notable change, though, is how this creates a division of
labor between libcrypto and any storemgmt implementation that wants to
pass X.509, X.509 CRL, etc structures back to libcrypto.  Since those
structures aren't directly supported in the libcrypto <-> provider
interface (asymmetric keys being the only exception so far), we resort
to a libcrypto object callback that can handle passed data in DER form
and does its part of figuring out what the DER content actually is.

This also adds the internal x509_crl_set0_libctx(), which works just
like x509_set0_libctx(), but for X509_CRL.

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

3 years agoDECODER: Add function to set an OSSL_PASSPHRASE_CALLBACK type callback
Richard Levitte [Sun, 2 Aug 2020 12:29:33 +0000 (14:29 +0200)]
DECODER: Add function to set an OSSL_PASSPHRASE_CALLBACK type callback

This makes it possible to use OSSL_DECODER in functions that are passed
a OSSL_PASSPHRASE_CALLBACK already.

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

3 years agoOSSL_PARAM: Add string pointer getters
Richard Levitte [Tue, 28 Jul 2020 20:00:09 +0000 (22:00 +0200)]
OSSL_PARAM: Add string pointer getters

When some function receives an OSSL_PARAM array to pilfer for data,
and there is a string of some sort, and all the code needs is to get
the pointer to the data, rather than a copy, there is currently no
other way than to use |param->data| directly.  This is of course a
valid method, but lacks any safety check (is |param->data_type|
correct, for example?).

OSSL_PARAM_get_utf8_string_ptr() and OSSL_PARAM_get_octet_string_ptr()
helps the programmer with such things, by setting the argument pointer
to |param->data|.
Additionally, the handle the data types OSSL_PARAM_UTF8_PTR and
OSSL_PARAM_OCTET_PTR as well.

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

3 years agoSTORE: Add the base functions to support provider based loaders
Richard Levitte [Wed, 22 Jul 2020 20:54:54 +0000 (22:54 +0200)]
STORE: Add the base functions to support provider based loaders

This includes fixing a bug that could only be discovered when no
loaders were registered.

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

3 years agoSTORE for providers: define libcrypto <-> provider interface
Richard Levitte [Wed, 22 Jul 2020 20:54:42 +0000 (22:54 +0200)]
STORE for providers: define libcrypto <-> provider interface

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

3 years agoSTORE: Add missing function OSSL_STORE_LOADER_set_open_with_libctx()
Richard Levitte [Sun, 26 Jul 2020 07:21:29 +0000 (09:21 +0200)]
STORE: Add missing function OSSL_STORE_LOADER_set_open_with_libctx()

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

3 years agoCORE: Generalise internal pass phrase prompter
Richard Levitte [Sun, 2 Aug 2020 10:14:19 +0000 (12:14 +0200)]
CORE: Generalise internal pass phrase prompter

The pass phrase prompter that's part of OSSL_ENCODER and OSSL_DECODER
is really a passphrase callback bridge between the diverse forms of
prompters that exist within OpenSSL: pem_password_cb, ui_method and
OSSL_PASSPHRASE_CALLBACK.

This can be generalised, to be re-used by other parts of OpenSSL, and
to thereby allow the users to specify whatever form of pass phrase
callback they need, while being able to pass that on to other APIs
that are called internally, in the form that those APIs demand.

Additionally, we throw in the possibility to cache pass phrases during
a "session" (we leave it to each API to define what a "session" is).
This is useful for any API that implements discovery and therefore may
need to get the same password more than once, such as OSSL_DECODER and
OSSL_STORE.

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

3 years agoCORE: Define provider-native abstract objects
Richard Levitte [Wed, 22 Jul 2020 13:34:25 +0000 (15:34 +0200)]
CORE: Define provider-native abstract objects

This is placed as CORE because the core of libcrypto is the authority
for what is possible to do and what's required to make these abstract
objects work.

In essence, an abstract object is an OSSL_PARAM array with well
defined parameter keys and values:

-   an object type, which is a number indicating what kind of
    libcrypto structure the object in question can be used with.  The
    currently possible numbers are defined in <openssl/core_object.h>.
-   an object data type, which is a string that indicates more closely
    what the contents of the object are.
-   the object data, an octet string.  The exact encoding used depends
    on the context in which it's used.  For example, the decoder
    sub-system accepts any encoding, as long as there is a decoder
    implementation that takes that as input.  If central code is to
    handle the data directly, DER encoding is assumed. (*)
-   an object reference, also an octet string.  This octet string is
    not the object contents, just a mere reference to a provider-native
    object. (**)
-   an object description, which is a human readable text string that
    can be displayed if some software desires to do so.

The intent is that certain provider-native operations (called X
here) are able to return any sort of object that belong with other
operations, or an object that has no provider support otherwise.

(*) A future extension might be to be able to specify encoding.

(**) The possible mechanisms for dealing with object references are:

-   An object loading function in the target operation.  The exact
    target operation is determined by the object type (for example,
    OSSL_OBJECT_PKEY implies that the target operation is a KEYMGMT)
    and the implementation to be fetched by its object data type (for
    an OSSL_OBJECT_PKEY, that's the KEYMGMT keytype to be fetched).
    This loading function is only useful for this if the implementations
    that are involved (X and KEYMGMT, for example) are from the same
    provider.

-   An object exporter function in the operation X implementation.
    That exporter function can be used to export the object data in
    OSSL_PARAM form that can be imported by a target operation's
    import function.  This can be used when it's not possible to fetch
    the target operation implementation from the same provider.

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

3 years agoFix coverity CID #1452770 - Dereference before NULL check in CRYPTO_siv128_init()
Shane Lontis [Tue, 11 Aug 2020 07:50:13 +0000 (17:50 +1000)]
Fix coverity CID #1452770 - Dereference before NULL check in CRYPTO_siv128_init()

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

3 years agoFix coverity CID #1452773 - Dereference before NULL check in EVP_DigestFinal_ex()
Shane Lontis [Tue, 11 Aug 2020 07:31:11 +0000 (17:31 +1000)]
Fix coverity CID #1452773 - Dereference before NULL check in EVP_DigestFinal_ex()

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

3 years agoFix coverity CID #1452775 & #1452772- Dereference before NULL check in evp_lib.c
Shane Lontis [Tue, 11 Aug 2020 07:18:31 +0000 (17:18 +1000)]
Fix coverity CID #1452775 & #1452772- Dereference before NULL check in evp_lib.c

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

3 years agoFix coverity CID #1454638 - Dereference after NULL check in EVP_MD_CTX_gettable_params()
Shane Lontis [Tue, 11 Aug 2020 07:09:18 +0000 (17:09 +1000)]
Fix coverity CID #1454638 - Dereference after NULL check in EVP_MD_CTX_gettable_params()

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

3 years agoFix coverity CID #1455335 - Dereference after NULL check in fromdata_init()
Shane Lontis [Tue, 11 Aug 2020 07:01:07 +0000 (17:01 +1000)]
Fix coverity CID #1455335 - Dereference after NULL check in fromdata_init()

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

3 years agoFix coverity CID #1458641 - Dereference before NULL check when setting ctx->flag_allo...
Shane Lontis [Tue, 11 Aug 2020 06:50:10 +0000 (16:50 +1000)]
Fix coverity CID #1458641 - Dereference before NULL check when setting ctx->flag_allow_md in rsa.c

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

3 years agoFix coverity CID #1458644 - Negative return passed to function taking size_t in ecdh_...
Shane Lontis [Tue, 11 Aug 2020 06:41:51 +0000 (16:41 +1000)]
Fix coverity CID #1458644 - Negative return passed to function taking size_t in ecdh_cms_set_shared_info()

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

3 years agoFix coverity CID #1458645 - Dereference before NULL check in rsa_digest_verify_final()
Shane Lontis [Tue, 11 Aug 2020 06:33:19 +0000 (16:33 +1000)]
Fix coverity CID #1458645 - Dereference before NULL check in rsa_digest_verify_final()

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

3 years agoFix coverity CID #1458647 - Use after free in clean_tbuf() which uses ctx->rsa
Shane Lontis [Tue, 11 Aug 2020 06:28:00 +0000 (16:28 +1000)]
Fix coverity CID #1458647 - Use after free in clean_tbuf() which uses ctx->rsa

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

3 years agoFix coverity CID #1458648 - Wrong sizeof() arg in rsa_freectx()
Shane Lontis [Tue, 11 Aug 2020 06:23:28 +0000 (16:23 +1000)]
Fix coverity CID #1458648 - Wrong sizeof() arg in rsa_freectx()

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

3 years agoFix coverity CID #1465525 - NULL pointer dereference in OSSL_DECODER_CTX_new_by_EVP_P...
Shane Lontis [Tue, 11 Aug 2020 05:56:17 +0000 (15:56 +1000)]
Fix coverity CID #1465525 - NULL pointer dereference in OSSL_DECODER_CTX_new_by_EVP_PKEY()

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

3 years agoFix coverity CID #1465531 - Negative return passed to a function param using size_t...
Shane Lontis [Tue, 11 Aug 2020 05:41:54 +0000 (15:41 +1000)]
Fix coverity CID #1465531 - Negative return passed to a function param using size_t in asn1_item_digest_with_libctx()

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

3 years agoFix coverity CID #1465790 - Dereference after NULL check in evp_test.c
Shane Lontis [Tue, 11 Aug 2020 05:36:49 +0000 (15:36 +1000)]
Fix coverity CID #1465790 - Dereference after NULL check in evp_test.c

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

3 years agoFix coverity CID #1465794 - Uninitialized pointer read in x942_encode_otherinfo()
Shane Lontis [Tue, 11 Aug 2020 05:24:52 +0000 (15:24 +1000)]
Fix coverity CID #1465794 - Uninitialized pointer read in x942_encode_otherinfo()

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

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)