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

2 years agoFix bug in X509_print_ex
Rich Salz [Tue, 6 Jul 2021 16:00:19 +0000 (12:00 -0400)]
Fix bug in X509_print_ex

If the user set nmflags == XN_FLAG_COMPAT and X509_NAME_print_ex(3)
failed, the error return value of 0 was misinterpreted as an indicator
of success, causing X509_print_ex(3) to ignore the error, continue
printing, and potentially return successfully even though not all
the content of the certificate was printed.

The X509_NAME_print_ex(3) manual page explains that this function
indicates failure by returning 0 if nmflags == XN_FLAG_COMPAT
and by returning -1 if nmflags != XN_FLAG_COMPAT.

Note that just checking for <= 0 in all cases would not be correct
either because X509_NAME_print_ex(3) returns 0 to indicate that it
successfully printed zero bytes in some cases, for example when all
three of the following conditions hold:
1. nmflags != XN_FLAG_COMPAT
2. indent == 0 (which X509_print_ex(3) does use in some cases)
3. the name object is NULL or empty

Thanks to Ingo Schwarze <schwarze@openbsd.org> for finding the bug,
and Joel Sing <jsing@openbsd.org> for contributing an idea for the
fix.

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

2 years agoFix comment for test_negotiated_group() test order
Benjamin Kaduk [Tue, 6 Jul 2021 14:49:39 +0000 (07:49 -0700)]
Fix comment for test_negotiated_group() test order

Because of how the 'client_multi' variable is set, we end up
running the tests where the client configures multiple groups (and
the server only configures one) before the ones where the server configures
multiple groups (and the client only configures one).

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

2 years agoCRYPTO: Remove the check for built-in methods in the export_to function
Richard Levitte [Tue, 6 Jul 2021 06:44:37 +0000 (08:44 +0200)]
CRYPTO: Remove the check for built-in methods in the export_to function

That check was seen as necessary at the time, but other changes have
been made since, so we now have better control on when we're handling
legacy structures and methods, making it safe to run the export_to
function on keys with foreign methods.

The basic message is that foreign methods must set key structure
values according to our standards no matter what, or not set them at
all.  This has really always been the case, but was harder to see at
the time because of interaction with other bugs.

Fixes #15927

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

2 years agobn: procduce correct sign for result of BN_mod()
Pauli [Mon, 5 Jul 2021 01:01:59 +0000 (11:01 +1000)]
bn: procduce correct sign for result of BN_mod()

There is a problem that appears when calling BN_div(a, c, a, b) with negative b.
In this case, the sign of the remainder c is incorrect.  The problem only
occurs if the dividend and the quotient are the same BIGNUM.

Fixes #15982

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

2 years agochanges: add entry noting the removal of ERR_GET_FUNC()
Pauli [Tue, 6 Jul 2021 09:00:04 +0000 (19:00 +1000)]
changes: add entry noting the removal of ERR_GET_FUNC()

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

2 years agodoc: update documentation to note removal of ERR_GET_FUNC()
Pauli [Tue, 6 Jul 2021 08:54:39 +0000 (18:54 +1000)]
doc: update documentation to note removal of ERR_GET_FUNC()

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

2 years agoerr: remove ERR_GET_FUNC()
Pauli [Tue, 6 Jul 2021 08:50:11 +0000 (18:50 +1000)]
err: remove ERR_GET_FUNC()

This is problematic in 3.0 because the function codes are all defined as zero.
This leads to either every error matching or no error ever matching.  Both
are problematic for users.  The OTC vote resolved to remove this function
completely.

Fixes #15946

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

2 years agotest: add some integral type size sanity checks
Pauli [Fri, 18 Jun 2021 23:54:55 +0000 (09:54 +1000)]
test: add some integral type size sanity checks

With the recent problem on VMS of maxint_t being defined as a 32 bit integer
despite OpenSSL mandating 64 bit integers being available, it seems prudent
to add some sanity checks for out integral types.

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

2 years agoutil: add -fips option to wrap.pl to make using the FIPS provider easier
Pauli [Thu, 1 Jul 2021 02:48:30 +0000 (12:48 +1000)]
util: add -fips option to wrap.pl to make using the FIPS provider easier

