openssl.git
2 years agoPrepare for release of 3.0 beta 2 openssl-3.0.0-beta2
Matt Caswell [Thu, 29 Jul 2021 14:50:29 +0000 (15:50 +0100)]
Prepare for release of 3.0 beta 2

Reviewed-by: Richard Levitte <levitte@openssl.org>
2 years agomake update
Matt Caswell [Thu, 29 Jul 2021 14:50:27 +0000 (15:50 +0100)]
make update

Reviewed-by: Richard Levitte <levitte@openssl.org>
2 years agoUpdate copyright year
Matt Caswell [Thu, 29 Jul 2021 14:41:35 +0000 (15:41 +0100)]
Update copyright year

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

2 years agoUpdate fingerprints.txt
Matt Caswell [Thu, 29 Jul 2021 10:09:05 +0000 (11:09 +0100)]
Update fingerprints.txt

Add Paul Dale as an approved release signer.

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

2 years agoAdd missing session timeout calc
Todd Short [Fri, 23 Jul 2021 13:25:09 +0000 (09:25 -0400)]
Add missing session timeout calc

Fixes #16142

Add missing session timeout calculation in `ssl_get_new_session()`

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

2 years agotest: add a comment indication that a bad MAC is intentional
Pauli [Tue, 27 Jul 2021 23:52:23 +0000 (09:52 +1000)]
test: add a comment indication that a bad MAC is intentional

This permits negative testing of FIPS module load failure.

Also changed the MAC to all zeros to make it even clearer.

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

2 years agoAdd some testing for the case where the FIPS provider fails to load
Matt Caswell [Tue, 27 Jul 2021 15:36:41 +0000 (16:36 +0100)]
Add some testing for the case where the FIPS provider fails to load

Ensure we get correct behaviour in the event that an attempt is made
to load the fips provider but it fails to load.

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

2 years agoDon't try and load the config file while already loading the config file
Matt Caswell [Tue, 27 Jul 2021 15:59:59 +0000 (16:59 +0100)]
Don't try and load the config file while already loading the config file

Calls to the API function EVP_default_properties_enable_fips() will
automatically attempt to load the default config file if it is not
already loaded. Therefore this function should not be called from inside
code to process the config file.

Fixes #16165

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

2 years agoEnsure any default_properties still apply even in the event of a provider load failure
Matt Caswell [Tue, 27 Jul 2021 15:36:24 +0000 (16:36 +0100)]
Ensure any default_properties still apply even in the event of a provider load failure

We don't treat a failure to load a provider as a fatal error. If it is fatal then
we give up attempting to load the config file - including reading any default
properties. Additionally if an attempt has been made to load a provider then we
disable fallback loading.

Fixes #16166

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

2 years agoDon't leak the OSSL_LIB_CTX in the event of a failure to load the FIPS module
Matt Caswell [Tue, 27 Jul 2021 15:31:20 +0000 (16:31 +0100)]
Don't leak the OSSL_LIB_CTX in the event of a failure to load the FIPS module

Ensure we free the OSSL_LIB_CTX on the error path.

Fixes #16163

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

2 years agoci: disable async for the SH4 build and reenable the associated test
Pauli [Mon, 26 Jul 2021 02:54:50 +0000 (12:54 +1000)]
ci: disable async for the SH4 build and reenable the associated test

The platform doesn't seem to have support for this.

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

2 years agoci: get rid of no-asm flag to m68k cross compiles
Pauli [Mon, 26 Jul 2021 01:57:48 +0000 (11:57 +1000)]
ci: get rid of no-asm flag to m68k cross compiles

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

2 years agoci: add the param conversion tests to the cross compiles.
Pauli [Mon, 26 Jul 2021 01:54:12 +0000 (11:54 +1000)]
ci: add the param conversion tests to the cross compiles.

There was a failure because an "inf" values was being read as a "NaN" not an
infinity.

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

2 years agoQEMU: include test runs for most cross compilation targets
Pauli [Fri, 23 Jul 2021 01:48:32 +0000 (11:48 +1000)]
QEMU: include test runs for most cross compilation targets

For the cross compiles where the tests couldn't be run, most are capable
of being run when statically linked.  For these, a shared with FIPS build
but not test run is also included to maximise compilation coverage.
The builds take a couple of minutes so the impact of these extra jobs
isn't great.

The test failures for test_includes, test_store and test_x509_store
across several platforms are related the the OPENSSL_DIR_read() call.
This gets a "Value too large for defined data type" error calling the
standard library's readdir() wrapper.  That is, the failure is during
the translation from the x86-64 structure to the 32 bit structure.
I've tried tweaking the include defines to use larger fields but couldn't
figure out how to make it work.  The most prudent fix is to ignore these
tests for these platforms.

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

