]> git.ipfire.org Git - thirdparty/openssl.git/log
thirdparty/openssl.git
2 years agoUpdate copyright year
Tomas Mraz [Tue, 30 May 2023 12:11:01 +0000 (14:11 +0200)] 
Update copyright year

Reviewed-by: Richard Levitte <levitte@openssl.org>
Release: yes

2 years agoRestrict the size of OBJECT IDENTIFIERs that OBJ_obj2txt will translate
Richard Levitte [Fri, 12 May 2023 08:00:13 +0000 (10:00 +0200)] 
Restrict the size of OBJECT IDENTIFIERs that OBJ_obj2txt will translate

OBJ_obj2txt() would translate any size OBJECT IDENTIFIER to canonical
numeric text form.  For gigantic sub-identifiers, this would take a very
long time, the time complexity being O(n^2) where n is the size of that
sub-identifier.

To mitigate this, a restriction on the size that OBJ_obj2txt() will
translate to canonical numeric text form is added, based on RFC 2578
(STD 58), which says this:

> 3.5. OBJECT IDENTIFIER values
>
> An OBJECT IDENTIFIER value is an ordered list of non-negative numbers.
> For the SMIv2, each number in the list is referred to as a sub-identifier,
> there are at most 128 sub-identifiers in a value, and each sub-identifier
> has a maximum value of 2^32-1 (4294967295 decimal).

Fixes otc/security#96
Fixes CVE-2023-2650

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
2 years agox509: Handle ossl_policy_level_add_node errors
Clemens Lang [Wed, 24 May 2023 11:12:54 +0000 (13:12 +0200)] 
x509: Handle ossl_policy_level_add_node errors

The invocation of ossl_policy_level_add_node in tree_calculate_user_set
did not have any error handling. Add it to prevent a memory leak for the
allocated extra policy data.

Also add error handling to sk_X509_POLICY_NODE_push to ensure that if
a new node was allocated, but could not be added to the stack, it is
freed correctly.

Fix error handling if tree->user_policies cannot be allocated by
returning 0, indicating failure, rather than 1.

Signed-off-by: Clemens Lang <cllang@redhat.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21040)

(cherry picked from commit 95a8aa6dc0e283b1560dd3258d2e9115c02659b1)

2 years agox509: Fix possible use-after-free when OOM
Clemens Lang [Wed, 24 May 2023 10:22:25 +0000 (12:22 +0200)] 
x509: Fix possible use-after-free when OOM

ossl_policy_level_add_node() first adds the new node to the level->nodes
stack, and then attempts to add extra data if extra_data is true. If
memory allocation or adding the extra data to tree->extra_data fails,
the allocated node (that has already been added to the level->nodes
stack) is freed using ossl_policy_node_free(), which leads to
a potential use after free.

Additionally, the tree's node count and the parent's child count would
not be updated, despite the new node being added.

Fix this by either performing the function's purpose completely, or not
at all by reverting the changes on error.

Signed-off-by: Clemens Lang <cllang@redhat.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21040)

(cherry picked from commit de53817ec386ea9e943d8f33716945dd9dbe1f31)

2 years agoAdd missing CHANGES.md entries
Tomas Mraz [Thu, 25 May 2023 14:58:04 +0000 (16:58 +0200)] 
Add missing CHANGES.md entries

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

2 years agoReplace __attribute__((malloc)) with __attribute__((__malloc__)) in macros.h
Anis-cpu-13 [Tue, 2 May 2023 12:59:11 +0000 (14:59 +0200)] 
Replace __attribute__((malloc)) with __attribute__((__malloc__)) in macros.h

Fix macro attribute conflict with cmocka
Fixes #20776

CLA: trivial

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20869)

(cherry picked from commit 0bf7e94c10f1b00510b8a36cdcbedc02a66468be)

2 years agoClarify how to return string data
Watson Ladd [Fri, 19 May 2023 20:55:08 +0000 (13:55 -0700)] 
Clarify how to return string data

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

(cherry picked from commit eab96453bb145cde8e447f420a4ba099a5fa7004)

2 years agoFix a bug where the result of rehash is unstable
minyong.ha [Mon, 22 May 2023 05:44:13 +0000 (14:44 +0900)] 
Fix a bug where the result of rehash is unstable

The root cause is that the file entries targeted for rehash are not actually sorted.
Sort was skipped because the compare function was null.
So a compare function has been implemented to allow file entries to be sorted.

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

(cherry picked from commit 31c94b5e1159b5435b2354e6525355ec33683ecc)

2 years agoFix incorrect parameter verification in EVP_MD_CTX_get_params
lan1120 [Mon, 22 May 2023 12:37:59 +0000 (20:37 +0800)] 
Fix incorrect parameter verification in EVP_MD_CTX_get_params

Signed-off-by: lan1120 <lanming@huawei.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21022)

(cherry picked from commit b501df3cefebcdaaeb7d6480b7a7b82d68927873)

2 years agodoc/fingerprints.txt: Add the OpenSSL OMC PGP key fingerprint
Richard Levitte [Mon, 22 May 2023 11:11:30 +0000 (13:11 +0200)] 
doc/fingerprints.txt: Add the OpenSSL OMC PGP key fingerprint

We want to move to using this key for tarball and announcement signatures.
It won't happen immediately, though, as we must have it specified in the
latest update of each release branch, so people can verify properly.

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

(cherry picked from commit f925bfebbb287321133b9251e72bee869a0f58b4)

2 years agoIf oaep_md is not initialized, correctly initialize it
Dmitry Belyavskiy [Thu, 18 May 2023 13:38:56 +0000 (15:38 +0200)] 
If oaep_md is not initialized, correctly initialize it

Fixes #20993

