]> git.ipfire.org Git - thirdparty/openssl.git/log
thirdparty/openssl.git
23 months agoissue-21718: remove setting of PTHREAD_MUTEX_NORMAL
Neil Horman [Fri, 11 Aug 2023 19:50:59 +0000 (15:50 -0400)] 
issue-21718: remove setting of PTHREAD_MUTEX_NORMAL

issue: https://github.com/openssl/openssl/issues/21718

build break reported:
crypto/threads_pthread.c:76:5: warning: implicit declaration of function 'pthread_mutexattr_settype'; did you mean 'pthread_mutexattr_destroy'? [-Wimplicit-function-declaration]
   76 |     pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~
      |     pthread_mutexattr_destroy
crypto/threads_pthread.c:76:38: error: 'PTHREAD_MUTEX_NORMAL' undeclared (first use in this function); did you mean 'PTHREAD_MUTEX_TIMED_NP'?
   76 |     pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
      |                                      ^~~~~~~~~~~~~~~~~~~~
      |                                      PTHREAD_MUTEX_TIMED_NP

This occurs because PTHREAD_MUTEX_NORMAL is only defined in glibc if
__USE_UNIX98 or __USE_XOPEN2K8 is defined, which is derived from setting
__USE_POSIX_C_SOURCE or __XOPEN_SOURCE is selected in the glibc feature
set for a build.  Since openssl selects no specific feature set from
glibc, the build break occurs

We could select a feature set of course, but that seems like a
significant discussion to have prior to doing so. Instead, the simpler
solution is to just not set the mutex type at all, given that
pthread_mutexattr_init sets the default mutex type, which should be akin
to normal anyway (i.e. no mutex error checking or allowed-recursive
behavior)

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

(cherry picked from commit e4d808652b0a1a19cfe615a6659e65ead0245108)

23 months agoImprove documentation for BIO_s_mem
Neil Horman [Mon, 14 Aug 2023 16:17:11 +0000 (12:17 -0400)] 
Improve documentation for BIO_s_mem

Recent leak discovered by valgrind:
==1007580== at 0x483C815: malloc (vg_replace_malloc.c:431)
==1007580== by 0x2C2689: CRYPTO_zalloc (in /home/vien/microedge-c/test)
==1007580== by 0x295A17: BUF_MEM_new (in /home/vien/microedge-c/test)
==1007580== by 0x295A78: BUF_MEM_new_ex (in /home/vien/microedge-c/test)
==1007580== by 0x28CACE: mem_new (in /home/vien/microedge-c/test)
==1007580== by 0x285EA8: BIO_new_ex (in /home/vien/microedge-c/test)
==1007580== by 0x231894: convert_pubkey_ECC (tpm2_driver.c:221)
==1007580== by 0x232B73: create_ephemeral_key (tpm2_driver.c:641)
==1007580== by 0x232E1F: tpm_gen_keypair (tpm2_driver.c:695)
==1007580== by 0x22D60A: gen_keypair (se_driver_api.c:275)
==1007580== by 0x21FF35: generate_keypair (dhkey.c:142)
==1007580== by 0x24D4C8: __test_dhkey (dhkey_test.c:55)

led me to find that BIO_get_mem_data is informative only, it does not
transer ownership of a BIO_s_mems data structure to the caller.
Additionally treating it as such leads to the above leak, or possibly
data corruption in the event that BIO_set_close(bio, BIO_NOCLOSE) is not
set properly prior to calling BIO_free.

Made an attempt to fix it in a minimally invasive manner in the 3.1
branch, but based on discussion, its just not safe to do in an API
compatible way, so just document the sematics a little more clearly
here, and fix it properly in a future release

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

23 months agoCheck i2d_X509_NAME return in X509_NAME_hash_ex/old
3lswear [Wed, 9 Aug 2023 13:25:51 +0000 (16:25 +0300)] 
Check i2d_X509_NAME return in X509_NAME_hash_ex/old

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21697)

(cherry picked from commit 945fde53a3db5011940a059fd1407b81197c9e14)

23 months agoFix no-dsa in combination with no-err
Matt Caswell [Fri, 11 Aug 2023 08:42:36 +0000 (09:42 +0100)] 
Fix no-dsa in combination with no-err

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21722)

(cherry picked from commit 4efd84fdd648279367683b280c9d9feb2ba54e9e)

23 months agoFix no-dtls and no-tls in combination
Matt Caswell [Fri, 11 Aug 2023 08:41:57 +0000 (09:41 +0100)] 
Fix no-dtls and no-tls in combination

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21722)

(cherry picked from commit fb32f6ea42e6916ff88cc44cf5de6e63ba596aca)

2 years agoOSSL_HTTP_{REQ_CTX_set_request_line(),_set1_request()}: backward compat w.r.t. path...
Dr. David von Oheimb [Tue, 8 Aug 2023 20:47:50 +0000 (22:47 +0200)] 
OSSL_HTTP_{REQ_CTX_set_request_line(),_set1_request()}: backward compat w.r.t. path parameter

Fixes #17923

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21690)

(cherry picked from commit 45c02183c65f0e1abf59909c2900764606334664)

2 years agoFor ASN1_STRING_set() check result and set correct error code
atishkov [Fri, 4 Aug 2023 19:15:01 +0000 (22:15 +0300)] 
For ASN1_STRING_set() check result and set correct error code

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21658)

(cherry picked from commit 0c1cdb7cefa8edbcc29b9d799ac28c6fbc7e0a30)

2 years agoDo not raise CMS_R_CONTENT_TYPE_NOT_ENVELOPED_DATA error in CMS_ContentInfo_free
Olga Batyshkina [Mon, 7 Aug 2023 12:51:53 +0000 (14:51 +0200)] 
Do not raise CMS_R_CONTENT_TYPE_NOT_ENVELOPED_DATA error in CMS_ContentInfo_free

This happens if this function is called for signed content.

Added ossl_cms_env_enc_content_free() for cleaning enveloped content.

Fixed indentation in ossl_cms_env_enc_content_free

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