2 years agotest: handle not a number (NaN) values in the param conversion test.
Pauli [Mon, 26 Jul 2021 01:53:23 +0000 (11:53 +1000)]
test: handle not a number (NaN) values in the param conversion test.

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

2 years agoAdd a test case for EVP_MD_meth_dup() and EVP_CIPHER_meth_dup()
Matt Caswell [Tue, 27 Jul 2021 09:32:49 +0000 (10:32 +0100)]
Add a test case for EVP_MD_meth_dup() and EVP_CIPHER_meth_dup()

Check that EVP_MD_meth_free() and EVP_CIPHER_meth_free() does actually
free the data.

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

2 years agoFix EVP_MD_meth_dup and EVP_CIPHER_meth_dup
Matt Caswell [Mon, 26 Jul 2021 14:53:25 +0000 (15:53 +0100)]
Fix EVP_MD_meth_dup and EVP_CIPHER_meth_dup

Make sure the origin is set correctly when duping an EVP_MD or EVP_CIPHER.

Fixes #16157

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

2 years agoMark the EVP_PKEY_METHOD arg as const on some EVP_PKEY_meth_get_*() funcs
Matt Caswell [Tue, 20 Jul 2021 15:18:04 +0000 (16:18 +0100)]
Mark the EVP_PKEY_METHOD arg as const on some EVP_PKEY_meth_get_*() funcs

Most EVP_PKEY_meth_get_*() functions mark the EVP_PKEY_METHOD argument as
const. But 3 did not. We fix those to be consistent.

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

2 years agoKTLS: AES-CCM in TLS-1.3 is broken on 5.x kernels, disable it
Tomas Mraz [Tue, 20 Jul 2021 11:08:31 +0000 (13:08 +0200)]
KTLS: AES-CCM in TLS-1.3 is broken on 5.x kernels, disable it

Fixes #16089

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

2 years agoTest ktls in non-default options CI build
Tomas Mraz [Tue, 20 Jul 2021 10:23:24 +0000 (12:23 +0200)]
Test ktls in non-default options CI build

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

2 years agoDrop no-ktls from runchecker daily build as it has no effect
Tomas Mraz [Tue, 20 Jul 2021 10:22:57 +0000 (12:22 +0200)]
Drop no-ktls from runchecker daily build as it has no effect

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

2 years agoECDSA_SIG_set0(): Clarify documentation and fix formatting errors
Tomas Mraz [Thu, 22 Jul 2021 07:32:56 +0000 (09:32 +0200)]
ECDSA_SIG_set0(): Clarify documentation and fix formatting errors

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

2 years agoECDSA_SIG_set0: r and s parameters cannot be NULL
Tomas Mraz [Wed, 21 Jul 2021 14:42:55 +0000 (16:42 +0200)]
ECDSA_SIG_set0: r and s parameters cannot be NULL

Fixes #7731

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

2 years agoDOCS: Move the description of EVP_PKEY_get0_description()
Richard Levitte [Tue, 13 Jul 2021 09:15:29 +0000 (11:15 +0200)]
DOCS: Move the description of EVP_PKEY_get0_description()

It appears to have been misplaced

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

2 years agoEVP: Add EVP_PKEY_get0_provider() and EVP_PKEY_CTX_get0_provider()
Richard Levitte [Tue, 13 Jul 2021 08:40:45 +0000 (10:40 +0200)]
EVP: Add EVP_PKEY_get0_provider() and EVP_PKEY_CTX_get0_provider()

Fixes #16058

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

2 years agoFix potential problems with EVP_PKEY_CTX_new() with engine set
Tomas Mraz [Thu, 22 Jul 2021 13:01:53 +0000 (15:01 +0200)]
Fix potential problems with EVP_PKEY_CTX_new() with engine set

If an engine is non-NULL in EVP_PKEY_CTX_new() call an assert might
have been incorrectly triggered or the engine might be finished
without being inited.

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

2 years agodo_sigver_init: Add missing ERR_clear_last_mark()
Tomas Mraz [Thu, 22 Jul 2021 13:25:32 +0000 (15:25 +0200)]
do_sigver_init: Add missing ERR_clear_last_mark()

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

2 years agoci: QEMU based cross compiled testing
Pauli [Thu, 22 Jul 2021 09:13:41 +0000 (19:13 +1000)]
ci: QEMU based cross compiled testing

With a little set up, Debian provides an ability to use QEMU to execute
programs compiled for other architectures. Using this, most of our cross
compilation CI builds can be executed.

This PR does this.

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

2 years agoci: reinstate the passwd tests for the no-cached-fetch run.
Pauli [Thu, 22 Jul 2021 00:56:29 +0000 (10:56 +1000)]
ci: reinstate the passwd tests for the no-cached-fetch run.