Without this option, I find I need to figure out which environment variables
point where which wastes effort.

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

2 years agoAdd HKDF negative tests
Shane Lontis [Fri, 2 Jul 2021 04:26:07 +0000 (14:26 +1000)]
Add HKDF negative tests

Fix memory leak if legacy test is skipped.
Using EVP_KDF_CTX_get_params() to get OSSL_KDF_PARAM_SIZE will now
return 0 if the returned size is 0.

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

2 years agoAdd test for provider gettables
Shane Lontis [Fri, 25 Jun 2021 02:01:13 +0000 (12:01 +1000)]
Add test for provider gettables

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

2 years agoAvoid "excessive message size" for session tickets
Matt Caswell [Wed, 23 Jun 2021 07:54:12 +0000 (08:54 +0100)]
Avoid "excessive message size" for session tickets

We received a report of an "excessive message size" for a received
session ticket. Our maximum size was significantly less than the theoretical
maximum. The server may put any data it likes in the session ticket
including (for example) the full certificate chain so we should be able to
handle longer tickets. Update the value to the maximum allowed by the spec.

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

2 years agoupdate fips checksums
Tomas Mraz [Thu, 1 Jul 2021 15:41:47 +0000 (17:41 +0200)]
update fips checksums

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

2 years agofips module header inclusion fine-tunning
Tomas Mraz [Thu, 1 Jul 2021 15:41:02 +0000 (17:41 +0200)]
fips module header inclusion fine-tunning

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

2 years agobn: Make fixed-length Montgomery Multiplication conditional on PPC64
Martin Schwenke [Thu, 1 Jul 2021 06:59:30 +0000 (16:59 +1000)]
bn: Make fixed-length Montgomery Multiplication conditional on PPC64

This code is currently unconditional even though build.info has:

  $BNASM_ppc64=$BNASM_ppc32 ppc64-mont-fixed.s

This causes a build failure on 32-bit systems.

Fixes #15923

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15971)

2 years agobn: Fix .size directive
Martin Schwenke [Thu, 1 Jul 2021 04:44:33 +0000 (14:44 +1000)]
bn: Fix .size directive

This requires the text address.

Fixes #15923

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15971)

2 years agobn: Use a basic branch-if-not-zero
Martin Schwenke [Thu, 1 Jul 2021 04:23:50 +0000 (14:23 +1000)]
bn: Use a basic branch-if-not-zero

Ancient toolchains fail the build because they don't like the hints,
newer ISAs recommend not using the hints and relying on dynamic branch
prediction.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15971)

2 years agorsa_cms_verify: Avoid negative return with missing pss parameters
Tomas Mraz [Fri, 2 Jul 2021 13:29:13 +0000 (15:29 +0200)]
rsa_cms_verify: Avoid negative return with missing pss parameters

Fixes #15984

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

2 years agoCoverity #1486687: fix potential dereference of NULL keymgmt
Tomas Mraz [Fri, 2 Jul 2021 13:45:09 +0000 (15:45 +0200)]
Coverity #1486687: fix potential dereference of NULL keymgmt

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

2 years agodoc: include PBKDF1 documentation in build.info
Pauli [Thu, 1 Jul 2021 04:47:38 +0000 (14:47 +1000)]
doc: include PBKDF1 documentation in build.info

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

2 years agodoc: add PBKDF1 provider documentation
Pauli [Thu, 1 Jul 2021 04:46:39 +0000 (14:46 +1000)]
doc: add PBKDF1 provider documentation

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

2 years agoprovider: use #define for PBKDF1 algorithm name
Pauli [Thu, 1 Jul 2021 04:00:03 +0000 (14:00 +1000)]
provider: use #define for PBKDF1 algorithm name

This seems to be standard practice so bringing PBKDF1 into line.

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

2 years agoPROV & STORE: Make the 'file:' store loader understand more binary formats
Richard Levitte [Fri, 2 Jul 2021 10:38:18 +0000 (12:38 +0200)]
PROV & STORE: Make the 'file:' store loader understand more binary formats