(cherry picked from commit 13342efbb9e16ec8f97b1ac5ab4aa2b3b3490596)

2 years agoFix ChaCha assembly code on 32-bit HPUX itanium systems
Bernd Edlinger [Tue, 8 Aug 2023 04:48:33 +0000 (06:48 +0200)] 
Fix ChaCha assembly code on 32-bit HPUX itanium systems

This fixes the reported crashes 32-bit HPUX systems due to
raw out and inp pointer values, and adds one nop instruction
on 64-bit systems, like it is done in other assembly modules
for those systems.

The fix was tested by @johnkohl-hcl see:
https://github.com/openssl/openssl/issues/17067#issuecomment-1668468033

Fixes #17067

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

(cherry picked from commit 6d38ccedb25f31dfab232e2669415fd4db18b20e)

2 years agoFix handling of the "0:" label in arm-xlate.pl
Tom Cosgrove [Thu, 3 Aug 2023 18:43:17 +0000 (19:43 +0100)] 
Fix handling of the "0:" label in arm-xlate.pl

When $label == "0", $label is not truthy, so `if ($label)` thinks there isn't
a label. Correct this by looking at the result of the s/// command.

Verified that there are no changes in the .S files created during a normal
build, and that the "0:" labels appear in the translation given in the error
report (and they are the only difference in the before and after output).

Fixes #21647

Change-Id: I5f2440100c62360bf4bdb7c7ece8dddd32553c79

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

(cherry picked from commit 9607f5ccf285ac9988a86f95c5ad9f92b556a843)

2 years agoendecode_test.c: Add tests for decoding with 0 selection
Tomas Mraz [Fri, 21 Jul 2023 15:45:32 +0000 (17:45 +0200)] 
endecode_test.c: Add tests for decoding with 0 selection

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/21519)

(cherry picked from commit 4c50610bdadbcf7aa6bbd968df67b8874234677b)

2 years agoWhen exporting/importing decoded keys do not use 0 as selection
Tomas Mraz [Fri, 21 Jul 2023 15:40:31 +0000 (17:40 +0200)] 
When exporting/importing decoded keys do not use 0 as selection

When decoding 0 as the selection means to decode anything
you get.

However when exporting and then importing the key data 0 as
selection is not meaningful.
So we set it to OSSL_KEYMGMT_SELECT_ALL to make the export/import
function export/import everything that we have decoded.

Fixes #21493

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/21519)

(cherry picked from commit 2acb0d363c0032b5b97c4f6596609f40bd7d842f)

2 years agoAvoid exporting bogus (empty) data if empty selection is used
Tomas Mraz [Fri, 21 Jul 2023 14:26:12 +0000 (16:26 +0200)] 
Avoid exporting bogus (empty) data if empty selection is used

This is already correct in the rsa_kmgmt.c but other
implementations are wrong.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/21519)

(cherry picked from commit 1ae4678cebaa13604c0f31bdf2c64cd28bdaf287)

2 years agoNew version of gost-engine tests
Dmitry Belyavskiy [Wed, 2 Aug 2023 12:17:30 +0000 (14:17 +0200)] 
New version of gost-engine tests

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/21635)

(cherry picked from commit 9f8dd6c265d5dd501cf03ca706aa45c6e79b53d7)

2 years agono_autoload: make the no-autoload-config option work again.
Pauli [Wed, 2 Aug 2023 00:44:47 +0000 (10:44 +1000)] 
no_autoload: make the no-autoload-config option work again.

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

(cherry picked from commit cb8e64131e7ce230a9268bdd7cc4664868ff0dc9)

2 years agotest: skip FIPS config auto loading based tests if feature is disabled
Pauli [Wed, 2 Aug 2023 01:36:46 +0000 (11:36 +1000)] 
test: skip FIPS config auto loading based tests if feature is disabled

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

(cherry picked from commit 9a255aa2bda07286d5516a77b269178fc03779b4)

2 years agoprovider test: don't run configuration based tests if configuration isn't loaded
Pauli [Wed, 2 Aug 2023 00:44:37 +0000 (10:44 +1000)] 
provider test: don't run configuration based tests if configuration isn't loaded

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

(cherry picked from commit a9dde749504065e6e66b63cc12c25381465ec721)

2 years agoPBE test: load providers if auto config load is turned off
Pauli [Wed, 2 Aug 2023 00:41:22 +0000 (10:41 +1000)] 
PBE test: load providers if auto config load is turned off

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

(cherry picked from commit 52ea255d9d560513f69c3f7f3f21513a693c865c)

2 years agotestutil: allow a failure return from setup_tests that doesn't print help
Pauli [Wed, 2 Aug 2023 00:40:23 +0000 (10:40 +1000)] 
testutil: allow a failure return from setup_tests that doesn't print help

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

(cherry picked from commit badf3c162d2b67635beee3fc948db32f13d274af)

2 years agoResolves some magic values that has a hello_retry_request enum type.
Frederik Wedel-Heinen [Wed, 2 Aug 2023 12:49:17 +0000 (14:49 +0200)] 
Resolves some magic values that has a hello_retry_request enum type.

CLA: trivial

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21636)

(cherry picked from commit 5ac7ee4d5a38e4f163ed6a7c9c283d45038625a8)

2 years agocrypto/cmp: fix clash of OSSL_CMP_CERTREQID_NONE with error result of ossl_cmp_asn1_g...
Dr. David von Oheimb [Thu, 27 Jul 2023 18:03:16 +0000 (20:03 +0200)] 
crypto/cmp: fix clash of OSSL_CMP_CERTREQID_NONE with error result of ossl_cmp_asn1_get_int()

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/21579)

(cherry picked from commit 2c8d9f19e351a84d4329fbe2f68a4a8a49cad3ef)

2 years agoFix typo in function name
Tianjia Zhang [Tue, 1 Aug 2023 06:21:02 +0000 (14:21 +0800)] 
Fix typo in function name

Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21608)

(cherry picked from commit 38c70a161cc6f96682bd77c8a935c5767355438c)