By selectively skipping the high round test cases, the out of memory problem
can be avoided.

partially fixes #16127

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

2 years agoMakefile: Avoid changing LIBDIR based on whether it already exists
jenda1 [Tue, 20 Jul 2021 14:32:49 +0000 (16:32 +0200)]
Makefile: Avoid changing LIBDIR based on whether it already exists

unix-Makefile.tmpl checks if the target LIBDIR exists on the build
machine or not and based on the result modify the final LIBDIR.
This should be avoided, build results should not depend on the build
machine root filesystem layout. It makes the build results unstable.

The fix simply removes the dir existence test from the unix-Makefile.tmpl.

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

2 years agoDSA/RSA_print(): Fix potential memory leak
Tomas Mraz [Wed, 21 Jul 2021 16:45:01 +0000 (18:45 +0200)]
DSA/RSA_print(): Fix potential memory leak

Fixes #10777

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

2 years agoAdd a test for custom EVP_PKEY_METHODs
Matt Caswell [Tue, 20 Jul 2021 15:18:58 +0000 (16:18 +0100)]
Add a test for custom EVP_PKEY_METHODs

Adds a test for using custom EVP_PKEY_METHODs without an ENGINE. As part
of this we also test having a custom EVP_PKEY_METHOD that wraps a built-in
EVP_PKEY_METHOD. We do this for both legacy and provided keys.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16118)

2 years agoFix custom EVP_PKEY_METHOD implementations where no engine is present
Matt Caswell [Mon, 19 Jul 2021 15:17:50 +0000 (16:17 +0100)]
Fix custom EVP_PKEY_METHOD implementations where no engine is present

It is possible to have a custom EVP_PKEY_METHOD implementation without
having an engine. In those cases we were failing to use that custom
implementation.

Fixes #16088

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16118)

2 years agoUpdate our EVP_PKEY_METHODs to get low level keys via public APIs
Matt Caswell [Tue, 20 Jul 2021 08:58:53 +0000 (09:58 +0100)]
Update our EVP_PKEY_METHODs to get low level keys via public APIs

It is possible to call built-in EVP_PKEY_METHOD functions with a provided
key. For example this might occur if a custom EVP_PKEY_METHOD is in use
that wraps a built-in EVP_PKEY_METHOD. Therefore our EVP_PKEY_METHOD
functions should not assume that we are using a legacy key. Instead we
get the low level key using EVP_PKEY_get0_RSA() or other similar functions.
This "does the right thing" if the key is actually provided.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16118)

2 years agoOSSL_HTTP_open(): Fix memory leak on TLS connect failure via proxy
Dr. David von Oheimb [Tue, 20 Jul 2021 09:19:39 +0000 (11:19 +0200)]
OSSL_HTTP_open(): Fix memory leak on TLS connect failure via proxy

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

2 years agoci: omit tests that consume too much memory
Pauli [Wed, 21 Jul 2021 09:25:22 +0000 (19:25 +1000)]
ci: omit tests that consume too much memory

The SSL API tests and the passwd command test trigger memory leakage in the
address sanitizer.

Fixes #16116

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

2 years agotls_process_{client,server}_certificate(): allow verify_callback return > 1
Dr. David von Oheimb [Wed, 27 Jan 2021 21:13:30 +0000 (22:13 +0100)]
tls_process_{client,server}_certificate(): allow verify_callback return > 1

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

2 years agoSSL_CTX_set_cert_verify_callback.pod: various corrections and clarifications
Dr. David von Oheimb [Fri, 22 Jan 2021 21:34:56 +0000 (22:34 +0100)]
SSL_CTX_set_cert_verify_callback.pod: various corrections and clarifications

- Make clear the callback is called whenever a peer certificate has been received,
  which is independent of the verification mode.
- Make clear that a return value > 1 always leads to handshake failure.
- Make clear that in server mode also return values <= 0 lead to handshake failure.
- For client mode replace the incorrect formulation "if B<SSL_VERIFY_PEER> is set"
  by what is actually implemented: "if the verification mode is not B<SSL_VERIFY_NONE>".
- Refer to X509_STORE_CTX_set_error() rather than to internal error variable.

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

2 years agoAdd testcases for SSL_key_update() corner case calls
yangyangtiantianlonglong [Thu, 15 Jul 2021 12:15:36 +0000 (20:15 +0800)]
Add testcases for SSL_key_update() corner case calls

Test that SSL_key_update() is not allowed if there are writes pending.
Test that there is no reset of the packet pointer in ssl3_setup_read_buffer().

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