Reviewed-by: Matt Caswell <matt@openssl.org>
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/20994)

(cherry picked from commit c5aa719502f1ef456b27347e5f7b15c07817da4e)

2 years agofips.module.sources: Add missing cpuid and related .c sources for other architectures
Tomas Mraz [Fri, 12 May 2023 10:55:24 +0000 (12:55 +0200)] 
fips.module.sources: Add missing cpuid and related .c sources for other architectures

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/20949)

(cherry picked from commit c509c040223aebd2a681fb64b60177c3c21f76d1)

2 years agoAdd information on the 'ias' port for OpenVMS
Richard Levitte [Wed, 17 May 2023 08:33:27 +0000 (10:33 +0200)] 
Add information on the 'ias' port for OpenVMS

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

(cherry picked from commit d500f04400d0acc83fe5270da860764a7d19deee)

2 years agoUpdate VMS configurations
Richard Levitte [Mon, 15 May 2023 08:09:42 +0000 (10:09 +0200)] 
Update VMS configurations

A native x86_64 C compiler has appeared.

We preserve the previous config target with a new name to indicate that it's
for cross compilation, at least for the time being.

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

(cherry picked from commit d6175dcca746f0996db18ab2b6b37a4152097afe)

2 years agoUpdate hkdf.c to avoid potentially vulnerable code pattern
Nicky Mouha [Wed, 17 May 2023 20:46:41 +0000 (16:46 -0400)] 
Update hkdf.c to avoid potentially vulnerable code pattern

The expression "if (a+b>c) a=c-b" is incorrect if "a+b" overflows.
It should be replaced by "if (a>c-b) a=c-b", which avoids the
potential overflow and is much easier to understand.

This pattern is the root cause of CVE-2022-37454, a buffer overflow
vulnerability in the "official" SHA-3 implementation.

It has been confirmed that the addition in
https://github.com/openssl/openssl/blob/master/providers/implementations/kdfs/hkdf.c#L534
cannot overflow. So this is only a minor change proposal to avoid
a potentially vulnerable code pattern and to improve readability.
More information: https://github.com/github/codeql/pull/12036#issuecomment-1466056959

CLA: trivial

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

(cherry picked from commit 56a51b5a1ecd54eadc80bed4bfe5044a340787c1)

2 years agoFix stack corruption in ui_read
Bernd Edlinger [Sat, 13 May 2023 07:04:18 +0000 (09:04 +0200)] 
Fix stack corruption in ui_read

This is an alternative to #20893

Additionally this fixes also a possible issue in UI_UTIL_read_pw:

When UI_new returns NULL, the result code would still be zero
as if UI_UTIL_read_pw succeeded, but the password buffer is left
uninitialized, with subsequent possible stack corruption or worse.

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

(cherry picked from commit a64c48cff88e032cf9513578493c4536df725a22)

2 years agoFixed EVP_PKEY_CTX_set_ec_paramgen_curve_nid() for SM2 in ENGINEs
Yuan, Shuai [Wed, 10 May 2023 01:22:16 +0000 (21:22 -0400)] 
Fixed EVP_PKEY_CTX_set_ec_paramgen_curve_nid() for SM2 in ENGINEs

The CTRL translation is missing for SM2 key types.

Fixes #20899
Signed-off-by: Yuan, Shuai <shuai.yuan@intel.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20900)

(cherry picked from commit 43d5dac9d00ac486823d949f85ee3ad650b62af8)

2 years agoCMP client: fix checking new cert enrolled with oldcert and without private key
Dr. David von Oheimb [Tue, 25 Apr 2023 17:26:36 +0000 (19:26 +0200)] 
CMP client: fix checking new cert enrolled with oldcert and without private key

Reviewed-by: Tomas Mraz <tomas@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/20832)

(cherry picked from commit e0f1ec3b2ec1b137695abc3199a62def5965351f)

2 years agoCMP client: fix error response on -csr without private key, also in docs
Dr. David von Oheimb [Tue, 25 Apr 2023 17:14:34 +0000 (19:14 +0200)] 
CMP client: fix error response on -csr without private key, also in docs

Reviewed-by: Tomas Mraz <tomas@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/20832)

(cherry picked from commit 2d6585986f3b754750b25e7a296a08e7129a5320)

2 years agoapps/openssl.cnf: fix reference to insta.ca.crt
Dr. David von Oheimb [Tue, 25 Apr 2023 10:21:33 +0000 (12:21 +0200)] 
apps/openssl.cnf: fix reference to insta.ca.crt

Reviewed-by: Tomas Mraz <tomas@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/20832)

(cherry picked from commit 14ca1b6f4694ad27b1163bcafda1683f4dd05a30)

2 years agoprovider: return error if buf too small when getting ec pubkey param
Yi Li [Fri, 5 May 2023 03:30:05 +0000 (11:30 +0800)] 
provider: return error if buf too small when getting ec pubkey param

Fixes #20889

There was an incorrect value passed to EC_POINT_point2oct() for the
buffer size of the param passed-in.

Added testcases.

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

(cherry picked from commit 91070877adb905f51eb4b19b730d42fc257bae13)

2 years agoFix typos found by codespell
Dimitri Papadopoulos [Wed, 10 May 2023 10:10:57 +0000 (12:10 +0200)] 
Fix typos found by codespell

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

Other typos have been fixed in a different commit.

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

(cherry picked from commit 9a271795f84eb5402ce1ecfbcfd21392ad1560d0)

2 years agoClarify documentation of SSL_SESSION_dup
Watson Ladd [Thu, 27 Apr 2023 17:16:49 +0000 (10:16 -0700)] 
Clarify documentation of SSL_SESSION_dup

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

(cherry picked from commit 25bab273ccc9b517cc4c1783950e3f95421cb570)