2 years agoA null pointer dereference occurs when memory allocation fails
yangyangtiantianlonglong [Mon, 31 Jul 2023 14:04:41 +0000 (07:04 -0700)] 
A null pointer dereference occurs when memory allocation fails

Fixes #21605

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21606)

(cherry picked from commit a8da305fa3dd6e34ba5aab3978281f652fd12883)

2 years agoAdd a test for PEM_read_bio_Parameters()
Matt Caswell [Mon, 31 Jul 2023 11:56:47 +0000 (12:56 +0100)] 
Add a test for PEM_read_bio_Parameters()

We must not ask for a password when attempting to read parameters.

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

(cherry picked from commit df3d609030bdb0868d1ccca14227bb6829ad954c)

2 years agoThe PEM_read_bio_Parameters() function should not ask for a password
Matt Caswell [Mon, 31 Jul 2023 11:32:16 +0000 (12:32 +0100)] 
The PEM_read_bio_Parameters() function should not ask for a password

The PEM_read_bio_Parameters[_ex] function does not have the capability
of specifying a password callback. We should not use the fallback password
callback in this case because it will attempt to send a prompt for the
password which might not be the correct thing to do. We should just not
use a password in that case.

Fixes #21588

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

(cherry picked from commit 0d0791eedff7f0747503d816184810aa093f523e)

2 years agoAlways add a suitable error if we fail to decode
Matt Caswell [Mon, 31 Jul 2023 11:30:34 +0000 (12:30 +0100)] 
Always add a suitable error if we fail to decode

We're always supposed to add the fallback "unsupported" error if we don't
have anything better. However in some cases this wasn't happening because
we were incorrectly setting "flag_construct_called" - even though the
construct function had failed.

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

(cherry picked from commit 564e5b754a4680dfad38585dd73bcf025567b448)

2 years agoDon't add the msblob/pvk decoders if they're not suitable
Matt Caswell [Mon, 31 Jul 2023 11:28:37 +0000 (12:28 +0100)] 
Don't add the msblob/pvk decoders if they're not suitable

msblob only decodes public/private keys (not just params).
pvk only decodes private keys.

If the requested selection doesn't intersect with the above then don't
consider those decoders.

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

(cherry picked from commit 6207f2b657b5ba1823681b49c7c34c619da0dd00)

2 years agoFixed incorrect usage of vshuf.b instruction
zhuchen [Mon, 24 Jul 2023 08:03:29 +0000 (16:03 +0800)] 
Fixed incorrect usage of vshuf.b instruction

In the definition of the latest revised LoongArch64 vector instruction manual,
it is clearly pointed out that the undefined upper three bits of each byte in
the control register of the vshuf.b instruction should not be used, otherwise
uncertain results may be obtained. Therefore, it is necessary to correct the
use of the vshuf.b instruction in the existing vpaes-loongarch64.pl code to
avoid erroneous calculation results in future LoongArch64 processors.

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

(cherry picked from commit 780ce3849f9efc5404d94464e0eeff966bebbbf1)

2 years agoBackport crypto/armcap.c from master branch
Tom Cosgrove [Thu, 27 Jul 2023 07:58:00 +0000 (08:58 +0100)] 
Backport crypto/armcap.c from master branch

This backports 7b508cd1e1 together with .pl fixes

Makes the SIGILL-based code easier to read, and doesn't use it on Apple Silicon
or where getauxval() is present, thereby improving stability when debugging on
Darwin (macOS/iOS/etc) and in multi-threaded programs (both Darwin and Linux).

Fixes #21541

Change-Id: I07912f0ddcbfe15bf3c1550533855a6583d21b67

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

2 years agoPrepare for 3.1.3 21613/head
Matt Caswell [Tue, 1 Aug 2023 13:37:03 +0000 (14:37 +0100)] 
Prepare for 3.1.3

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Release: yes

2 years agoPrepare for release of 3.1.2 openssl-3.1.2
Matt Caswell [Tue, 1 Aug 2023 13:36:55 +0000 (14:36 +0100)] 
Prepare for release of 3.1.2

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Release: yes

2 years agomake update
Matt Caswell [Tue, 1 Aug 2023 13:36:54 +0000 (14:36 +0100)] 
make update

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Release: yes

2 years agoCopyright year updates
Matt Caswell [Tue, 1 Aug 2023 13:35:30 +0000 (14:35 +0100)] 
Copyright year updates

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Release: yes

2 years agoFix a regression in X509_VERIFY_PARAM_add0_policy()
Matt Caswell [Thu, 27 Jul 2023 11:09:47 +0000 (12:09 +0100)] 
Fix a regression in X509_VERIFY_PARAM_add0_policy()

Also fixes a similar regression in X509_VERIFY_PARAM_add0_table().

Commit 38ebfc3 introduced a regression in 3.0.6 that changed the return
value of the two functions above from 1 on success to the number of entries
in the stack. If there are more than one entry then this is a change in
behaviour which should not have been introduced into a stable release.

This reverts the behaviour back to what it was prior to the change. The code
is slightly different to the original code in that we also handle a possible
-1 return value from the stack push function. This should never happen in
reality because we never pass a NULL stack as a parameter - but for the sake
of robustness we handle it anyway.

Note that the changed behaviour exists in all versions of 3.1 (it never had
the original version). But 3.1 should be fully backwards compatible with 3.0
so we should change it there too.

Fixes #21570

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/21576)

(cherry picked from commit e3d897d3fa3b48bb835fab0665a435469beea7ae)

2 years agovpaes: LoongArch: Use getauxval(AT_HWCAP) for LSX detection
Xi Ruoyao [Fri, 21 Jul 2023 02:07:04 +0000 (02:07 +0000)] 
vpaes: LoongArch: Use getauxval(AT_HWCAP) for LSX detection

Running LSX instructions requires both the hardware support and the
kernel support.  The `cpucfg` instruction only tests the hardware
support, causing a SIGILL if the hardware supports LSX but the kernel
does not.