2 years agotest: include all DRBG tests in FIPS mode
Pauli [Fri, 16 Jul 2021 01:58:46 +0000 (11:58 +1000)]
test: include all DRBG tests in FIPS mode

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

2 years agodocs: update CTR DRBG documentation to not mention the lack of a derivation function...
Pauli [Fri, 16 Jul 2021 01:54:14 +0000 (11:54 +1000)]
docs: update CTR DRBG documentation to not mention the lack of a derivation function in FIPS

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

2 years agoerr: remove the derivation function is mandatory for FIPS error message since it...
Pauli [Fri, 16 Jul 2021 01:52:30 +0000 (11:52 +1000)]
err: remove the derivation function is mandatory for FIPS error message since it's no longer used and newly introduced

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

2 years agodrbg: allow the ctr derivation function to be disabled in FIPS mode
Pauli [Fri, 16 Jul 2021 01:38:23 +0000 (11:38 +1000)]
drbg: allow the ctr derivation function to be disabled in FIPS mode

Word from the lab is:

    The use of the derivation function is optional if either an approved
    RBG or an entropy source provides full entropy output when entropy
    input is requested by the DRBG mechanism. Otherwise, the derivation
    function shall be used.

So our disallowing it's use was more than required.

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

2 years agoFix a read buffer overrun in X509_aux_print().
Ingo Schwarze [Sun, 18 Jul 2021 15:48:06 +0000 (17:48 +0200)]
Fix a read buffer overrun in X509_aux_print().

The ASN1_STRING_get0_data(3) manual explitely cautions the reader
that the data is not necessarily NUL-terminated, and the function
X509_alias_set1(3) does not sanitize the data passed into it in any
way either, so we must assume the return value from X509_alias_get0(3)
is merely a byte array and not necessarily a string in the sense
of the C language.

I found this bug while writing manual pages for X509_print_ex(3)
and related functions.  Theo Buehler <tb@openbsd.org> checked my
patch to fix the same bug in LibreSSL, see

http://cvsweb.openbsd.org/src/lib/libcrypto/asn1/t_x509a.c#rev1.9

As an aside, note that the function still produces incomplete and
misleading results when the data contains a NUL byte in the middle
and that error handling is consistently absent throughout, even
though the function provides an "int" return value obviously intended
to be 1 for success and 0 for failure, and even though this function
is called by another function that also wants to return 1 for success
and 0 for failure and even does so in many of its code paths, though
not in others.  But let's stay focussed.  Many things would be nice
to have in the wide wild world, but a buffer overflow must not be
allowed to remain in our backyard.

CLA: trivial

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

2 years agodoc: fix OPENSSL_VERSION_NUMBER length in the synopsis
Petr Gotthard [Sun, 18 Jul 2021 12:19:11 +0000 (14:19 +0200)]
doc: fix OPENSSL_VERSION_NUMBER length in the synopsis

The number has 8 digits (not 9). It is a single integer `0xMNN00PP0L`.

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

2 years agodemos: update readme file with pbkdf2 and scrypt examples.
Pauli [Mon, 19 Jul 2021 03:17:02 +0000 (13:17 +1000)]
demos: update readme file with pbkdf2 and scrypt examples.

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

2 years agodemos: add Makefile support for pbkdf2 and scrypt KDF demos
Pauli [Mon, 19 Jul 2021 03:00:38 +0000 (13:00 +1000)]
demos: add Makefile support for pbkdf2 and scrypt KDF demos

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

2 years agodemo: add scrypt demonstration program
Pauli [Mon, 19 Jul 2021 03:00:23 +0000 (13:00 +1000)]
demo: add scrypt demonstration program

Using test vector from RTC 7914

Fixes #14108

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

2 years agodemo: add pbkdf2 demonstration program
Pauli [Mon, 19 Jul 2021 03:00:06 +0000 (13:00 +1000)]
demo: add pbkdf2 demonstration program

Using test vector from RTC 7914

Fixes #14107

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

2 years agotest: fix use after scope problem in ACVP test
Pauli [Sat, 17 Jul 2021 14:47:09 +0000 (00:47 +1000)]
test: fix use after scope problem in ACVP test

Repeat after me:
    thou shall not use an auto scope variable as a parameter
    that is used out of scope.

Fixes GitHub CI #6305

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

2 years agoFix some minor record layer issues
Matt Caswell [Thu, 15 Jul 2021 13:08:56 +0000 (14:08 +0100)]
Fix some minor record layer issues

Various comments referred to s->packet and s->packet_length instead of
s->rlayer.packet and s->rlayer.packet_length. Also fixed is a spot where
RECORD_LAYER_write_pending() should have been used. Based on the review
comments in #16077.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/16086)