2 years agoClear ownership when duplicating sessions
Watson Ladd [Thu, 27 Apr 2023 17:14:51 +0000 (10:14 -0700)] 
Clear ownership when duplicating sessions

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

(cherry picked from commit 9fdf9a44bbe3827fe653165a07281ccae8ab0947)

2 years agoFixed TLS1.3 handshake issue for legacy engine API.
Yuan, Shuai [Wed, 10 May 2023 08:49:54 +0000 (04:49 -0400)] 
Fixed TLS1.3 handshake issue for legacy engine API.

Signed-off-by: Yuan, Shuai <shuai.yuan@intel.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20922)

(cherry picked from commit be6497aa208948c960a28363bac98a429677bd9d)

2 years agoCMP app: fix deallocated host/port fields in APP_HTTP_TLS_INFO
Dr. David von Oheimb [Mon, 16 Jan 2023 14:48:24 +0000 (15:48 +0100)] 
CMP app: fix deallocated host/port fields in APP_HTTP_TLS_INFO

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

(cherry picked from commit 20d4dc8898edc12806ead2100ac09b907662aff6)

2 years agoCMP app and app_http_tls_cb(): pick the right TLS hostname (also without port)
Dr. David von Oheimb [Thu, 12 Jan 2023 09:54:50 +0000 (10:54 +0100)] 
CMP app and app_http_tls_cb(): pick the right TLS hostname (also without port)

Fixes #20031

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

(cherry picked from commit 30b9a6ec89d97152b5a564b3acf3a94ee57185a7)

2 years agoFix a typo found by codespell in a Makefile variable
Dimitri Papadopoulos [Tue, 9 May 2023 09:50:06 +0000 (11:50 +0200)] 
Fix a typo found by codespell in a Makefile variable

I have no experience with building on Windows, so I don't know the
effect of fixing this typo. I guess that this will fix a bug at worst.

CLA: trivial

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

(cherry picked from commit e5a054b7fcafc98a1dbf4358da390dc6e7759de5)

2 years agoDLTS → DTLS
Dimitri Papadopoulos [Tue, 9 May 2023 06:04:20 +0000 (08:04 +0200)] 
DLTS → DTLS

Fix a typo that is confusing for newcomers.

CLA: trivial

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

(cherry picked from commit 2913b5c09fcc4e5d493589ded2c22a3116127ed0)

2 years agoFix memory leak in engine_cleanup_add_first()
Kovalev Vasiliy [Thu, 4 May 2023 12:12:33 +0000 (16:12 +0400)] 
Fix memory leak in engine_cleanup_add_first()

Fixes #20870

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

(cherry picked from commit 8c63b14296f117b07781509ced529a8955d78fb9)

2 years agoaes-gcm-armv8_64 asm support bigdian
JerryDevis [Sat, 11 Mar 2023 10:35:23 +0000 (18:35 +0800)] 
aes-gcm-armv8_64 asm support bigdian

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

(cherry picked from commit 32344a74b7ee2693a5bfda361c40ec60ab5be624)

2 years agoPrevent a fuzzing timeout in the conf fuzzer
Matt Caswell [Wed, 26 Apr 2023 14:04:42 +0000 (15:04 +0100)] 
Prevent a fuzzing timeout in the conf fuzzer

The fuzzer was creating a config file with large numbers of includes
which are expensive to process. However this should not cause a security
issue, and should never happen in normal operation so we can ignore it.

Fixes ossfuzz issue 57718.

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

(cherry picked from commit 5f3adf396b06ee3b81938468995e69cff4ca64d1)

2 years agoFix the padlock engine
Bernd Edlinger [Thu, 26 Jan 2023 14:45:03 +0000 (15:45 +0100)] 
Fix the padlock engine

... after it was broken for almost 5 years,
since the first 1.1.1 release.
Note: The last working version was 1.1.0l release.

Fixes #20073

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@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/20146)

(cherry picked from commit 849ed515c7838943eab42de5c29d6a1f91079a11)

2 years agoFix broken links on asym_cipher manpages
Ladislav Marko [Thu, 13 Apr 2023 15:13:36 +0000 (17:13 +0200)] 
Fix broken links on asym_cipher manpages

Links were missing starting tags

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

(cherry picked from commit 010333be5362a07508888124c83efac35b28760f)

2 years agoAdd negative integer check when using ASN1_BIT_STRING
mlitre [Mon, 1 May 2023 09:07:21 +0000 (11:07 +0200)] 
Add negative integer check when using ASN1_BIT_STRING

The negative integer check is done to prevent potential overflow.
Fixes #20719.

CLA: trivial

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

(cherry picked from commit 1258a8e4361320cd3cfaf9ede692492ce01034c8)

2 years agorand: trust user supplied entropy when configured without a random source
Pauli [Thu, 27 Apr 2023 01:25:11 +0000 (11:25 +1000)] 
rand: trust user supplied entropy when configured without a random source

Fixes #20841

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

(cherry picked from commit 56547da9d3fa24f54b439497d322b12beb004c80)

2 years agoparam->ctrl translation: Fix evp_pkey_ctx_setget_params_to_ctrl()
Richard Levitte [Fri, 21 Apr 2023 04:00:47 +0000 (06:00 +0200)] 
param->ctrl translation: Fix evp_pkey_ctx_setget_params_to_ctrl()

Ensure that ctx.ctrl_cmd defaults to translation->cmd_num

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

(cherry picked from commit 1009940c14716ac03d5f161bdb4ae626ec6fe729)

2 years agoparam->ctrl translation: Fix fix_ec_paramgen_curve_nid()
Richard Levitte [Thu, 20 Apr 2023 05:22:53 +0000 (07:22 +0200)] 
param->ctrl translation: Fix fix_ec_paramgen_curve_nid()