Use `getauxval(AT_HWCAP)` as the ["Software Development and Build
Convention for LoongArch Architectures"][1] manual suggests.

The LOONGARCH_HWCAP_LSX and LOONGARCH_HWCAP_LASX bits are copied from
the manual too.  In Glibc 2.38 they'll be provided by <sys/auxv.h> as
well, but they are unavailable in earlier Glibc versions so we cannot
rely on it.

The getauxval syscall and Glibc wrapper are available since day one
(Linux-5.19 and Glibc-2.36) for LoongArch.

Fixes #21508.

[1]:https://github.com/loongson/la-softdev-convention/blob/master/la-softdev-convention.adoc#kernel-constraints

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21509)

(cherry picked from commit c612289b77c37f7295d5af0d0e6b6c04e6ba727c)

2 years agoCorrect spelling of database
Fatih Arslan Tugay [Mon, 24 Jul 2023 12:34:08 +0000 (15:34 +0300)] 
Correct spelling of database

Apply normal sentence case to db update message

CLA: trivial

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/21535)

(cherry picked from commit ccb2f3080d84a271f17458a60e0d7ccd77929e95)

2 years agoAdd CHANGES.md and NEWS.md entries for CVE-2023-3817
Tomas Mraz [Tue, 25 Jul 2023 13:35:34 +0000 (15:35 +0200)] 
Add CHANGES.md and NEWS.md entries for CVE-2023-3817

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/21550)

(cherry picked from commit 4b29762802c05fa871f0e1efcf804e86db0ddaa2)

2 years agodhtest.c: Add test of DH_check() with q = p + 1
Tomas Mraz [Tue, 25 Jul 2023 13:23:43 +0000 (15:23 +0200)] 
dhtest.c: Add test of DH_check() with q = p + 1

This must fail with DH_CHECK_INVALID_Q_VALUE and
with DH_CHECK_Q_NOT_PRIME unset.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/21550)

(cherry picked from commit ad5d35572695d7b5748b2bd4fb1afaa189b29e28)

2 years agoDH_check(): Do not try checking q properties if it is obviously invalid
Tomas Mraz [Tue, 25 Jul 2023 13:22:48 +0000 (15:22 +0200)] 
DH_check(): Do not try checking q properties if it is obviously invalid

If  |q| >= |p| then the q value is obviously wrong as q
is supposed to be a prime divisor of p-1.

We check if p is overly large so this added test implies that
q is not large either when performing subsequent tests using that
q value.

Otherwise if it is too large these additional checks of the q value
such as the primality test can then trigger DoS by doing overly long
computations.

Fixes CVE-2023-3817

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/21550)

(cherry picked from commit 1c16253f3c3a8d1e25918c3f404aae6a5b0893de)

2 years agoMake DH_check set some error bits in recently added error
Bernd Edlinger [Sun, 23 Jul 2023 12:27:54 +0000 (14:27 +0200)] 
Make DH_check set some error bits in recently added error

The pre-existing error cases where DH_check returned zero
are not related to the dh params in any way, but are only
triggered by out-of-memory errors, therefore having *ret
set to zero feels right, but since the new error case is
triggered by too large p values that is something different.
On the other hand some callers of this function might not
be prepared to handle the return value correctly but only
rely on *ret. Therefore we set some error bits in *ret as
additional safety measure.

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

(cherry picked from commit 81d10e61a4b7d5394d08a718bf7d6bae20e818fc)

2 years agoget_cert_by_subject_ex(): Check result of X509_STORE_lock()
atishkov [Fri, 21 Jul 2023 08:36:37 +0000 (11:36 +0300)] 
get_cert_by_subject_ex(): Check result of X509_STORE_lock()

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21515)

(cherry picked from commit bc5d9cc8711e86d5c25b81c58dfae531536e61fc)

2 years agox509: add ASN1_STRING_set() check result
atishkov [Thu, 20 Jul 2023 08:02:38 +0000 (11:02 +0300)] 
x509: add ASN1_STRING_set() check result

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

(cherry picked from commit 46e95903762f0cc478d8a3c252390fa7312bba6e)

2 years agoFix error handling in pipelining test
Bernd Edlinger [Fri, 21 Jul 2023 05:34:39 +0000 (07:34 +0200)] 
Fix error handling in pipelining test

When an early error happens in the test_pipelining
function and idx == 5 the error handling would try
to call OPENSSL_free(msg), but msg is at that time
just a string constant in read-only memory, so a
crash would be the result. Fixed that by using
fragsize as an indication when to free msg.

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21512)

(cherry picked from commit 06a0d40322e96dbba816b35f82226871f635ec5a)

2 years agofix: reject adding a duplicity into STACK_OF(X509_ATTRIBUTE)
Adam Šulc [Thu, 20 Jul 2023 19:30:45 +0000 (21:30 +0200)] 
fix: reject adding a duplicity into STACK_OF(X509_ATTRIBUTE)

Function `X509at_add1_attr()` (crypto/x509/x509_att.c) rejects to add a duplicity into `*x` but it searches in a wrong stack.

Changed to search in `*x`.

CLA: trivial

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21505)

(cherry picked from commit 7551264186f176ca5801aa84d60c7b91d8fba31f)

2 years agospeed: Fix execution of EdDSA measurement
Ingo Franzki [Wed, 19 Jul 2023 13:24:49 +0000 (15:24 +0200)] 
speed: Fix execution of EdDSA measurement

Running 'openssl speed eddsa' fails with

Doing 253 bits sign Ed25519 ops for 10s: EdDSA sign failure
000003FF9306C7D0:error:030000BC:digital envelope routines:EVP_DigestSign:
                           final error:crypto/evp/m_sigver.c:585:
-1 253 bits Ed25519 sign ops in 0.00s
Doing 253 bits verify Ed25519 ops for 10s: EdDSA verify failure
000003FF9306C7D0:error:030000BC:digital envelope routines:EVP_DigestVerify:
                           final error:crypto/evp/m_sigver.c:694:
-1 253 bits Ed25519 verify ops in 0.00s