2 years agoFix signed/unsigned comparison warnings in sslapitest
Matt Caswell [Wed, 14 Jul 2021 14:36:12 +0000 (15:36 +0100)]
Fix signed/unsigned comparison warnings in sslapitest

Fixes build failures if using enable-ktls in conjunction with --strict-warnings

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

2 years agoconfig: enable ACVP test case if FIPS is enabled.
Pauli [Fri, 16 Jul 2021 00:31:41 +0000 (10:31 +1000)]
config: enable ACVP test case if FIPS is enabled.

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

2 years agodoc: It is not possible to use SSL_OP_* value in preprocessor conditions
Tomas Mraz [Thu, 15 Jul 2021 11:37:26 +0000 (13:37 +0200)]
doc: It is not possible to use SSL_OP_* value in preprocessor conditions

Fixes #16082

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

2 years agoDisallow SSL_key_update() if there are writes pending
Matt Caswell [Tue, 13 Jul 2021 16:44:44 +0000 (17:44 +0100)]
Disallow SSL_key_update() if there are writes pending

If an application is halfway through writing application data it should
not be allowed to attempt an SSL_key_update() operation. Instead the
SSL_write() operation should be completed.

Fixes #12485

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

2 years agoDon't reset the packet pointer in ssl3_setup_read_buffer
Matt Caswell [Tue, 13 Jul 2021 16:19:12 +0000 (17:19 +0100)]
Don't reset the packet pointer in ssl3_setup_read_buffer

Sometimes this function gets called when the buffers have already been
set up. If there is already a partial packet in the read buffer then the
packet pointer will be set to an incorrect value. The packet pointer already
gets reset to the correct value when we first read a packet anyway, so we
don't also need to do it in ssl3_setup_read_buffer.

Fixes #13729

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

2 years agoRSA_public_decrypt is equivalent to a verify recover operation
Tomas Mraz [Thu, 15 Jul 2021 07:30:23 +0000 (09:30 +0200)]
RSA_public_decrypt is equivalent to a verify recover operation

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

2 years agoevp_test: Add tests for rsa_padding_mode:none
Tomas Mraz [Wed, 14 Jul 2021 10:45:30 +0000 (12:45 +0200)]
evp_test: Add tests for rsa_padding_mode:none

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

2 years agoAllow RSA signature operations with RSA_NO_PADDING
Tomas Mraz [Tue, 13 Jul 2021 13:28:24 +0000 (15:28 +0200)]
Allow RSA signature operations with RSA_NO_PADDING

When no md is set, the raw operations should be allowed.

Fixes #16056

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

2 years agoDrop daily run-checker build with just enable-acvp-tests
Tomas Mraz [Wed, 14 Jul 2021 13:51:29 +0000 (15:51 +0200)]
Drop daily run-checker build with just enable-acvp-tests

Having just enable-acvp-tests without enable-fips does not make
much sense as this just builds the test but it is skipped.

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

2 years agoCI: have enable-acvp-tests in some CI build
Tomas Mraz [Wed, 14 Jul 2021 13:49:31 +0000 (15:49 +0200)]
CI: have enable-acvp-tests in some CI build

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

2 years agoSignature algos: allow having identical digest in params
Tomas Mraz [Wed, 14 Jul 2021 13:41:22 +0000 (15:41 +0200)]
Signature algos: allow having identical digest in params

The flag_allow_md prevents setting a digest in params however
this is unnecessarily strict. If the digest is the same as the
one already set, we do not return an error.

Fixes #16071

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

2 years agoacvp_test: Fix incorrect parenthesis
Tomas Mraz [Wed, 14 Jul 2021 13:41:00 +0000 (15:41 +0200)]
acvp_test: Fix incorrect parenthesis

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

2 years agoapps: Use the first detected address family if IPv6 is not available
Daiki Ueno [Wed, 14 Jul 2021 09:15:34 +0000 (11:15 +0200)]
apps: Use the first detected address family if IPv6 is not available

This is a follow up of 15729bef385211bc2a0497e2d53a45c45d677d2c.  Even
when the host does not support IPv6 at all, BIO_lookup_ex may now
return IN6ADDR_ANY in addition to INADDR_ANY, as the second element of
the ai_next field.

After eee8a40aa5e06841eed6fa8eb4f6109238d59aea, the do_server function
prefers the IPv6 address and fails on the BIO_socket call.  This adds
a fallback code to retry with the IPv4 address returned as the first
element to avoid the error.

The failure had been partially avoided in the previous code with
AI_ADDRCONFIG, because getaddrinfo returns only IPv4 address if no
IPv6 address is associated with external interface.  However, it would
be still a problem if the external interface has an IPv6 address
assigned, while the loopback interface doesn't.

Signed-off-by: Daiki Ueno <dueno@redhat.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16074)