This function didn't prepare space to get the param string, which causes
the default_fixup_args() call to fail.

Fixes #20161

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

(cherry picked from commit ac52fe5f5ae7a1d062f09adab7744e3a3b2ddbcf)

2 years agoAvoid generating RSA keys with p < q
rkarmaka98 [Wed, 26 Apr 2023 07:53:35 +0000 (07:53 +0000)] 
Avoid generating RSA keys with p < q

We swap p and q in that case except when ACVP tests are being run.

Fixes #20823

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

(cherry picked from commit dc231eb598460aec239c7f597f560bca47d9f72a)

2 years agofix md5 bug on aarch64 big-endian plantform.
Liu-ErMeng [Thu, 27 Apr 2023 03:14:02 +0000 (11:14 +0800)] 
fix md5 bug on aarch64 big-endian plantform.

Signed-off-by: Liu-ErMeng <liuermeng2@huawei.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20829)

(cherry picked from commit 004bd8f97d11bb7ac5f2de89f7060e03222b60fe)

2 years agoImprove documentation of -no_ssl3, -no_tls1, -no_tls1_1, -no_tls1_2, -no_tls1_3 options
rkarmaka98 [Wed, 26 Apr 2023 08:11:01 +0000 (08:11 +0000)] 
Improve documentation of -no_ssl3, -no_tls1, -no_tls1_1, -no_tls1_2, -no_tls1_3 options

Fixes #19014

CLA: trivial

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

(cherry picked from commit 06565f36e78e6155834875ad544bb48838a812e4)

2 years agohttp proxy handling: Use ossl_safe_getenv() instead of getenv()
Mukesh Bharsakle [Sat, 22 Apr 2023 13:56:35 +0000 (14:56 +0100)] 
http proxy handling: Use ossl_safe_getenv() instead of getenv()

CLA: trivial

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

(cherry picked from commit e7cbb09fdf8d835bd0d88b4b288edfd525be569c)

2 years agoASN1_OCTET_STRING_new() calls ASN1_STRING_type_new(V_ASN1_OCTET_STRING)
Vladimir Kotal [Wed, 26 Apr 2023 12:31:25 +0000 (14:31 +0200)] 
ASN1_OCTET_STRING_new() calls ASN1_STRING_type_new(V_ASN1_OCTET_STRING)

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

(cherry picked from commit 26f0150fce64dd878b77eddc4504fd441cbdef87)

2 years agofix aes-xts bug on aarch64 big-endian env.
Liu-ErMeng [Fri, 21 Apr 2023 08:04:51 +0000 (16:04 +0800)] 
fix aes-xts bug on aarch64 big-endian env.

Signed-off-by: Liu-ErMeng <liuermeng2@huawei.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20797)

(cherry picked from commit 4df13d1054e143f1cbf13fa347491807289f87b7)

2 years agoAPPS/cmp: prevent HTTP client failure on -rspin option with too few filenames
Dr. David von Oheimb [Tue, 14 Feb 2023 12:18:40 +0000 (13:18 +0100)] 
APPS/cmp: prevent HTTP client failure on -rspin option with too few filenames

The logic for handling inconsistent use of -rspin etc., -port, -server,
and -use_mock_srv options proved faulty.  This is fixed here, updating and
correcting also the documentation and diagnostics of the involved options.

In particular, the case that -rspin (or -rspout. reqin, -reqout) does not
provide enough message file names was not properly described and handled.

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

(cherry picked from commit 1f757df1f3de0c18cc22a4992d66e9a7b113f61d)

2 years agoCorrect the CHANGES entry for CVE-2023-1255
Tomas Mraz [Fri, 21 Apr 2023 08:14:13 +0000 (10:14 +0200)] 
Correct the CHANGES entry for CVE-2023-1255

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

(cherry picked from commit e6990079c2413625d2039ebed49ea17a5b8cf935)

2 years agoFix regression of no-posix-io builds
Tomas Mraz [Thu, 20 Apr 2023 09:41:46 +0000 (11:41 +0200)] 
Fix regression of no-posix-io builds

Instead of using stat() to check if a file is a directory
we just skip . and .. as a workaround.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/20786)

(cherry picked from commit 3155b5a90e6ad9c7369d09e70e81686f4b321a73)

2 years agoFix calling pthread_key_delete on uninitialized data
Petr Mikhalicin [Fri, 21 Apr 2023 09:25:43 +0000 (12:25 +0300)] 
Fix calling pthread_key_delete on uninitialized data

default_context_do_init may be never called and CRYPTO_THREAD_init_local
inside it may be never called too. But corresponding
CRYPTO_THREAD_cleanup_local is always called at cleanup stage. This lead
to undefined behavior.

So, add flag to check that default_context_do_init will be called
successfully or not.

Fix: #20697

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

(cherry picked from commit 31295ca02c0a2d7209a33047c7f6dd1dabc12c93)

2 years agofips: setup the FIPS provider in pendantic mode for testing
Pauli [Tue, 18 Apr 2023 01:11:17 +0000 (11:11 +1000)] 
fips: setup the FIPS provider in pendantic mode for testing

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

(cherry picked from commit c04e78f0c69201226430fed14c291c281da47f2d)

2 years agotest: update ssl_new tests in line with pedantic FIPS policy
Pauli [Tue, 18 Apr 2023 04:41:17 +0000 (14:41 +1000)] 
test: update ssl_new tests in line with pedantic FIPS policy