This is because the EVP_DigestSign/Verify() calls in the EdDSA_sign/verify_loop()
fail because the context has already been finalized by the previous
EVP_DigestSign/Verify call during the EdDSA signature test done by speed_main().

This happens since commit 3fc2b7d6b8f961144905330dfd4689f5bd515199 where the
EVP_DigestSign/Verify() functions have been changed to set a flag that the
context has been finalized.

Fix this by re-initializing the context using EVP_DigestSign/Verify() in the
EdDSA_sign/verify_loop().

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21491)

(cherry picked from commit 0c85bcbaeabe3a695831bec44ab87964725a51a6)

2 years agospeed: Fix memory leak
Ingo Franzki [Wed, 19 Jul 2023 12:59:16 +0000 (14:59 +0200)] 
speed: Fix memory leak

Free the signature stack after iterating over all found signatures.
Free the kem and signature stacks at the end of speed_main() if not
NULL.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21491)

(cherry picked from commit cc7e2b20de02959c328f96e464e5fb8b256a00e0)

2 years agoFix documentation around AAD and return values in EVP_Cipher*
Samuel Lee [Wed, 19 Jul 2023 18:04:12 +0000 (11:04 -0700)] 
Fix documentation around AAD and return values in EVP_Cipher*

Fixes #21485

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

(cherry picked from commit 51a7066e2092b062a502e29166adfcc297803058)

2 years agoapps/cms.c: Fix unreachable code in cms_main()
atishkov [Mon, 17 Jul 2023 10:10:44 +0000 (13:10 +0300)] 
apps/cms.c: Fix unreachable code in cms_main()

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21474)

(cherry picked from commit 8c34367e434c6b9555f21cc4fc77a18d6ef84a85)

2 years agoUpdate CHANGES/NEWS for CVE-2023-3446
Matt Caswell [Thu, 13 Jul 2023 15:14:49 +0000 (16:14 +0100)] 
Update CHANGES/NEWS for CVE-2023-3446

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21451)

(cherry picked from commit 4ec53ad6e1791daafbe26bdbd539f2ba9172959a)

2 years agoAdd a test for CVE-2023-3446
Matt Caswell [Fri, 7 Jul 2023 13:39:48 +0000 (14:39 +0100)] 
Add a test for CVE-2023-3446

Confirm that the only errors DH_check() finds with DH parameters with an
excessively long modulus is that the modulus is too large. We should not
be performing time consuming checks using that modulus.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21451)

(cherry picked from commit ede782b4c8868d1f09c9cd237f82b6f35b7dba8b)

2 years agoFix DH_check() excessive time with over sized modulus
Matt Caswell [Thu, 6 Jul 2023 15:36:35 +0000 (16:36 +0100)] 
Fix DH_check() excessive time with over sized modulus

The DH_check() function checks numerous aspects of the key or parameters
that have been supplied. Some of those checks use the supplied modulus
value even if it is excessively large.

There is already a maximum DH modulus size (10,000 bits) over which
OpenSSL will not generate or derive keys. DH_check() will however still
perform various tests for validity on such a large modulus. We introduce a
new maximum (32,768) over which DH_check() will just fail.

An application that calls DH_check() and supplies a key or parameters
obtained from an untrusted source could be vulnerable to a Denial of
Service attack.

The function DH_check() is itself called by a number of other OpenSSL
functions. An application calling any of those other functions may
similarly be affected. The other functions affected by this are
DH_check_ex() and EVP_PKEY_param_check().

CVE-2023-3446

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21451)

(cherry picked from commit 9e0094e2aa1b3428a12d5095132f133c078d3c3d)

2 years agoopenssl-kdf.pod.in: add text on 'salt' and 'info' parameters; small further improvements
Dr. David von Oheimb [Sun, 16 Jul 2023 13:06:18 +0000 (15:06 +0200)] 
openssl-kdf.pod.in: add text on 'salt' and 'info' parameters; small further improvements

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

(cherry picked from commit 7b2a3a1e9d5246fb0f2935f152d0daec715f79f9)

2 years agoEVP_KDF.pod: extend text on 'salt' and 'info' parameters
Dr. David von Oheimb [Sun, 16 Jul 2023 12:55:35 +0000 (14:55 +0200)] 
EVP_KDF.pod: extend text on 'salt' and 'info' parameters

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

(cherry picked from commit 61c8146aa36b84afd9d83c87c9a01138979ffd60)

2 years agoFix typos found by codespell
Dimitri Papadopoulos [Sun, 16 Jul 2023 05:56:05 +0000 (07:56 +0200)] 
Fix typos found by codespell

Only modify doc/man* in the openssl-3.1 branch.

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

2 years agoFix int_ctx_new() error when use 1.1.1n sm2 key and ec method engine
lan1120 [Sat, 10 Jun 2023 11:36:17 +0000 (19:36 +0800)] 
Fix int_ctx_new() error when use 1.1.1n sm2 key and ec method engine

Signed-off-by: lan1120 <lanming@huawei.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21170)

(cherry picked from commit 4c4fefa5c78a49b63113aec35a2bc8d6d9432436)

2 years agoRemove duplicated values
ljuzwiuk [Tue, 11 Jul 2023 20:43:32 +0000 (20:43 +0000)] 
Remove duplicated values

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21401)

(cherry picked from commit f1b7243cda208d8bd74f75c95990f8205e977ae4)

2 years agoFix ssl3_do_write() to correctly handle retries
Matt Caswell [Wed, 12 Jul 2023 14:50:25 +0000 (15:50 +0100)] 
Fix ssl3_do_write() to correctly handle retries

A BIO is documented to return -1 on write retry - but sometimes they return
0. ssl3_do_write() was incorrectly handling a 0 response.

Fixes #21422

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

2 years agoAdd a test for a retry during the handshake
Matt Caswell [Wed, 12 Jul 2023 13:54:46 +0000 (14:54 +0100)] 
Add a test for a retry during the handshake

Test various scenarios for a write retry occuring during a handshake.

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