2 years agoSplit bignum code out of the sparcv9cap.c
Tomas Mraz [Wed, 7 Jul 2021 15:47:06 +0000 (17:47 +0200)]
Split bignum code out of the sparcv9cap.c

Fixes #15978

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

2 years agodoc: document the params arguments to the initialisation functions.
Pauli [Wed, 14 Jul 2021 00:03:45 +0000 (10:03 +1000)]
doc: document the params arguments to the initialisation functions.

These were accidentally omitted when the arguments were added globally.

Fixes #16067

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

2 years agoevp: constify some OSSL_PARAM arguments
Pauli [Wed, 14 Jul 2021 00:03:22 +0000 (10:03 +1000)]
evp: constify some OSSL_PARAM arguments

These were missed when the initialisation params were added

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

2 years agoMake EVP_PKEY_check() be an alias for EVP_PKEY_pairwise_check()
Tomas Mraz [Tue, 13 Jul 2021 15:41:02 +0000 (17:41 +0200)]
Make EVP_PKEY_check() be an alias for EVP_PKEY_pairwise_check()

The implementation of EVP_PKEY_pairwise_check() is also changed
to handle the legacy keys.

Fixes #16046

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

2 years agodoc: Document that incomplete certificates return error
Tomas Mraz [Tue, 13 Jul 2021 15:59:37 +0000 (17:59 +0200)]
doc: Document that incomplete certificates return error

Fixes #16065

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

2 years agotest: add single byte IV AES GCM tests
Pauli [Tue, 13 Jul 2021 08:55:36 +0000 (18:55 +1000)]
test: add single byte IV AES GCM tests

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

2 years agoRemove lower limit on GCM mode ciphers
Pauli [Tue, 13 Jul 2021 08:40:01 +0000 (18:40 +1000)]
Remove lower limit on GCM mode ciphers

Fixes #16057

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

2 years agoapps: avoid using POSIX IO macros and functions when built without them.
Pauli [Wed, 14 Jul 2021 01:02:57 +0000 (11:02 +1000)]
apps: avoid using POSIX IO macros and functions when built without them.

Fall back to stdio functions if not available.

Fixes a daily run-checker failure (no-posix-io)

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

2 years agoFix OSSL_TRACE9 missing arg9
Syrone Wong [Tue, 13 Jul 2021 02:04:56 +0000 (10:04 +0800)]
Fix OSSL_TRACE9 missing arg9

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
CLA: trivial

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16060)

2 years agoAvoid empty lines in nmake rule bodies
Richard Levitte [Mon, 12 Jul 2021 05:29:02 +0000 (07:29 +0200)]
Avoid empty lines in nmake rule bodies

nmake is tolerant of those empty lines, but jom isn't.  That tolerance
isn't standard make behaviour, so we lean towards avoiding them.

We simply use '@rem' instead.

Fixes #16014

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

2 years agoRemove executable mode attributes of non-executable files
Tianjia Zhang [Mon, 12 Jul 2021 03:22:59 +0000 (11:22 +0800)]
Remove executable mode attributes of non-executable files

Remove the executable attributes of some C code files and key files,
change the file mode from 0755 to 0644.

Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16045)

2 years agoasn.1: fix Coverity 1487104 Logically dead code
Pauli [Sun, 11 Jul 2021 10:53:43 +0000 (20:53 +1000)]
asn.1: fix Coverity 1487104 Logically dead code

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

2 years agodoc: document the new opt_legacy_okay() function's behaviour
Pauli [Thu, 8 Jul 2021 01:38:06 +0000 (11:38 +1000)]
doc: document the new opt_legacy_okay() function's behaviour

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

2 years agoapp: add library context and propq arguments to opt_md() and opt_cipher()
Pauli [Thu, 8 Jul 2021 01:25:11 +0000 (11:25 +1000)]
app: add library context and propq arguments to opt_md() and opt_cipher()

Also avoid calling EVP_get_XXXbyname() if legacy paths aren't allowed.

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

2 years agoapps: add a function opt_legacy_okay() that indicates if legacy paths are permitted...
Pauli [Thu, 8 Jul 2021 01:24:05 +0000 (11:24 +1000)]
apps: add a function opt_legacy_okay() that indicates if legacy paths are permitted or not

By default they are.  However, if a provider, provider path or a property query has been specified
they are not.  Likewise, if a library context or a property query has been
specified by the command, they are not.

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

2 years agoapps: add query to allow a command to know of a provider command line option was...
Pauli [Thu, 8 Jul 2021 01:22:14 +0000 (11:22 +1000)]
apps: add query to allow a command to know of a provider command line option was processed

Better fixing:
Fixing #15683
Fixing #15686