The 'file:' store loader only understood DER natively.  With all the
whatever to key decoders gone, direct support for other binary file
formats are gone, and we need to recreate them for this store loader.

With these changes, it now also understands MSBLOB and PVK files.

As a consequence, any store loader that handles some form of open file
data (such as a PEM object) can now simply pass that data back via
OSSL_FUNC_store_load()'s object callback.  As long as libcrypto has
access to a decoder that can understand the data, the appropriate
OpenSSL object will be generated for it, even if the store loader sits
in a different provider than any decoder or keymgmt.
For example, an LDAP store loader, which typically finds diverse PEM
formatted blobs in the database, can simply pass those back via the
object callback, and let libcrypto do the rest of the work.

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

2 years agoPROV & STORE: Don't decode keys in the 'file:' store loader
Richard Levitte [Fri, 2 Jul 2021 10:29:23 +0000 (12:29 +0200)]
PROV & STORE: Don't decode keys in the 'file:' store loader

This makes the 'file:' store loader only read the file, and only decode
down to a base level binary format, and simply pass that blob of data
back to the OSSL_FUNC_store_load() object callback.

This offloads the decoding into specific OpenSSL types to libcrypto,
which takes away the issue of origins, which provider is it that holds
the key (or other future types of objects).

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

2 years agoTEST: Add testing of PVK and MSBLOB files to test_store
Richard Levitte [Fri, 2 Jul 2021 10:13:47 +0000 (12:13 +0200)]
TEST: Add testing of PVK and MSBLOB files to test_store

The PVK and MSBLOB files were generated using openssl 1.1.1, using
test/testrsa.pem as source:

    openssl rsa -in test/testrsa.pem \
                -out test/recipes/90-test_store_data/testrsa.msb \
                -outform msb
    openssl rsa -in test/testrsa.pem \
                -out test/recipes/90-test_store_data/testrsa.pvk \
                -outform pvk \
                -passout pass:password

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

2 years agoWork around a 32-bit mingw failure
Matt Caswell [Thu, 1 Jul 2021 10:58:35 +0000 (11:58 +0100)]
Work around a 32-bit mingw failure

Passing the return value from gmtime() directly to mktime() was producing
incorrect results under windows (but not under wine) when built with mingw
32-bit (but not VC-WIN32). We implement a workaround for this.

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

2 years agoUse TEST_time_t_* functions in cmp_hrd_test.c
Matt Caswell [Tue, 29 Jun 2021 13:12:28 +0000 (14:12 +0100)]
Use TEST_time_t_* functions in cmp_hrd_test.c

This gives better diagnostic output

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

2 years agoAvoid some MinGW test failures
Matt Caswell [Fri, 25 Jun 2021 15:05:20 +0000 (16:05 +0100)]
Avoid some MinGW test failures

There were 4 classes of failure:

- line ending problems;
- unicode problems;
- file path munging problems; and
- a "hang" in test_cmp_http.

The unicode problems appear to be somewhere between wine or msys - they
don't actually appear to be a problem with the built binaries. We just skip
those tests for now.

Fixes #13558

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

2 years agoFix memory leak in i2d_ASN1_bio_stream
Oliver Mihatsch [Mon, 12 Apr 2021 14:46:16 +0000 (16:46 +0200)]
Fix memory leak in i2d_ASN1_bio_stream

When creating a signed S/MIME message using SMIME_write_CMS()
if the reading from the bio fails, the state is therefore
still ASN1_STATE_START when BIO_flush() is called by i2d_ASN1_bio_stream().
This results in calling asn1_bio_flush_ex cleanup but will only
reset retry flags as the state is not ASN1_STATE_POST_COPY.
Therefore 48 bytes (Linux x86_64) leaked since the
ndef_prefix_free / ndef_suffix_free callbacks are not executed
and the ndef_aux structure is not freed.

By always calling free function callback in asn1_bio_free() the
memory leak is fixed.

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

2 years agoPEM_read_...: document that garbage and other PEM data is skipped
Tomas Mraz [Wed, 30 Jun 2021 16:02:24 +0000 (18:02 +0200)]
PEM_read_...: document that garbage and other PEM data is skipped

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