2 years agono-module should not imply disabling DSO loading support
Tomas Mraz [Fri, 14 Jul 2023 08:25:42 +0000 (10:25 +0200)] 
no-module should not imply disabling DSO loading support

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

(cherry picked from commit 3d2f96e2c867fa3e79a453639304b70ba0508076)

2 years agoFix RSA OAEP set/get label for legacy engine
ljuzwiuk [Thu, 13 Jul 2023 09:11:28 +0000 (09:11 +0000)] 
Fix RSA OAEP set/get label for legacy engine

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21401)

(cherry picked from commit 64b1d2fb06c9a5233dcabfe130036ff95c3fdaae)

2 years agoAdd CHANGES.md and NEWS.md entries for CVE-2023-2975
Tomas Mraz [Fri, 7 Jul 2023 07:54:18 +0000 (09:54 +0200)] 
Add CHANGES.md and NEWS.md entries for CVE-2023-2975

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

(cherry picked from commit 1e398bec538978b9957e69bf9e12b3c626290bea)

2 years agoAdd testcases for empty associated data entries with AES-SIV
Tomas Mraz [Tue, 4 Jul 2023 15:50:37 +0000 (17:50 +0200)] 
Add testcases for empty associated data entries with AES-SIV

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

(cherry picked from commit 3993bb0c0c87e3ed0ab4274e4688aa814e164cfc)

2 years agoDo not ignore empty associated data with AES-SIV mode
Tomas Mraz [Tue, 4 Jul 2023 15:30:35 +0000 (17:30 +0200)] 
Do not ignore empty associated data with AES-SIV mode

The AES-SIV mode allows for multiple associated data items
authenticated separately with any of these being 0 length.

The provided implementation ignores such empty associated data
which is incorrect in regards to the RFC 5297 and is also
a security issue because such empty associated data then become
unauthenticated if an application expects to authenticate them.

Fixes CVE-2023-2975

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

(cherry picked from commit c426c281cfc23ab182f7d7d7a35229e7db1494d9)

2 years agoModified OSSL_parse_url to initialize pport_num to 0.
Randall S. Becker [Thu, 1 Jun 2023 19:29:15 +0000 (13:29 -0600)] 
Modified OSSL_parse_url to initialize pport_num to 0.

This change is intended to provide some safety for uninitialized stack failures
that have appeared in 80-test_cmp_http on NonStop x86 when run in a complex
CI/CD Jenkins environment. This change also adds init_pint() to handle the
initialization of a pointer to int value.

Fixes: #21083
Signed-off-by: Randall S. Becker <randall.becker@nexbridge.ca>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21109)

2 years agoBump actions/setup-python from 4.6.1 to 4.7.0
dependabot[bot] [Fri, 14 Jul 2023 08:07:23 +0000 (08:07 +0000)] 
Bump actions/setup-python from 4.6.1 to 4.7.0

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.6.1 to 4.7.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v4.6.1...v4.7.0)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
CLA: trivial

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

(cherry picked from commit dbe36351dc3fcb5bd3582075b40d34e0b103b15c)

2 years agoAdd FIPS build instructions
slontis [Tue, 9 May 2023 03:07:50 +0000 (13:07 +1000)] 
Add FIPS build instructions

If you are building the latest release source code with enable-fips configured
then the FIPS provider you are using is not likely to be FIPS compliant.

This update demonstrates how to build a FIPS provider that is compliant
and use it with the latest source code.

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

(cherry picked from commit 2b42290f08c0a75695021aeb7d5cd16068b3edc3)

2 years agoMove Keccak rhotates tables to rodata
Amir Ayupov [Wed, 12 Jul 2023 22:14:51 +0000 (15:14 -0700)] 
Move Keccak rhotates tables to rodata

rhotates tables are placed to .text section which confuses tools such as BOLT.
Move them to rodata to unbreak and avoid polluting icache/iTLB with data.

CLA: trivial

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21440)

(cherry picked from commit 2fd82c228363cfd16c5047a348e7c853defa42eb)

2 years agoAdd a NEWS entry covering the FIPS related changes.
Pauli [Fri, 7 Jul 2023 08:37:08 +0000 (18:37 +1000)] 
Add a NEWS entry covering the FIPS related changes.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/21386)

2 years agoEVP_PKEY_{en,de}capsulate.pod: fix glitches and add some detail and hints
Dr. David von Oheimb [Fri, 7 Jul 2023 15:34:05 +0000 (17:34 +0200)] 
EVP_PKEY_{en,de}capsulate.pod: fix glitches and add some detail and hints

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/21397)

(cherry picked from commit 5be8233d2be306a2906d3da16e59aa15a4559dd2)

2 years agofips: make installations FIPS compliant by default
Pauli [Wed, 5 Jul 2023 09:02:02 +0000 (19:02 +1000)] 
fips: make installations FIPS compliant by default

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

(cherry picked from commit dc6f3b9b8d6e54ea7d8669a158fd73b451862c7d)

2 years agofips: use correct field names when generating fipsmodule.cnf
Pauli [Fri, 30 Jun 2023 01:03:56 +0000 (11:03 +1000)] 
fips: use correct field names when generating fipsmodule.cnf

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

(cherry picked from commit 89111cbc3238dcdf47e921af38d6b12c4b32d326)

2 years agoconf/conf_sap.c: correct return of ossl_config_int() in UEFI system
Yi Li [Tue, 27 Jun 2023 14:33:24 +0000 (22:33 +0800)] 
conf/conf_sap.c: correct return of ossl_config_int() in UEFI system

FIX: https://github.com/openssl/openssl/issues/21299

ret in ossl_config_int() only used to check return value of
CONF_modules_load_file(), should set it to 1 if in UEFI system.

Signed-off-by: Yi Li <yi1.li@intel.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21300)

(cherry picked from commit 500e479db1beae5fa5691d40b866329d2fdc62e7)