Replacing rather than fixing:
Fixing #15414

Since that claims to fix another:
Fixing #15372

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

2 years agotest: make build descriptions more consistent
Pauli [Thu, 8 Jul 2021 01:09:39 +0000 (11:09 +1000)]
test: make build descriptions more consistent

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

2 years agotest: add a shim function for the apps's opt_legacy_okay() function
Pauli [Thu, 8 Jul 2021 00:55:01 +0000 (10:55 +1000)]
test: add a shim function for the apps's opt_legacy_okay() function

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

2 years agotest: rename apps_mem.c to be apps_shims.c in anticipation of additonal functions
Pauli [Thu, 8 Jul 2021 00:53:05 +0000 (10:53 +1000)]
test: rename apps_mem.c to be apps_shims.c in anticipation of additonal functions

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

2 years agoFix legacy OCSP_REQ_CTX_http() function to expect ASN.1 formatted input
Dr. David von Oheimb [Thu, 8 Jul 2021 17:44:47 +0000 (19:44 +0200)]
Fix legacy OCSP_REQ_CTX_http() function to expect ASN.1 formatted input

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

2 years agoImprove doc of OSSL_HTTP_REQ_CTX_set_expected() on timeout param < 0
Dr. David von Oheimb [Thu, 8 Jul 2021 17:45:35 +0000 (19:45 +0200)]
Improve doc of OSSL_HTTP_REQ_CTX_set_expected() on timeout param < 0

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

2 years agoBIO_lookup_ex: use AI_ADDRCONFIG only if explicit host name is given
Daiki Ueno [Thu, 8 Jul 2021 17:22:36 +0000 (19:22 +0200)]
BIO_lookup_ex: use AI_ADDRCONFIG only if explicit host name is given

The flag only affects which record types are queried via DNS (A or
AAAA, or both).  When node is NULL and AF_UNSPEC is used, it prevents
getaddrinfo returning the right address associated with the loopback
interface.

Signed-off-by: Daiki Ueno <dueno@redhat.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/16033)

2 years agotest_cmp_ctx: Avoid using empty X509 with i2d
Tomas Mraz [Fri, 9 Jul 2021 13:48:02 +0000 (15:48 +0200)]
test_cmp_ctx: Avoid using empty X509 with i2d

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

2 years agoFix test/asn1_encode_test.c to handle encoding/decoding failure
Richard Levitte [Fri, 9 Jul 2021 06:51:55 +0000 (08:51 +0200)]
Fix test/asn1_encode_test.c to handle encoding/decoding failure

Make it only report (and fail on) encoding/decoding failures when success
is expected.

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

2 years agoFix test/asn1_encode_test.c to not use ASN1_FBOOLEAN
Richard Levitte [Fri, 9 Jul 2021 06:31:24 +0000 (08:31 +0200)]
Fix test/asn1_encode_test.c to not use ASN1_FBOOLEAN

ASN1_FBOOLEAN is designed to use as a default for optional ASN1 items.
This test program used it for non-optional items, which doesn't encode
well.

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

2 years agoASN.1: Refuse to encode to DER if non-optional items are missing
Richard Levitte [Thu, 8 Jul 2021 11:38:45 +0000 (13:38 +0200)]
ASN.1: Refuse to encode to DER if non-optional items are missing

Fixes #16026

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

2 years agoTEST: Check that i2d refuses to encode non-optional items with no content
Richard Levitte [Thu, 8 Jul 2021 11:33:28 +0000 (13:33 +0200)]
TEST: Check that i2d refuses to encode non-optional items with no content

The test case creates an RSA public key and tries to pass it through
i2d_PrivateKey().  This SHOULD fail, since the private bits are missing.

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

2 years agoConfigurations/unix-Makefile.tmpl: use platform->sharedlib() as fallback
Richard Levitte [Thu, 8 Jul 2021 17:05:34 +0000 (19:05 +0200)]
Configurations/unix-Makefile.tmpl: use platform->sharedlib() as fallback

If platform->sharedlib_simple() and platform->sharedlib_import()
return undefined, try platform->sharedlib() as a fallback before
platform->staticlib().

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

2 years agoplatform->sharedlib_simple(): return undef when same as platform->sharedlib()
Richard Levitte [Thu, 8 Jul 2021 03:18:25 +0000 (05:18 +0200)]
platform->sharedlib_simple(): return undef when same as platform->sharedlib()

On some Unix-like platforms, there is no such thing as versioned shared
libraries.  In this case, platform->sharedlib_simple() should simply
return undef.  Among others, this avoids the shared libraries to be
installed as symlinks on themselves.

Fixes #16012

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