2 years agoload_key_certs_crls: Avoid reporting any spurious errors
Tomas Mraz [Wed, 30 Jun 2021 14:11:17 +0000 (16:11 +0200)]
load_key_certs_crls: Avoid reporting any spurious errors

When there is other PEM data in between certs the OSSL_STORE_load
returns NULL and reports error. Avoid printing that error unless
there was nothing read at all.

Fixes #15945

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

2 years agotest_pem_reading: Test loading a key from a file with multiple PEM data
Tomas Mraz [Tue, 29 Jun 2021 15:18:34 +0000 (17:18 +0200)]
test_pem_reading: Test loading a key from a file with multiple PEM data

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

2 years agoload_pkey_pem: Check for spurious errors when loading
Tomas Mraz [Tue, 29 Jun 2021 14:44:00 +0000 (16:44 +0200)]
load_pkey_pem: Check for spurious errors when loading

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

2 years agopem_read_bio_key: Add passphrase caching to avoid asking for password twice
Tomas Mraz [Tue, 29 Jun 2021 14:24:59 +0000 (16:24 +0200)]
pem_read_bio_key: Add passphrase caching to avoid asking for password twice

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

2 years agopem_read_bio_key_decoder: Avoid spurious error on unknown PEM data
Tomas Mraz [Tue, 29 Jun 2021 13:46:25 +0000 (15:46 +0200)]
pem_read_bio_key_decoder: Avoid spurious error on unknown PEM data

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

2 years agoFix compile errors when building with --api=1.1.0 no-deprecated.
Shane Lontis [Thu, 1 Jul 2021 02:01:22 +0000 (12:01 +1000)]
Fix compile errors when building with --api=1.1.0 no-deprecated.

Fixes #15963

INSTALL.md uses these exact options as an example so it should work.

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

2 years agoupdate pyca-cryptography regression test suite
Paul Kehrer [Thu, 1 Jul 2021 13:24:49 +0000 (08:24 -0500)]
update pyca-cryptography regression test suite

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

2 years agoDefined out MUTEX attributes not available on NonStop SPT Threads.
Randall S. Becker [Wed, 23 Jun 2021 20:50:09 +0000 (14:50 -0600)]
Defined out MUTEX attributes not available on NonStop SPT Threads.

Standard Posix Threads (SPT) Threads are an older separate branch of
pthreads that do not support some of the capabilities in the current
Posix User Threads (PUT).

The change also includes a rename of the close field of OSSL_STORE_LOADER
which was causing preprocessor conflicts.

Fixes #15885

Signed-off-by: Randall S. Becker <rsbecker@nexbridge.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15886)

2 years agodoc: Mention the update of der data pointers in d2i/i2d
Tomas Mraz [Wed, 30 Jun 2021 09:17:09 +0000 (11:17 +0200)]
doc: Mention the update of der data pointers in d2i/i2d

Fixes #15958

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

2 years agoDOC: clarify OPENSSL_API_COMPAT
Richard Levitte [Wed, 30 Jun 2021 04:31:58 +0000 (06:31 +0200)]
DOC: clarify OPENSSL_API_COMPAT

Fixes #15928

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

2 years agoci: add a memory sanitiser test run
Pauli [Tue, 29 Jun 2021 23:25:40 +0000 (09:25 +1000)]
ci: add a memory sanitiser test run

This omission noted in #15950

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

2 years agoafalg: add some memory initialisation calls to pacify memory sanitisation.
Pauli [Wed, 30 Jun 2021 00:21:17 +0000 (10:21 +1000)]
afalg: add some memory initialisation calls to pacify memory sanitisation.

The engine is modifying memory without the sanitiser realising.  By pre-
initialising this memory, the sanitiser now thinks that read accesses are okay.

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

2 years agoDocument cross-compile considerations for NonStop x86 builds.
Randall S. Becker [Tue, 29 Jun 2021 14:39:29 +0000 (08:39 -0600)]
Document cross-compile considerations for NonStop x86 builds.

Fixes #15919

Signed-off-by: Randall S. Becker <rsbecker@nexbridge.com>
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/15948)