2 years agoFix OSSL_PROVIDER_try_load() retain_fallbacks doc
Duncan Thomson [Wed, 28 Jun 2023 21:02:26 +0000 (22:02 +0100)] 
Fix OSSL_PROVIDER_try_load() retain_fallbacks doc

CLA: trivial

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21319)

(cherry picked from commit 063cdca61adfd4d418affe850f8bebbf528d05d9)

2 years agoopenssl-rsautl.pod: Add missing comma
Jakub Wilk [Wed, 28 Jun 2023 20:17:00 +0000 (22:17 +0200)] 
openssl-rsautl.pod: Add missing comma

CLA: trivial

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21318)

(cherry picked from commit 83f9d03e7c4913c3eb34edd4a8feb3833650b58f)

2 years agoDo not use stitched AES-GCM implementation on PPC32
Tomas Mraz [Wed, 28 Jun 2023 14:55:57 +0000 (16:55 +0200)] 
Do not use stitched AES-GCM implementation on PPC32

The implementation is not usable there at all.
Fixes #21301

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

2 years agoAdd some test_ssl_new tests for the ffdhe groups
Matt Caswell [Fri, 23 Jun 2023 15:01:41 +0000 (16:01 +0100)] 
Add some test_ssl_new tests for the ffdhe groups

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

2 years agoFix supported_groups handing in TLSv1.2
Matt Caswell [Fri, 23 Jun 2023 14:45:14 +0000 (15:45 +0100)] 
Fix supported_groups handing in TLSv1.2

In TLSv1.2 we should not attempt to use a supported_group value that is
intended for use with TLSv1.3 - even if both the server and the client
support it, e.g. the ffdhe groups are supported by OpenSSL for TLSv1.3 but
not for TLSv1.2.

Fixes #21081

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

2 years agoopenssl speed -multi -evp prints wrong algorithm name
Jörg Sommer [Thu, 15 Jun 2023 16:16:49 +0000 (18:16 +0200)] 
openssl speed -multi -evp prints wrong algorithm name

When running `openssl speed -evp md5` the result shows `md5` as algorithm
name. But when adding the option `-multi 2` it gives `evp` as algorithm
name.

Signed-off-by: Jörg Sommer <joerg@jo-so.de>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21216)

(cherry picked from commit 33c09341bb081682535be0450ff6032df47ea141)

2 years agos390xcap.c: Avoid copying structure on initialization
Tomas Mraz [Mon, 26 Jun 2023 15:13:30 +0000 (17:13 +0200)] 
s390xcap.c: Avoid copying structure on initialization

This is problematic on old compilers. It also avoids duplicating
the read-only data.

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21284)

2 years agoCONF_modules_load_file_ex(): Do not try to load an empty file name
Tomas Mraz [Mon, 26 Jun 2023 09:11:57 +0000 (11:11 +0200)] 
CONF_modules_load_file_ex(): Do not try to load an empty file name

Fixes #21258

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/21282)

(cherry picked from commit 8b7d5ea7dd602eb7c2c4bc5ad45489dc5fc711f6)

2 years agoAdd a test for pkeyutl encrypt/decrypt using SM2
Matt Caswell [Fri, 23 Jun 2023 11:05:07 +0000 (12:05 +0100)] 
Add a test for pkeyutl encrypt/decrypt using SM2

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

(cherry picked from commit 810f7dc1c7cc5441097b398f753e33652848a4cc)

2 years agoDon't truncate the input when decrypting in pkeyutl
Matt Caswell [Fri, 23 Jun 2023 10:50:17 +0000 (11:50 +0100)] 
Don't truncate the input when decrypting in pkeyutl

The pkeyutl app was truncating the input file for decryption leading to
incorrect results. This was probably ok historically when RSA was being
used for decryption which has short maximum sizes. This is not ok with SM2.

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

(cherry picked from commit 849450746f38a5658ef783abb0a8c79ae2861464)

2 years agoCheck for 0 modulus in BN_RECP_CTX_set.
fullwaywang [Wed, 21 Jun 2023 07:00:06 +0000 (15:00 +0800)] 
Check for 0 modulus in BN_RECP_CTX_set.

The function BN_RECP_CTX_set did not check whether arg d is zero,
in which case an early failure should be returned to the invoker.
This is a similar fix to the cognate defect of CVE-2015-1794.

Fixes #21111

CLA: trivial

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

(cherry picked from commit 43596b306b1fe06da3b1a99e07c0cf235898010d)

2 years agoadd note about retrieving error stack
Vladimír Kotal [Fri, 16 Jun 2023 09:22:24 +0000 (11:22 +0200)] 
add note about retrieving error stack

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

(cherry picked from commit a7c54dde5189f11c046f638e5aaf2004aee34202)

2 years agoAdd a test case for the password prompt on garbage PKCS#12 file
Richard Levitte [Fri, 16 Jun 2023 11:56:36 +0000 (13:56 +0200)] 
Add a test case for the password prompt on garbage PKCS#12 file

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

(cherry picked from commit 1a27cc3626bd15f8fd9a26a2dbc59a681d505321)

2 years agoOSSL_STORE and PKCS#12: Check if there is a MAC to verify before prompting
Richard Levitte [Tue, 13 Jun 2023 18:06:04 +0000 (20:06 +0200)] 
OSSL_STORE and PKCS#12: Check if there is a MAC to verify before prompting

When a DER object with unknown contents comes all the way to
ossl_store_handle_load_result(), and it attempts to decode them as different
objects, the PKCS#12 decoding attempt would (almost) always prompt for a
passphrase, even if there isn't a MAC to verify it against in the PKCS#12
object.

This change checks if there is a MAC to verify against before attempting to
prompt for a passphrase, leading to less surprising behavior.

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

(cherry picked from commit 7a520619c997146639f42ce8595162ac34c2ad41)

2 years agoDon't do SIGILL capability detection on Apple Silicon
Tom Cosgrove [Thu, 22 Jun 2023 02:31:47 +0000 (03:31 +0100)] 
Don't do SIGILL capability detection on Apple Silicon

Fixes #20753

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21261)