2 years agoFix s_server PSK handling
Matt Caswell [Tue, 6 Jul 2021 15:24:07 +0000 (16:24 +0100)]
Fix s_server PSK handling

Issue #15951 describes a scenario which causes s_server to fail when using
a PSK. In the originally described issue this only impacted master and not
1.1.1. However, in fact this issue does also impact 1.1.1 - but only if you
additionally supply the option "-no_ticket" to the s_server command line.

The difference between the behaviour in master and 1.1.1 is due to 9c13b49,
which changed PSK_MAX_IDENTITY_LEN from 128 to 256. It just so happens that
a default OpenSSL TLSv1.3 ticket length happens to fall between those 2
values. Tickets are presented in TLSv1.3 as a PSK "identity". Passing
"no_ticket" doesn't actually stop TLSv1.3 tickets completely, it just
forces the use of "session ids as a ticket" instead. This significantly
reduces the ticket size to below 128 in 1.1.1.

The problem was due to s_server setting a TLSv1.2 PSK callback and a
TLSv1.3 PSK callback. For backwards compat reasons the TLSv1.2 PSK
callbacks also work in TLSv1.3 but are not preferred. In the described
scenario we use a PSK to create the initial connection. Subsequent to that
we attempt a resumption using a TLSv1.3 ticket (psk). If the psk length is
below PSK_MAX_IDENTITY_LEN then we first call the TLSv1.2 PSK callback.
Subsequently we call the TLSv1.3 PSK callback. Unfortunately s_server's
TLSv1.2 PSK callback accepts the identity regardless, even though it is an
unexpected value, and hence the binder subsequently fails to verify.

The fix is to bail early in the TLSv1.2 callback if we detect we are being
called from a TLSv1.3 connection.

Fixes #15951

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16008)

2 years agoAdd a PKCS12 test to check with one input cert we get one output cert
Matt Caswell [Tue, 6 Jul 2021 10:31:28 +0000 (11:31 +0100)]
Add a PKCS12 test to check with one input cert we get one output cert

Following on from the regression in issue #15983, add a test that with
one input cert, we get one cert in the pkcs12 file, and that it has the
expected friendlyName.

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

2 years agoDon't add the first pkcs12 certificate multiple times
Matt Caswell [Mon, 5 Jul 2021 16:19:59 +0000 (17:19 +0100)]
Don't add the first pkcs12 certificate multiple times

This fixes a regression introduced by commit 1d6c867. When exporting a set
of certificates to a PKCS12 file we shouldn't add the first one twice. Also
we restore historic behaviour with respect to the canames option where we
have no ee certificate with key.

Fixes #15983

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

2 years agoapps: fix Coverity 1451531 Unchecked return value
Pauli [Mon, 5 Jul 2021 08:30:27 +0000 (18:30 +1000)]
apps: fix Coverity 1451531 Unchecked return value

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/15994)

2 years agoevp: detect and raise an error if no digest is found for a sign/verify operation
Pauli [Wed, 7 Jul 2021 06:32:16 +0000 (16:32 +1000)]
evp: detect and raise an error if no digest is found for a sign/verify operation

If no digest is specified, the code looks for a default digest per PKEY via the
evp_keymgmt_util_get_deflt_digest_name() call.  If this call returns NULL,
indicating no digest found, the code continues regardless.  If the verify/sign
init later fails, it returns an error without raising one.  This change raises
an error in this case.

Fixes #15372

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

2 years agoFix compile warning with GCC 11.
Juergen Christ [Mon, 5 Jul 2021 07:48:53 +0000 (09:48 +0200)]
Fix compile warning with GCC 11.

When configured with strict warnings, GCC 11 complains about a possible
stringop-translation:

Config:

/usr/bin/perl ./Configure enable-asan enable-ubsan enable-zlib-dynamic \
enable-unit-test enable-md2 enable-rc5 enable-buildtest-c++ \
enable-weak-ssl-ciphers enable-ssl3 enable-ssl3-method enable-fips -w \
--strict-warnings

Warning:

crypto/evp/ctrl_params_translate.c: In function 'fix_rsa_pss_saltlen':
crypto/evp/ctrl_params_translate.c:1356:13: error: 'strncpy' specified bound 50 equals destination size [-Werror=stringop-truncation]
 1356 |             strncpy(ctx->name_buf, str_value_map[i].ptr, sizeof(ctx->name_buf));
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fix by copying one byte less than the buffer size.  We anyway overwrite the
last byte.

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

2 years agoMade foreign bit field unsigned in evp.h
Randall S. Becker [Tue, 6 Jul 2021 17:42:22 +0000 (12:42 -0500)]
Made foreign bit field unsigned in evp.h

Fixes #16010

Signed-off-by: Randall S. Becker <rsbecker@nexbridge.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16011)