Add a new option to the `test' section of SSL test data structure.
This contains a space separated list of version checks, all of which must
pass.

Note that the version checks are as they as because:

- 3.1.0 doesn't have mandatory EMS support, so it can run the old tests.
- 3.1.1 (& later) will have mandatory EMS support, so they can't run them.

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

(cherry picked from commit 4454c20f026bb47f158ea05c207f143c81d674d8)

2 years agotest: update TLS PDF tests in line with pedantic FIPS policy
Pauli [Tue, 18 Apr 2023 02:59:06 +0000 (12:59 +1000)] 
test: update TLS PDF tests in line with pedantic FIPS policy

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

(cherry picked from commit e07999369a13a29243f34cbd5d24281783984299)

2 years agotest: update evprand tests in line with pedantic FIPS policy
Pauli [Tue, 18 Apr 2023 02:55:25 +0000 (12:55 +1000)] 
test: update evprand tests in line with pedantic FIPS policy

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

(cherry picked from commit cf3d5c2fbaf734731b1ccbd3a84e21eeb6d0f30d)

2 years agosslapi: use correct fipsmodule.cnf
Pauli [Tue, 18 Apr 2023 07:20:40 +0000 (17:20 +1000)] 
sslapi: use correct fipsmodule.cnf

The SSL API tests copies fipsmodule.cnf and modifies it.  Unfortunately, it
grabbed the wrong instance of this file.

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

(cherry picked from commit bc5d9502c5f3c726e42ef72263a4076fd48300d6)

2 years agoBump actions/setup-python from 4.5.0 to 4.6.0
dependabot[bot] [Fri, 21 Apr 2023 14:22:29 +0000 (14:22 +0000)] 
Bump actions/setup-python from 4.5.0 to 4.6.0

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.5.0 to 4.6.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v4.5.0...v4.6.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/20792)

(cherry picked from commit 3ac96c8f715672ff77025d48b5773f5de4f84215)

2 years agoFix checking return code of EVP_PKEY_get_int_param at check_curve
Petr Mikhalicin [Wed, 19 Apr 2023 11:43:02 +0000 (14:43 +0300)] 
Fix checking return code of EVP_PKEY_get_int_param at check_curve

According to docs, EVP_PKEY_get_int_param should return 1 on Success, and
0 on Failure. So, fix checking of this return value at check_curve

CLA: trivial

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

(cherry picked from commit 4e5f3d691343a691ddae739c51f7ae71e9893c98)

2 years agoaesv8-armx.pl: Avoid buffer overrread in AES-XTS decryption
Tomas Mraz [Mon, 17 Apr 2023 14:51:20 +0000 (16:51 +0200)] 
aesv8-armx.pl: Avoid buffer overrread in AES-XTS decryption

Original author: Nevine Ebeid (Amazon)
Fixes: CVE-2023-1255
The buffer overread happens on decrypts of 4 mod 5 sizes.
Unless the memory just after the buffer is unmapped this is harmless.

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

(cherry picked from commit 72dfe46550ee1f1bbfacd49f071419365bc23304)

2 years agotest: test -pedantic option in fipsinstall
Pauli [Mon, 17 Apr 2023 05:53:13 +0000 (15:53 +1000)] 
test: test -pedantic option in fipsinstall

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

(cherry picked from commit c8093347f736c7991350d26048b680d0e64974a0)

2 years agodoc: document the -pedantic option to fipsinstall.
Pauli [Mon, 17 Apr 2023 05:39:24 +0000 (15:39 +1000)] 
doc: document the -pedantic option to fipsinstall.

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

(cherry picked from commit d30fec6ff438f73f4e255b0b9c6af3ea57ec122a)

2 years agofipsinstall: add -pedantic option
Pauli [Mon, 17 Apr 2023 05:31:29 +0000 (15:31 +1000)] 
fipsinstall: add -pedantic option

This adds a -pedantic option to fipsinstall that adjusts the various
settings to ensure strict FIPS compliance rather than backwards
compatibility.

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

(cherry picked from commit bc2a4225a4a03f70bb0154a72c2889aa80c1b0f6)

2 years agoConfigurations/descrip.mms.tmpl: Fix a few typos
Richard Levitte [Fri, 14 Apr 2023 11:47:34 +0000 (13:47 +0200)] 
Configurations/descrip.mms.tmpl: Fix a few typos

These typos caused failed propagation of the 'cflags' attribute from
Configurations/10-main.conf.

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

(cherry picked from commit 04e0abc8bb1c24534d16cc930b611ac1d03bc9bf)

2 years agoFix broken links in crypto manpage
Ladislav Marko [Sat, 15 Apr 2023 08:52:26 +0000 (10:52 +0200)] 
Fix broken links in crypto manpage

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

(cherry picked from commit d79b6104ae947b8749623d3152c309f398387a54)

2 years agoCMP cert_response(): add missing rejection status on client rejecting new cert
Dr. David von Oheimb [Wed, 1 Feb 2023 16:22:17 +0000 (17:22 +0100)] 
CMP cert_response(): add missing rejection status on client rejecting new cert

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

(cherry picked from commit 44e816bd540c8687c1b4995febbde2626a655338)

2 years agocmp_client_test.c: add tests for errors reported by server on subsequent requests...
Dr. David von Oheimb [Wed, 1 Feb 2023 14:50:54 +0000 (15:50 +0100)] 
cmp_client_test.c: add tests for errors reported by server on subsequent requests in a transaction

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

(cherry picked from commit 154625e1090b18c8c306a6b7a6970dbab185c49d)

2 years agoossl_cmp_mock_srv_new.pod: correct/update names of internal test support functions
Dr. David von Oheimb [Wed, 1 Feb 2023 14:47:14 +0000 (15:47 +0100)] 
ossl_cmp_mock_srv_new.pod: correct/update names of internal test support functions

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

(cherry picked from commit 7439661627b8009f69b13c57b7372286e85a2805)

2 years agoOSSL_CMP_SRV_process_request(): fix recipNonce on error in subsequent request of...
Dr. David von Oheimb [Wed, 1 Feb 2023 14:43:35 +0000 (15:43 +0100)] 
OSSL_CMP_SRV_process_request(): fix recipNonce on error in subsequent request of a transaction

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

(cherry picked from commit 7cd91d221f630f18eb2cc5c01c4204e31c0a15aa)

2 years agocmp_ctx.c: fix wrong comments on OSSL_CMP_CTX_set1_{recipient,issuer}
Dr. David von Oheimb [Wed, 1 Feb 2023 14:39:52 +0000 (15:39 +0100)] 
cmp_ctx.c: fix wrong comments on OSSL_CMP_CTX_set1_{recipient,issuer}

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

(cherry picked from commit 56d5c55de779f35d4e66ae4b791ef1488ab1f57a)

2 years agoCMP check_transactionID_or_nonce(): fix reason code on unmatched recipNonce
Dr. David von Oheimb [Wed, 1 Feb 2023 14:37:21 +0000 (15:37 +0100)] 
CMP check_transactionID_or_nonce(): fix reason code on unmatched recipNonce

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

(cherry picked from commit 40eea44884dff96ffd753bfe66c025145a69191b)

2 years agoossl_cmp_msg_check_update(): fix two wrong error return values (-1 instead of 0)
Dr. David von Oheimb [Wed, 1 Feb 2023 14:36:25 +0000 (15:36 +0100)] 
ossl_cmp_msg_check_update(): fix two wrong error return values (-1 instead of 0)

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

(cherry picked from commit 2eb7a11035144b5556b81aa7e8233927165a5880)

2 years agotest_get_libctx(): prevent crash when called with NULL provider arg
Dr. David von Oheimb [Wed, 1 Feb 2023 14:34:19 +0000 (15:34 +0100)] 
test_get_libctx(): prevent crash when called with NULL provider arg

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

(cherry picked from commit 40f3a606b1671d417b63a902dab205e7906dbccd)

2 years agocrypto/cmp: fix CertReqId to use in p10cr transactions acc. to RFC 4210
Dr. David von Oheimb [Wed, 15 Feb 2023 14:38:35 +0000 (15:38 +0100)] 
crypto/cmp: fix CertReqId to use in p10cr transactions acc. to RFC 4210

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/20298)

(cherry picked from commit 25b18e629d5cab40f88b33fd9ecf0d69e08c7707)

2 years agobn_local: remove unused `PTR_SIZE_INT` definition
Alois Klink [Sun, 16 Apr 2023 18:19:04 +0000 (19:19 +0100)] 
bn_local: remove unused `PTR_SIZE_INT` definition

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

(cherry picked from commit dcfeb617477dd957f69e713cbc61fd4dca0f2db4)

2 years agobn_nist: remove unused type-punning union `u`
Alois Klink [Sun, 16 Apr 2023 16:03:23 +0000 (17:03 +0100)] 
bn_nist: remove unused type-punning union `u`

We no longer need to cast function pointers to PTR_SIZE_INT.

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

(cherry picked from commit f659f7a1c70709caa1727bb0b7f836d170d35bb5)

2 years agobn_nist: replace pointer bit-fiddling with ternary
Alois Klink [Sun, 16 Apr 2023 14:40:01 +0000 (15:40 +0100)] 
bn_nist: replace pointer bit-fiddling with ternary

Bit-fiddling pointers is technically implementation defined behavior
in the C specification so the following code is not supported in all
platforms:

    PTR_SIZE_INT mask;
    void * a, b, c;
    int boolean_flag;

    mask = 0 - boolean_flag;
    /* Not guaranteed to be a valid ptr to a or b on all platforms  */
    a = (void *)
        ((((PTR_SIZE_INT) b & ~mask) | (((PTR_SIZE_INT)) c & mask)));

Using a ternary conditional operator is supported on all platforms
(i.e. `a = boolean_flag ? b : c;`).

On most modern compilers/CPUs, this will be faster, since it will
get converted to a CMOV instruction.

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

(cherry picked from commit 326af4ad171b849ba1e76fd425d8f337718c4108)

2 years agoadding provider_unload functions for cmp_ tests
Danny Carpenter [Thu, 13 Apr 2023 19:16:44 +0000 (19:16 +0000)] 
adding provider_unload functions for cmp_ tests

CLA: trivial

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

(cherry picked from commit 8835940db58229fc467cdea1eebf3f064352a086)

2 years agoList also non-fetchable hashes in openssl dgst -list
GauriSpears [Thu, 30 Mar 2023 11:30:59 +0000 (16:30 +0500)] 
List also non-fetchable hashes in openssl dgst -list

CLA: trivial

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

(cherry picked from commit 7eab7680ee61c64b2ae7acd9dd199ab6734f3d1f)

2 years agoFix the LCM computation in the RSA multiprime key check
Tomas Mraz [Tue, 11 Apr 2023 14:24:44 +0000 (16:24 +0200)] 
Fix the LCM computation in the RSA multiprime key check

Fixes #20693

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

(cherry picked from commit efbff4de3e259cee71a4e1bbd86b30ebd86bbdae)

2 years agodoc: Fix incorrect pairing of functions
Ladislav Marko [Tue, 11 Apr 2023 13:51:06 +0000 (15:51 +0200)] 
doc: Fix incorrect pairing of functions

CLA: trivial

The functions that should be implemented together are `OSSL_FUNC_signature_verify_recover_init` and `OSSL_FUNC_signature_verify_recover` and not  `OSSL_FUNC_signature_verify_recover_init` with ` OSSL_FUNC_signature_verify_init`

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

(cherry picked from commit 51b941ac290864103d00a3d6a3018372b58b01f4)

2 years agodoc: Fix misleading stucture info
Ladislav Marko [Tue, 11 Apr 2023 13:56:11 +0000 (15:56 +0200)] 
doc: Fix misleading stucture info

CLA: trivial

The thing created by `OSSL_FUNC_signature_newctx()` and `OSSL_FUNC_signature_dupctx()` is a signature context, not a signature. It's in the name of the function and surrounding documentation.

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

(cherry picked from commit b2023d5dfc957cf5a3cfca16961f97e79842b941)

2 years agoFixes #19580 ECX keygen
Yuan, Shuai [Tue, 4 Apr 2023 05:42:38 +0000 (01:42 -0400)] 
Fixes #19580 ECX keygen

Signed-off-by: Yuan, Shuai <shuai.yuan@intel.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/20680)

(cherry picked from commit 40f4884990a1717755df366e2aa06d01a1affd63)

2 years agoUpdated return value of PEM_write_TYPE() and PEM_write_bio_TYPE() in man-pages.
Jeeban Sethi [Mon, 3 Apr 2023 08:46:24 +0000 (14:16 +0530)] 
Updated return value of PEM_write_TYPE() and PEM_write_bio_TYPE() in man-pages.

Fixes #20218

CLA: trivial

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

(cherry picked from commit dfb8e185134df90fd3f21fb6ec625e7c295fdcea)

2 years agoAlternative fix for CVE-2022-4304
Bernd Edlinger [Mon, 13 Feb 2023 16:46:41 +0000 (17:46 +0100)] 
Alternative fix for CVE-2022-4304

This is about a timing leak in the topmost limb
of the internal result of RSA_private_decrypt,
before the padding check.

There are in fact at least three bugs together that
caused the timing leak:

First and probably most important is the fact that
the blinding did not use the constant time code path
at all when the RSA object was used for a private
decrypt, due to the fact that the Montgomery context
rsa->_method_mod_n was not set up early enough in
rsa_ossl_private_decrypt, when BN_BLINDING_create_param
needed it, and that was persisted as blinding->m_ctx,
although the RSA object creates the Montgomery context
just a bit later.

Then the infamous bn_correct_top was used on the
secret value right after the blinding was removed.

And finally the function BN_bn2binpad did not use
the constant-time code path since the BN_FLG_CONSTTIME
was not set on the secret value.

In order to address the first problem, this patch
makes sure that the rsa->_method_mod_n is initialized
right before the blinding context.

And to fix the second problem, we add a new utility
function bn_correct_top_consttime, a const-time
variant of bn_correct_top.

Together with the fact, that BN_bn2binpad is already
constant time if the flag BN_FLG_CONSTTIME is set,
this should eliminate the timing oracle completely.

In addition the no-asm variant may also have
branches that depend on secret values, because the last
invocation of bn_sub_words in bn_from_montgomery_word
had branches when the function is compiled by certain
gcc compiler versions, due to the clumsy coding style.

So additionally this patch stream-lined the no-asm
C-code in order to avoid branches where possible and
improve the resulting code quality.

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

2 years agoRevert "Fix Timing Oracle in RSA decryption"
Bernd Edlinger [Tue, 14 Feb 2023 04:06:36 +0000 (05:06 +0100)] 
Revert "Fix Timing Oracle in RSA decryption"

This reverts commit 8022a4799fe884b3bf8d538e2b4c4ec323663118.

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

2 years agoErase temporary buffer in EVP_PKEY_get_bn_param()
Anatolii Lishchynskyi [Wed, 29 Mar 2023 14:16:48 +0000 (17:16 +0300)] 
Erase temporary buffer in EVP_PKEY_get_bn_param()

Function EVP_PKEY_get_bn_param() uses temporary buffer (on stack or
heap allocated) to store serialized bignum, but after deserializing it
into BIGNUM*, the buffer is not erased and may contain sensitive data.

This change makes sure the buffer is erased if it was successfully
filled before. Unfortunately, it does not distinguish between public and
private key components, and will always erase the buffer.

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

(cherry picked from commit 34e4a962bca998cc2d6eb4be721153fbde2f4c35)

2 years agoDon't call OPENSSL_init_crypto from inside a RUN_ONCE
Matt Caswell [Fri, 31 Mar 2023 09:35:32 +0000 (10:35 +0100)] 
Don't call OPENSSL_init_crypto from inside a RUN_ONCE

Calling OPENSSL_init_crypto from inside a RUN_ONCE seems like a bad idea.
This is especially bad if OPENSSL_init_crypto can recursively end up
attempting to call the RUN_ONCE that we're already inside.

The initialisation in OPENSSL_init_crypto is already "run once" protected.
There is no need to protect it "twice".

Fixes #20653

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

2 years agoAvoid calling into provider with the same iv_len or key_len
Tomas Mraz [Fri, 31 Mar 2023 13:46:15 +0000 (15:46 +0200)] 
Avoid calling into provider with the same iv_len or key_len

Fixes #20625

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

(cherry picked from commit eb52450f5151e8e78743ab05de21a344823316f5)

2 years agoMake DSA_sign() test for negative p,q,g values.
slontis [Tue, 21 Mar 2023 05:52:34 +0000 (15:52 +1000)] 
Make DSA_sign() test for negative p,q,g values.

Related to #20268

DSA_sign() assumes that the signature passed in is related to DSA_size().
If q is negative then DSA_size() actually fails and returns 0.

A test that tries to allocate the signature buffer using DSA_size() and then
pass it to DSA_sign() will then either.

(1) Have a signature buffer of NULL. In this case it was leaking data
returned via i2d_DSA_SIG.

(2) Cause a seg fault because we created a buffer that was not large
enough to hold the signature. As it already checked zero we also now
check for negative values also.

Reviewed-by: Tomas Mraz <tomas@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/20553)

(cherry picked from commit 9559ad0e8d433a2a212b63cc848fa2ac82a9b048)

2 years agoIncorrect null pointer check
afshinpir [Wed, 29 Mar 2023 22:26:44 +0000 (11:26 +1300)] 
Incorrect null pointer check

CLA: trivial
There is an incorrect null pointer check and this ccommit resolves it.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/20646)

(cherry picked from commit 6469043bbabc9728aed61d7708c32e2ae319be1d)

2 years agoFix mem leak in ECDSA_sign().
slontis [Tue, 21 Mar 2023 06:06:06 +0000 (16:06 +1000)] 
Fix mem leak in ECDSA_sign().

Similiar to the issue found in PR #20553 for DSA_sign().
ECDSA_sign() leaked memory if the signature was NULL
when i2d_ECDSA_SIG was called.

Note that this does not affect the higher level EVP
functions as they correctly handle NULL.

Reviewed-by: Tomas Mraz <tomas@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/20554)

(cherry picked from commit 4befe81a99b89c52b749a87eece82c1cba4fab12)

2 years agodoc: Fix typo in EVP_EncryptInit.pod
Samuel Lee (ENS/CRYPTO) [Wed, 29 Mar 2023 20:02:38 +0000 (13:02 -0700)] 
doc: Fix typo in EVP_EncryptInit.pod

CLA: trivial

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/20645)

(cherry picked from commit 027226eb229c41d7066366a8b9ef8241da7500bd)

2 years agoAdd a test for an app data record appearing before epoch change in DTLS
Matt Caswell [Tue, 28 Mar 2023 15:25:22 +0000 (16:25 +0100)] 
Add a test for an app data record appearing before epoch change in DTLS

We had a test for a handshake record appearing before epoch change, and
a test for an app data record appearing before Finished - but not one for
the app data record appearing before epoch change.

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

2 years agoHandle app data records from the next epoch
Matt Caswell [Mon, 27 Mar 2023 14:59:41 +0000 (15:59 +0100)] 
Handle app data records from the next epoch

It is possible that DTLS records are received out of order such that
records from the next epoch arrive before we have finished processing the
current epoch. We are supposed to buffer such records but for some reason
we only did that for handshake and alert records. This is incorrect since
it is perfectly possible for app data records to arrive early too.

Fixes #20597

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

2 years agoSM4 check should be for __aarch64__, not __ARM_MAX_ARCH__ >= 8
Tom Cosgrove [Tue, 28 Mar 2023 10:53:37 +0000 (11:53 +0100)] 
SM4 check should be for __aarch64__, not __ARM_MAX_ARCH__ >= 8

(And then __arm__ and __arm tests are redundant)

Fixes #20604 for 3.1 branch

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

2 years agoFix: some patches related to error exiting
Peiwei Hu [Wed, 5 Jan 2022 15:17:53 +0000 (23:17 +0800)] 
Fix: some patches related to error exiting

Fixes #20613

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

2 years agoDeclare FIPS option functions in their own header 20633/head
Pauli [Thu, 23 Mar 2023 22:24:23 +0000 (09:24 +1100)] 
Declare FIPS option functions in their own header

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

(cherry picked from commit 30ab774770a7e8547b0d6363b63a73cc80f33a7b)

2 years agotest: test -drbg_allow_truncated_digests option
Pauli [Sun, 19 Mar 2023 23:49:40 +0000 (10:49 +1100)] 
test: test -drbg_allow_truncated_digests option

Verify that the option produces the correct output in the FIPS configuration
file and that the default is as expected.

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

(cherry picked from commit 78bcbc1ea440feac3e9a3292dba4b055b81ca29e)

2 years agoLet fipsinstall know about DRBG digiest limiting
Pauli [Sun, 19 Mar 2023 22:46:08 +0000 (09:46 +1100)] 
Let fipsinstall know about DRBG digiest limiting

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

(cherry picked from commit b345dbed28701f8aab06b0271603186127499928)

2 years agochanges: note the banning of truncated hashes with DRBGs
Pauli [Fri, 17 Mar 2023 00:23:49 +0000 (11:23 +1100)] 
changes: note the banning of truncated hashes with DRBGs

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

(cherry picked from commit 808b30f6b60da3e92283e315f2e6f0e574a62080)

2 years agodoc: note the restriction on digests used by DRBGs in FIPS mode.
Pauli [Thu, 16 Mar 2023 03:21:25 +0000 (14:21 +1100)] 
doc: note the restriction on digests used by DRBGs in FIPS mode.

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

(cherry picked from commit e14fc22c90ce5a9e6d66d8658fc6bb37f95019da)

2 years agoDRBG: restrict the digests that can be used with HMAC and Hash DRBGs.
Pauli [Thu, 16 Mar 2023 03:12:09 +0000 (14:12 +1100)] 
DRBG: restrict the digests that can be used with HMAC and Hash DRBGs.

According to FIP 140-3 IG D.R: https://csrc.nist.gov/CSRC/media/Projects/cryptographic-module-validation-program/documents/fips%20140-3/FIPS%20140-3%20IG.pdf

Outside of FIPS, there remains no restriction other than not allowing
XOF digests.

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

(cherry picked from commit f553c0f0dd24f037f31d971a99a1ffe7a11f64e6)

2 years agofips: rework the option handling code
Pauli [Fri, 17 Mar 2023 01:42:21 +0000 (12:42 +1100)] 
fips: rework the option handling code

Add option for restricting digests available to DRBGs.

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

(cherry picked from commit 83ccf81b1dd8886d54c570354ef8c532af4c514f)