2 years agoAdd a test for an invalid group in the HRR
Matt Caswell [Fri, 9 Jun 2023 08:33:11 +0000 (09:33 +0100)] 
Add a test for an invalid group in the HRR

Test that if the client sends a key share for a group in the server's
supported_group list but is otherwise invalid, that we don't select it
in the HRR.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/21163)

(cherry picked from commit adf33f9e268b17ec1b4739707abb40b03b21ea6a)

2 years agoDon't ask for an invalid group in an HRR
Matt Caswell [Fri, 9 Jun 2023 08:09:06 +0000 (09:09 +0100)] 
Don't ask for an invalid group in an HRR

If the client sends us a group in a key_share that is in our
supported_groups list but is otherwise not suitable (e.g. not compatible
with TLSv1.3) we reject it. We should not ask for that same group again
in a subsequent HRR.

Fixes #21157

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/21163)

(cherry picked from commit 7a949ae5f1799a6629cf6deb44ae0f38455a73dd)

2 years agoreturn immediately if namemap is NULL
Vladimír Kotal [Fri, 16 Jun 2023 14:25:58 +0000 (16:25 +0200)] 
return immediately if namemap is NULL

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21223)

(cherry picked from commit 307cd045dccbd9ea589ff47682e39504d79644d4)

2 years agoFix new typos found by codespell
Dimitri Papadopoulos [Thu, 15 Jun 2023 07:16:22 +0000 (09:16 +0200)] 
Fix new typos found by codespell

Fix only typos in doc/man* for inclusion in 3.* branches.

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

2 years agofips: use tsan counter instead of tsan_add to increment
Pauli [Wed, 14 Jun 2023 06:53:51 +0000 (16:53 +1000)] 
fips: use tsan counter instead of tsan_add to increment

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

(cherry picked from commit ff934cfdc85a7b8ddb4bdebf9ab68d518bf68b7f)

2 years agoapps/ca.c: Handle EVP_PKEY_get_default_digest_name() returning 1 with "UNDEF"
Richard Levitte [Wed, 8 Mar 2023 10:53:34 +0000 (11:53 +0100)] 
apps/ca.c: Handle EVP_PKEY_get_default_digest_name() returning 1 with "UNDEF"

EVP_PKEY_get_default_digest_name() may return 1 with the returned digest
name "UNDEF".  This case hasn't been documented, and the meaning has been
left undefined, until now.

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20460)

(cherry picked from commit af99d55078582fb2ac35787043d56e0c10b1fe97)

2 years agofips: update DSA security check to fix legacy verify strengths
Pauli [Mon, 12 Jun 2023 23:37:57 +0000 (09:37 +1000)] 
fips: update DSA security check to fix legacy verify strengths

Refer SP 800-131Ar2 table 2:
    https://csrc.nist.gov/publications/detail/sp/800-131a/rev-2/final

Fixes #21185

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

(cherry picked from commit 71cf587ea21c1422640847e358019a51806d2811)

2 years agocrypto/params: drop float for UEFI
Yi Li [Tue, 16 May 2023 03:09:47 +0000 (11:09 +0800)] 
crypto/params: drop float for UEFI

Using floating point is not supported in UEFI and can cause build
problems, for example due to SSE being disabled and x64 calling
convention passing floats in SSE registers.

Avoid those problems by not compiling the related code for floating
point numbers.

Signed-off-by: Yi Li <yi1.li@intel.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21189)

2 years agofips: use memory ordering rather than locks
Pauli [Tue, 13 Jun 2023 01:39:23 +0000 (11:39 +1000)] 
fips: use memory ordering rather than locks

The FIPS provider accesses it's current state under lock.
This is overkill, little or no synchronisation is actually required in
practice (because it's essentially a read only setting).  Switch to using
TSAN operations in preference.

Fixes #21179

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

(cherry picked from commit 8e9ca334528e0a923c4deb0af250a60510974be0)

2 years agoAPPS: remove spurious errors when certain config file entries are not provided
Dr. David von Oheimb [Mon, 15 May 2023 17:59:16 +0000 (19:59 +0200)] 
APPS: remove spurious errors when certain config file entries are not provided

This backports the functional essence of #20971.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/21050)

(cherry picked from commit 1737fb8f455963b0956c81504a2bec4304bd902d)

2 years agorand_lib: RAND_poll: Reseed in non-"no-deprecated" builds.
Mike Kasick [Fri, 9 Jun 2023 17:40:16 +0000 (13:40 -0400)] 
rand_lib: RAND_poll: Reseed in non-"no-deprecated" builds.

In a non-"no-deprecated" libcrypto build with a default configuration,
RAND_get_rand_method() == RAND_OpenSSL() and so needs to fall through to
the RAND_seed call (used in "no-deprecated" builds) to perform a reseed.

CLA: trivial

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

(cherry picked from commit cc343d047c147e0a395fb101efbe9dedf458aa17)

2 years agoX509_NAME_cmp fix for empty name
Wim Decroix [Thu, 8 Jun 2023 10:40:36 +0000 (12:40 +0200)] 
X509_NAME_cmp fix for empty name

CLA: trivial

Fixes #21156

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21155)

(cherry picked from commit ec59752835f616860cd9451d6cfcea16bfc3ad05)

2 years agoINSTALL: document shared library pinning for static builds
Matthias St. Pierre [Wed, 17 May 2023 09:54:07 +0000 (11:54 +0200)] 
INSTALL: document shared library pinning for static builds

The libcrypto library uses shared library pinning to prevent its
cleanup handlers from crashing at program termination because of a
premature unloading of the shared library.

However, shared library pinning is enabled also for static builds,
which may lead to surpising behaviour if libcrypto is linked
statically to a shared third-party library, because in this case
the third-party library gets pinned.

This surprising behaviour is caused by the fact that the `no-shared`
configure option does not imply `no-pinshared`. Since this quirk
can't be changed without potentially breaking existing code, we just
document it here and provide a workaround.

Fixes #20977

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20985)

(cherry picked from commit ce451fb86141fedad607bd68840639b06616047e)