2 years agoFix use of uninitialized memory in test_rsa_oaep
David Benjamin [Tue, 29 Jun 2021 18:41:12 +0000 (14:41 -0400)]
Fix use of uninitialized memory in test_rsa_oaep

48f1739600f33c92387debce2002acec6e365f1d did not convert the RSA OAEP
tests correctly. The corrupted ciphertext and truncation tests were
really decrypting uninitialized memory, rather than the sample
ciphertext. This results in an error in tools like MSan.

The test is somewhat roundabout. In the original version, before the
conversion, ctext_ex was an OAEP test vector from key1(), etc.,
functions. The test would:

1. Encrypt ptext_ex as ctext.
2. Decrypt ctext and check it gives ptext_ex.
3. Decrypt ctext_ex and check it gives ptext_ex.
4. Try corrupted and truncated versions of ctext.

48f1739600f33c92387debce2002acec6e365f1d then moved steps 1 and 2 into
test_rsa_simple, which meant ctext is no longer available for step 4. It
then mistakenly left the variable around, but uninitialized, so the test
wasn't testing anything. (Confusingly, test_rsa_simple outputs ctext_ex
to the caller, but doesn't do anything with it. The ctext_ex output is
also only usable for OAEP, not PKCS#1 v1.5.)

It doesn't really matter whether we use ctext or ctext_ex for step 4, so
this PR fixes it by using ctext_ex instead.

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

2 years agoOSSL_CRMF_{CERTTEMPLATE,CERTID}_get0_serialNumber(): Make result const for consistency
Dr. David von Oheimb [Tue, 29 Jun 2021 09:11:05 +0000 (11:11 +0200)]
OSSL_CRMF_{CERTTEMPLATE,CERTID}_get0_serialNumber(): Make result const for consistency

Also make doc/man3/OSSL_CRMF_MSG_get0_tmpl.pod consistent with crmf.h.in regarding const results

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/15790)

2 years agocmp_mock_srv.c: Add missing OldCertID check for 'kur' cert update requests
Dr. David von Oheimb [Tue, 22 Jun 2021 13:40:49 +0000 (15:40 +0200)]
cmp_mock_srv.c: Add missing OldCertID check for 'kur' cert update requests

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/15790)

2 years agoCMP: Add missing getter functions to CRMF API and CMP API
Dr. David von Oheimb [Wed, 16 Jun 2021 08:26:26 +0000 (10:26 +0200)]
CMP: Add missing getter functions to CRMF API and CMP API

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/15790)

2 years agotest: fix test ordering in threads test
Pauli [Wed, 30 Jun 2021 01:13:35 +0000 (11:13 +1000)]
test: fix test ordering in threads test

Fixes #15953

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

2 years agoevp: fix coverity 1473380 Copy into fixed size buffer (STRING_OVERFLOW)
Pauli [Mon, 28 Jun 2021 22:26:11 +0000 (08:26 +1000)]
evp: fix coverity 1473380 Copy into fixed size buffer (STRING_OVERFLOW)

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

2 years agodh_test: fix coverity 1473239 Argument cannot be negative (NEGATIVE_RETURNS)
Pauli [Mon, 28 Jun 2021 22:18:30 +0000 (08:18 +1000)]
dh_test: fix coverity 1473239 Argument cannot be negative (NEGATIVE_RETURNS)

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

2 years agos_time: avoid unlikely division by zero
Pauli [Mon, 28 Jun 2021 22:05:19 +0000 (08:05 +1000)]
s_time: avoid unlikely division by zero

Fixing coverity 966560 Division or modulo by zero (DIVIDE_BY_ZERO)

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

2 years agobio: check for valid socket when closing
Pauli [Mon, 28 Jun 2021 22:01:13 +0000 (08:01 +1000)]
bio: check for valid socket when closing

Fixes coverity 271258 Improper use of negative value (NEGATIVE_RETURNS)

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

2 years agotest: fix coverity 1469427 Improper use of negative value (NEGATIVE_RETURNS)
Pauli [Mon, 28 Jun 2021 21:59:00 +0000 (07:59 +1000)]
test: fix coverity 1469427 Improper use of negative value (NEGATIVE_RETURNS)

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