]> git.ipfire.org Git - thirdparty/openssl.git/log
thirdparty/openssl.git
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)

2 years agoFix documentation of X509_VERIFY_PARAM_add0_policy()
Tomas Mraz [Tue, 21 Mar 2023 15:15:47 +0000 (16:15 +0100)] 
Fix documentation of X509_VERIFY_PARAM_add0_policy()

The function was incorrectly documented as enabling policy checking.

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

2 years agoUpdated CHANGES.md and NEWS.md for CVE-2023-0465
Matt Caswell [Thu, 23 Mar 2023 15:31:25 +0000 (15:31 +0000)] 
Updated CHANGES.md and NEWS.md for CVE-2023-0465

Also updated the entries for CVE-2023-0464

Related-to: CVE-2023-0465
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20586)

2 years agoAdd a Certificate Policies Test
Matt Caswell [Tue, 7 Mar 2023 17:07:57 +0000 (17:07 +0000)] 
Add a Certificate Policies Test

Test that a valid certificate policy is accepted and that an invalid
certificate policy is rejected. Specifically we are checking that a
leaf certificate with an invalid policy is detected.

Related-to: CVE-2023-0465
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20586)

2 years agoEnsure that EXFLAG_INVALID_POLICY is checked even in leaf certs
Matt Caswell [Tue, 7 Mar 2023 16:52:55 +0000 (16:52 +0000)] 
Ensure that EXFLAG_INVALID_POLICY is checked even in leaf certs

Even though we check the leaf cert to confirm it is valid, we
later ignored the invalid flag and did not notice that the leaf
cert was bad.

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

2 years agoGenerate some certificates with the certificatePolicies extension
Matt Caswell [Tue, 7 Mar 2023 15:22:40 +0000 (15:22 +0000)] 
Generate some certificates with the certificatePolicies extension

Related-to: CVE-2023-0465
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20586)

2 years ago`EVP_PKEY_CTX_dup` segmentation fault fix
afshinpir [Wed, 22 Mar 2023 23:25:45 +0000 (12:25 +1300)] 
`EVP_PKEY_CTX_dup` segmentation fault fix

CLA: trivial
The the provider, context duplication method for signature, key
exchange, asymmetric cipher, and key encapsulation is optional. But if
they are missing, we will get a segmentation fault in `EVP_PKEY_CTX_dup`
because they are called without null pointer checking.

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

(cherry picked from commit 864c70e43ea5f1d7fe20bfea457e53e79fd46b6e)

2 years agoCMP add: fix -reqin option, which requires adding OSSL_CMP_MSG_update_recipNonce()
Dr. David von Oheimb [Fri, 3 Feb 2023 09:31:19 +0000 (10:31 +0100)] 
CMP add: fix -reqin option, which requires adding OSSL_CMP_MSG_update_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/20204)

(cherry picked from commit b75d56dee09ac6f1fdb75169da891668cf181066)

2 years agoapps/cmp.c: make sure that last -reqin argument is actually used
Dr. David von Oheimb [Thu, 2 Feb 2023 18:24:56 +0000 (19:24 +0100)] 
apps/cmp.c: make sure that last -reqin argument is actually used

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

(cherry picked from commit d27f73ad31691d81715b4affe01264fa10f5da9e)

2 years agoCMP app: improve doc and help output on -{req,rsp}{in,out} options
Dr. David von Oheimb [Thu, 2 Feb 2023 18:13:47 +0000 (19:13 +0100)] 
CMP app: improve doc and help output on -{req,rsp}{in,out} options

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

(cherry picked from commit 44190234e4f65038f5b093306779a04e79fbd8cd)

2 years agoUpdate the EVP_PKEY_get_id documentation
Michael Baentsch [Mon, 13 Mar 2023 13:27:01 +0000 (14:27 +0100)] 
Update the EVP_PKEY_get_id documentation

The documentation didn't mention the development where EVP_PKEY_get_id()
returns a negative value for provider-only implementations, and the
migration guide didn't mention how to cope with that.

Fixes #20497

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

(cherry picked from commit a2a543e0e3ec277d136772b4b0e0bb3d1181d337)

2 years agoCMP app and doc: improve texts on (un-)trusted certs, srvCert, etc.
Dr. David von Oheimb [Mon, 19 Dec 2022 09:56:50 +0000 (10:56 +0100)] 
CMP app and doc: improve texts on (un-)trusted certs, srvCert, etc.

Reviewed-by: Hugo Landau <hlandau@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/20277)

(cherry picked from commit d5e50bdf87053d99e8fce50ac57d94bbed571b56)

2 years agotls1_set_groups_list: freeing *pext before overwriting
Peter Kaestle [Thu, 16 Feb 2023 14:02:46 +0000 (15:02 +0100)] 
tls1_set_groups_list: freeing *pext before overwriting

calling SSL_CTX_set1_groups_list() twice on one SSL_CTX* caused a memory
leak visible in valgrind:
  4 bytes in 1 blocks are definitely lost in loss record 1 of 1
     at 0x4841888: malloc (vg_replace_malloc.c:381)
     by 0x4B1EE96: CRYPTO_memdup (in libcrypto.so.3)
     by 0x48993A0: tls1_set_groups_list (in libssl.so.3)
     by 0x487AA7E: ssl3_ctx_ctrl (in libssl.so.3)
     by 0x1091EA: main (mem_leak.c:10)

  LEAK SUMMARY:
     definitely lost: 4 bytes in 1 blocks

Freeing *pext to fix it.

CLA: trivial

Signed-off-by: Peter Kaestle <peter.kaestle@nokia.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20317)

(cherry picked from commit fcf3a9f7c6a10acb2d92f03aec5e45df7dd712d5)

2 years agoOBJ_nid2obj(): Return UNDEF object instead of NULL for NID_undef
Tomas Mraz [Tue, 21 Mar 2023 10:36:56 +0000 (11:36 +0100)] 
OBJ_nid2obj(): Return UNDEF object instead of NULL for NID_undef

Fixes a regression from 3.0 from the obj creation refactoring.

Fixes #20555

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

(cherry picked from commit 908ba3ed9adbb3df90f7684a3111ca916a45202d)

2 years agoDisable the policy tree exponential growth test conditionally
Pauli [Wed, 22 Mar 2023 01:13:07 +0000 (12:13 +1100)] 
Disable the policy tree exponential growth test conditionally

If there is no EC specified, the test won't pass.

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

(cherry picked from commit f5935fcf8e4bc2191ac4a32e5b7ec32817642f1e)

2 years agoVC++ 2010 x86 compilers do not have InterlockedOr64
Georgi Valkov [Tue, 21 Mar 2023 10:49:23 +0000 (12:49 +0200)] 
VC++ 2010 x86 compilers do not have InterlockedOr64

The changes from the following commit should also apply to
Visual Studio 2010
https://github.com/openssl/openssl/commit/2d46a44ff24173d2cf5ea2196360cb79470d49c7#r104867505

Fixes build errors: undefined symbol InterlockedOr64
on Windows 2003, Visual Studio 2010 for x86 target.

CLA: trivial

Signed-off-by: Georgi Valkov <gvalkov@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20557)

(cherry picked from commit 8bdc3708964814ea0b7002df020fbd459e3a813f)

2 years agoDo not build P10-specific AES-GCM assembler on macOS
Evan Miller [Sat, 18 Mar 2023 15:03:22 +0000 (11:03 -0400)] 
Do not build P10-specific AES-GCM assembler on macOS

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

(cherry picked from commit 175645a1a695017a312155a2c1d864ad8bff4eaa)

2 years agochanges: note about policy tree size limits and circumvention
Pauli [Wed, 15 Mar 2023 03:13:22 +0000 (14:13 +1100)] 
changes: note about policy tree size limits and circumvention

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

2 years agotest: add test cases for the policy resource overuse
Pauli [Wed, 8 Mar 2023 03:39:25 +0000 (14:39 +1100)] 
test: add test cases for the policy resource overuse

These trees have pathological properties with respect to building.  The small
tree stays within the imposed limit, the large tree doesn't.

The large tree would consume over 150Gb of RAM to process.

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

2 years agox509: excessive resource use verifying policy constraints
Pauli [Wed, 8 Mar 2023 04:28:20 +0000 (15:28 +1100)] 
x509: excessive resource use verifying policy constraints

A security vulnerability has been identified in all supported versions
of OpenSSL related to the verification of X.509 certificate chains
that include policy constraints.  Attackers may be able to exploit this
vulnerability by creating a malicious certificate chain that triggers
exponential use of computational resources, leading to a denial-of-service
(DoS) attack on affected systems.

Fixes CVE-2023-0464

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

2 years agocmp: fix --strict-warnings windows builds
FdaSilvaYY [Fri, 10 Mar 2023 14:16:01 +0000 (15:16 +0100)] 
cmp: fix --strict-warnings windows builds

remove unneeded const qualifier to keep method declaration
and definition in sync.

Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/20436)

(cherry picked from commit 6f792f4d27b47213166e0fa9c9b10a3eab85b8f6)

2 years agonit: tidy-up code, and fix a typo.
FdaSilvaYY [Fri, 10 Mar 2023 14:21:05 +0000 (15:21 +0100)] 
nit: tidy-up code, and fix a typo.

Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/20436)

(cherry picked from commit f42d6b7ae62a2b2914b144153af56096f9b4a6d5)

2 years agocmp_msg.c: free memory of certStatus before goto err
JAVAID Mohammad-Habib [Tue, 28 Feb 2023 20:07:59 +0000 (21:07 +0100)] 
cmp_msg.c: free memory of certStatus before goto err

CLA: trivial

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

(cherry picked from commit c9c99018a887bfac1fe5a5ae6dcd8a5647494504)

2 years agoFix Configure test for -mips in CFLAGS
Mike Gilbert [Sun, 12 Feb 2023 22:56:58 +0000 (17:56 -0500)] 
Fix Configure test for -mips in CFLAGS

We want to add -mips2 or -mips3 only if the user hasn't already
specified a mips version in CFLAGS. The existing test was a
double-negative.

CLA: trivial

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

(cherry picked from commit 8b399c5e51b4d010650cb344a67a696daf096a05)

2 years agodoc: note the default iteration count for PBKDF2 in the enc command
Pauli [Wed, 8 Mar 2023 23:17:53 +0000 (10:17 +1100)] 
doc: note the default iteration count for PBKDF2 in the enc command

Fixes #20466

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

(cherry picked from commit 6678b0868b7660177f8b5af299894e2e99330a21)

2 years agoInclude the default iteration count in the help for the enc command
Pauli [Wed, 8 Mar 2023 23:15:54 +0000 (10:15 +1100)] 
Include the default iteration count in the help for the enc command

The only way to discover this otherwise is looking at the code.

Fixes #20466

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

(cherry picked from commit dc43f080c5d60ef76df4087c1cf53a4bbaad93bd)

2 years agorsaz-*k-avx512.pl: fix wrong name of avx512 flag variable
Tomas Mraz [Wed, 15 Mar 2023 16:46:29 +0000 (17:46 +0100)] 
rsaz-*k-avx512.pl: fix wrong name of avx512 flag variable

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20519)

2 years agoaes-gcm-avx512.pl: Fix the clang version detection on Apple Oses
Tomas Mraz [Wed, 15 Mar 2023 15:49:24 +0000 (16:49 +0100)] 
aes-gcm-avx512.pl: Fix the clang version detection on Apple Oses

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20519)

2 years agoFix version detection on Apple clang
Tomas Mraz [Wed, 15 Mar 2023 15:14:19 +0000 (16:14 +0100)] 
Fix version detection on Apple clang

Added missing fix from the master branch.

Fixes #20518

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20519)

2 years agoFix copyright disclaimer.
Pauli [Wed, 15 Mar 2023 08:19:35 +0000 (19:19 +1100)] 
Fix copyright disclaimer.

The mention of the GPL shouldn't have been there.

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

(cherry picked from commit c879f8ac56170a5cf929fab8067beb2a5902be2b)

2 years agoFix documented function return types
Andy Bernard [Mon, 13 Mar 2023 15:56:37 +0000 (15:56 +0000)] 
Fix documented function return types

The documented return type of the (incorrectly named; see below) OSSL_FUNC_decoder_export_object function signature is wrong; the correct type is int, due to the following line in core_dispatch.h:
OSSL_CORE_MAKE_FUNC(int, decoder_export_object,

Fixes #19543

Per the Github conversation with levitte and t8m for pull request #19964, the following issues are not addressed by this patch:

The macro OSSL_CORE_MAKE_FUNC in core_dispatch.h generates a function, and a corresponding function signature typedef with name ending in "_fn". The typedefed signature is unrelated to the signature of the function.
However, provider-decoder.pod describes typedefed signatures generated by the macro, but uses the names of the functions (lacking "_fn") instead of the typedefed signatures, which is a mismatch.

Also, the documented claim about OSSL_FUNC_decoder_export_object, etc that "None of these are actual functions" is contradicted by the fact that the code actually calls those functions, and calls them specifically by those names. E.g. in decoder_meth.c:
decoder->export_object = OSSL_FUNC_decoder_export_object(fns);

The functions are generated by OSSL_CORE_MAKE_FUNC.

The paragraph "None of these are actual functions"... should be replaced by something more like "These function signatures, generated by the OSSL_CORE_MAKE_FUNC macro, are for functions that are offered via function pointers in OSSL_DISPATCH arrays."

CLA: trivial

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

(cherry picked from commit 04af51c276e7d785a194eb9ed199abf250c5b3b6)

2 years agocms_ec.c: Fix broken backport of size_t fix in ecdh_cms_encrypt
Tomas Mraz [Wed, 15 Mar 2023 08:10:59 +0000 (09:10 +0100)] 
cms_ec.c: Fix broken backport of size_t fix in ecdh_cms_encrypt

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

2 years agodemo: Fix makefile target
Pauli [Tue, 14 Mar 2023 00:33:51 +0000 (11:33 +1100)] 
demo: Fix makefile target

The makefile target was incorrect and wouldn't build the rsa_encrypt demo.

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

(cherry picked from commit 67bfdfa17bc4ca8e2b819316299bb82748394c45)

2 years agoTest that there are no errors on the stack for rejected early data
Matt Caswell [Mon, 27 Feb 2023 18:38:03 +0000 (18:38 +0000)] 
Test that there are no errors on the stack for rejected early data

If we reject early data then it is normal for decryption operations to
fail. We should ensure there are no spurious errors on the stack in that
case. This adds a test for that scenario.

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

2 years agoRemove spurious error queue entries on early data
Matt Caswell [Mon, 27 Feb 2023 18:43:20 +0000 (18:43 +0000)] 
Remove spurious error queue entries on early data

Early data decryption is expected to fail sometimes. If it does we should
not leave spurious error entries on the queue.

Fixes #20377

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

2 years agoImprove the performance of d2i_AutoPrivateKey and friends
Matt Caswell [Wed, 1 Mar 2023 17:03:48 +0000 (17:03 +0000)] 
Improve the performance of d2i_AutoPrivateKey and friends

Probe first to see if we have a PKCS8 file to improve decoder performance.

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

(cherry picked from commit dba97d4c7142621fb279ef2074cd5c0a04eca7d3)

2 years agoDocument remaining obsolete SSL_OP_NETSCAPE_*_BUG
Tobias Nießen [Mon, 6 Mar 2023 22:51:17 +0000 (22:51 +0000)] 
Document remaining obsolete SSL_OP_NETSCAPE_*_BUG

SSL_OP_NETSCAPE_CA_DN_BUG became obsolete in 3c33c6f6b1086435 and
support for SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG was removed by
7a4dadc3a6a487db. The definitions are still listed under "OBSOLETE
OPTIONS retained for compatibility" in ssl.h.in, so this commit adds
them to the list of obsolete options in doc/man3.

Refs: https://github.com/nodejs/node/pull/46954

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

(cherry picked from commit fe52208c560fb4d16fc40cfe395032544b82271e)

2 years agoAdd missing assignment to EVP_get_digestbynid()
ndossche [Tue, 7 Mar 2023 12:27:15 +0000 (13:27 +0100)] 
Add missing assignment to EVP_get_digestbynid()

The assignment of the result of EVP_get_digestbynid() did not happen
which made the fallback not actually perform the fallback.

CLA: trivial

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

(cherry picked from commit c09c202e9bc66f0300ee598ca94f2b3fa5a5899d)

2 years agodoc/man3/X509_STORE_CTX_get_error.pod: make order consistent, add some missing entries
Dr. David von Oheimb [Mon, 27 Feb 2023 18:22:33 +0000 (19:22 +0100)] 
doc/man3/X509_STORE_CTX_get_error.pod: make order consistent, add some missing entries

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

(cherry picked from commit 1caa4835eb140682ba091bf328758fc6535e70bc)

2 years agoSegmentation fault in parent rng cleanup
afshinpir [Wed, 8 Mar 2023 03:42:00 +0000 (16:42 +1300)] 
Segmentation fault in parent rng cleanup

CLA: trivial
When `cleanup_entropy()` is called to cleanup parent by calling
provided `OSSL_FUNC_rand_clear_seed_fn` method, incorrect random
context is passed to the method. So accessing that context creates
a segmentation fault. Parent context should be passed rather than
DRBG's own context.

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

(cherry picked from commit 6d45fd47f4849c8dc55b8dd5fa1e1b8a158774a0)

2 years agoUpdated `rsa_has()` for correct validation
afshinpir [Wed, 8 Mar 2023 07:31:54 +0000 (20:31 +1300)] 
Updated `rsa_has()` for correct validation

CLA: trivial
In RSA, `(n,e)` and `(n,d)` identify public key and private key.
Modulus `n` is the common part. So I updated `rsa_has()` to validate
these pairs correctly. `OSSL_KEYMGMT_SELECT_KEYPAIR` is common part
for both public and private key, so I changed it to check `n` of
RSA and for `OSSL_KEYMGMT_SELECT_PUBLIC_KEY`, `e` is checked. Before
this change, if `selection` was `OSSL_KEYMGMT_SELECT_PRIVATE_KEY` and
only `e` and `d` was in the RSA structure, the function returns 1
while it was incorrect.

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

(cherry picked from commit a3207163ef3d30658a41a9c9e3750ca4c5b16677)

2 years agoFix size_t/int mismatch in cms_ec.c and rsa_sig.c
Tomas Mraz [Wed, 8 Mar 2023 10:17:31 +0000 (11:17 +0100)] 
Fix size_t/int mismatch in cms_ec.c and rsa_sig.c

Fixes #20435

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

(cherry picked from commit 559e078d94f1213318105b03f4e88b848fc28314)

2 years agoaes/asm/bsaes-armv7.pl: Replace adrl with add
Kornel DulÄ™ba [Wed, 8 Mar 2023 10:28:41 +0000 (11:28 +0100)] 
aes/asm/bsaes-armv7.pl: Replace adrl with add

"adrl" is a pseudo-instruction used to calculate an address relative
to PC. It's not recognized by clang resulting in a compilation error.
I've stumbled upon it when trying to integrate the bsaes-armv7 assmebly
logic into FreeBSD kernel, which uses clang as it's default compiler.
Note that this affect the build only if BSAES_ASM_EXTENDED_KEY is
defined, which is not the default option in OpenSSL.

The solution here is to replace it with an add instruction.
This mimics what has already been done in !BSAES_ASM_EXTENDED_KEY logic.
Because of that I've marked this as trivial CLA.

CLA: trivial
Signed-off-by: Kornel Dulęba <mindal@semihalf.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20458)

(cherry picked from commit 27093ba73372935fe4ef91d0a45ce6ea90a1ac8e)

2 years agoAdd missing copyright header
Pauli [Wed, 8 Mar 2023 22:59:25 +0000 (09:59 +1100)] 
Add missing copyright header

This file was only recently introduced and the missing header slipped through
the review process.

Fixes #20461

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

(cherry picked from commit 93b0a1ea614f9ce3931373fd3d1d1af04795e6d7)

2 years agodoc: document that prediction resistance comes with a hidden cost
Pauli [Tue, 7 Mar 2023 23:09:11 +0000 (10:09 +1100)] 
doc: document that prediction resistance comes with a hidden cost

In the default setup, using prediction resistance cascades to a reseeding
of all DRBGs.  The cost for this will be excessive for highly threaded
applications.

Fixes #20414

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

(cherry picked from commit d90bd3468a9a8d2af6b821be50c1034e21d782ca)

2 years agocheck-format.pl: fix statistics on whitespace and nesting issues
Dr. David von Oheimb [Wed, 30 Nov 2022 20:11:48 +0000 (21:11 +0100)] 
check-format.pl: fix statistics on whitespace and nesting issues

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

(cherry picked from commit 2bdc60cbe9e6baa37d6fa68e80c024d23c050528)

2 years agocheck-format.pl: fix detection of '#ifdef __cplusplus'
Dr. David von Oheimb [Wed, 30 Nov 2022 20:12:20 +0000 (21:12 +0100)] 
check-format.pl: fix detection of '#ifdef __cplusplus'

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

(cherry picked from commit d327f7c4ad2fe19bb6e69818dc540f8ae7c37a39)

2 years agocheck-format.pl: fix detection of function body start
Dr. David von Oheimb [Wed, 30 Nov 2022 20:07:40 +0000 (21:07 +0100)] 
check-format.pl: fix detection of function body start

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

(cherry picked from commit a49ade26324423fdf6eed4083a71f44e8a17754f)

2 years agocheck-format.pl: improve whitespace reporting on <op>=
Dr. David von Oheimb [Tue, 26 Jul 2022 06:37:41 +0000 (08:37 +0200)] 
check-format.pl: improve whitespace reporting on <op>=

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

(cherry picked from commit 295ecb1600c52cbed3aad859b0bfd16966abe0e6)

2 years agocheck-format.pl: further fixes for whitespace reporting within 'for (...)'
Dr. David von Oheimb [Mon, 25 Jul 2022 16:14:33 +0000 (18:14 +0200)] 
check-format.pl: further fixes for whitespace reporting within 'for (...)'

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

(cherry picked from commit f968648ef7e39230ee5def1baf212e7fd98fe67f)

2 years agocheck-format.pl: report #if and #elif with constant condition; improve checks on...
Dr. David von Oheimb [Fri, 15 Jul 2022 06:35:16 +0000 (08:35 +0200)] 
check-format.pl: report #if and #elif with constant condition; improve checks on '/*'

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

(cherry picked from commit bdb41f92420981928578167cc6db3bcbac206cea)

2 years agocheck-format.pl: extend checking into macro bodies; small further improvements
Dr. David von Oheimb [Wed, 13 Jul 2022 23:34:11 +0000 (01:34 +0200)] 
check-format.pl: extend checking into macro bodies; small further improvements

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

(cherry picked from commit 1fb20f1d210d57520f4c91c707fc9a1eded0daa4)

2 years agocheck-format.pl: improve preprocessor directive handling; re-order state variables
Dr. David von Oheimb [Wed, 13 Jul 2022 17:37:30 +0000 (19:37 +0200)] 
check-format.pl: improve preprocessor directive handling; re-order state variables

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

(cherry picked from commit 87c8a476645a476a1fe5a99bf222792e93bb92f3)

2 years agoPrepare for 3.1.1 20509/head
Matt Caswell [Tue, 14 Mar 2023 12:59:14 +0000 (12:59 +0000)] 
Prepare for 3.1.1

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

2 years agoPrepare for release of 3.1.0 openssl-3.1.0
Matt Caswell [Tue, 14 Mar 2023 12:59:07 +0000 (12:59 +0000)] 
Prepare for release of 3.1.0

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

2 years agomake update
Matt Caswell [Tue, 14 Mar 2023 12:59:06 +0000 (12:59 +0000)] 
make update

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

2 years agoUpdate copyright year
Matt Caswell [Tue, 14 Mar 2023 12:49:46 +0000 (12:49 +0000)] 
Update copyright year

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

2 years agoFix aarch64 signed bit shift issue found by UBSAN
Otto Hollmann [Fri, 10 Mar 2023 15:03:03 +0000 (16:03 +0100)] 
Fix aarch64 signed bit shift issue found by UBSAN

Also fix conditional branch out of range when using sanitisers.

Fixes #18813

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
Change-Id: Ic543885091ed3ef2ddcbe21de0a4ac0bca1e2494

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

2 years agofips: Use salt >= 16 bytes in PBKDF2 selftest
Clemens Lang [Fri, 3 Mar 2023 11:22:03 +0000 (12:22 +0100)] 
fips: Use salt >= 16 bytes in PBKDF2 selftest

NIST SP 800-132 [1] section 5.1 says "[t]he length of the
randomly-generated portion of the salt shall be at least
128 bits", which implies that the salt for PBKDF2 must be at least 16
bytes long (see also Appendix A.2.1).

The FIPS 140-3 IG [2] section 10.3.A requires that "the lengths and the
properties of the Password and Salt parameters, as well as the desired
length of the Master Key used in a CAST shall be among those supported
by the module in the approved mode."

As a consequence, the salt length in the self test must be at least 16
bytes long for FIPS 140-3 compliance. Switch the self test to use the
only test vector from RFC 6070 that uses salt that is long enough to
fulfil this requirement. Since RFC 6070 does not provide expected
results for PBKDF2 with HMAC-SHA256, use the output from [3], which was
generated with python cryptography, which was tested against the RFC
6070 vectors with HMAC-SHA1.

 [1]: https://doi.org/10.6028/NIST.SP.800-132
 [2]: https://csrc.nist.gov/CSRC/media/Projects/cryptographic-module-validation-program/documents/fips%20140-3/FIPS%20140-3%20IG.pdf
 [3]: https://github.com/brycx/Test-Vector-Generation/blob/master/PBKDF2/pbkdf2-hmac-sha2-test-vectors.md

Signed-off-by: Clemens Lang <cllang@redhat.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20429)

(cherry picked from commit 451cb23c41c90d5a02902b3a77551aa9ee1c6956)

2 years agoAdd option to FIPS module to enforce EMS check during KDF TLS1_PRF.
slontis [Wed, 8 Feb 2023 07:22:43 +0000 (17:22 +1000)] 
Add option to FIPS module to enforce EMS check during KDF TLS1_PRF.

Fixes #19989

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

(cherry picked from commit 50ea5cdcb735916591e35a04c1f5a659bf253ddc)

2 years agoDOCS: provider-keymgmt(7) - params for EVP_PKEY_get_default_digest_{name,nid}()
Richard Levitte [Fri, 3 Mar 2023 13:18:43 +0000 (14:18 +0100)] 
DOCS: provider-keymgmt(7) - params for EVP_PKEY_get_default_digest_{name,nid}()

This describes them in detail in provider-keymgmt(7).

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

(cherry picked from commit ac57336cd258e0432ffa485615d11c7c7ecfe81a)

2 years agoImprove the performance of EVP_PKCS82PKEY_ex
Matt Caswell [Wed, 1 Mar 2023 11:14:25 +0000 (11:14 +0000)] 
Improve the performance of EVP_PKCS82PKEY_ex

We can easily find out the keytype which should significantly improve
the performance of this function because we don't have to try every loaded
decoder.

Partial fix for #20399

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

(cherry picked from commit 52ce351a674bf459c836ffd01afb09917889f047)

2 years agoFix cast.
Pauli [Thu, 2 Mar 2023 23:14:39 +0000 (10:14 +1100)] 
Fix cast.

Fixes #20424

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

(cherry picked from commit b1cd268c034268f4d37c665ee4b5148f9d8700bb)

2 years agoFix typo in base provider example code
HansHoogerwerf [Wed, 1 Mar 2023 09:02:37 +0000 (10:02 +0100)] 
Fix typo in base provider example code

CLA: trivial

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

(cherry picked from commit 08a11ba20461ce14b0a6b9c9e374fbea91fbd8cf)

2 years agoCoverity 1521557: Error handling issues
Pauli [Wed, 1 Mar 2023 01:22:49 +0000 (12:22 +1100)] 
Coverity 1521557: Error handling issues

Check the return from DSA_set0_key and generate an error on failure.
Technically a false positive since the function always returns success.

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

(cherry picked from commit dd573a2fc1e8806c67420a5d6df0de175745aaf8)

2 years agoAdd sections that were missing
Pauli [Tue, 28 Feb 2023 08:51:36 +0000 (19:51 +1100)] 
Add sections that were missing

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

2 years agoFix FFC mdprop setting bugs.
slontis [Mon, 27 Feb 2023 06:35:41 +0000 (16:35 +1000)] 
Fix FFC mdprop setting bugs.

Coverage testing showed that ossl_ffc_params_fromdata() was not setting
OSSL_PKEY_PARAM_FFC_DIGEST_PROPS.
Adding a negative test also showed that ossl_ffc_params_copy() did not
do a shallow copy of the digest or digest property.

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

(cherry picked from commit 3307338e26862070eaacad6ec7537a63a63b8a90)

2 years agoFix potential infinite loops in ECDSA signing.
slontis [Mon, 27 Feb 2023 03:53:25 +0000 (13:53 +1000)] 
Fix potential infinite loops in ECDSA signing.

Similiar checks to the DSA code have been added for ECDSA also.
This should not be a problem when using named groups.

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

(cherry picked from commit 5f820bd7535b871fdfdc0303c3af23ba4be901f0)

2 years agoFix infinite loops in DSA sign code.
slontis [Mon, 27 Feb 2023 03:48:24 +0000 (13:48 +1000)] 
Fix infinite loops in DSA sign code.

Fixes #20268

Values such as q=1 or priv=0 caused infinite loops when calling
DSA_sign() without these changes.

There are other cases where bad domain parameters may have caused
infinite loops where the retry counter has been added. The simpler case
of priv=0 also hits this case. q=1 caused an infinite loop in the setup.

The max retry value has been set to an arbitrary value of 8 (it is
unlikely to ever do a single retry for valid values).

The minimum q bits was set to an arbitrary value of 128 (160 is still
used for legacy reasons when using 512 bit keys).

Thanks @guidovranken for detecting this, and @davidben for his
insightful analysis.

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

(cherry picked from commit 3a4e09ab42654b3d223f0f8dd1a9c58b2902ddcc)

2 years agoec: Use .machine "any" explicitly in ecp_nistp521-ppc64
Robin Lee [Sun, 26 Feb 2023 05:56:14 +0000 (13:56 +0800)] 
ec: Use .machine "any" explicitly in ecp_nistp521-ppc64

Since GCC commit e154242724b084380e3221df7c08fcdbd8460674 the flag "-many"
is sometimes not passed to the assembler. Use .machine "any" just like
ecp_nistz256-ppc64 to prevent compile errors when built with some
configurations of GCC.

CLA: trivial

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

(cherry picked from commit a6d7093a1dc890493d3577c738e729c0265d7b40)

2 years agoUpdate FIPS provider documentation to note that fips=yes is mandatory
Pauli [Sun, 26 Feb 2023 23:14:43 +0000 (10:14 +1100)] 
Update FIPS provider documentation to note that fips=yes is mandatory

This was in the notes section but an earlier comment about it not being
mandatory was missed.

Fixes #20376

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

(cherry picked from commit 0a81220a01e888c3ee4ab18dfdcab6472d9e214c)

2 years agoDisable atomic refcounts with no-threads
J.W. Jagersma [Tue, 22 Nov 2022 18:20:53 +0000 (19:20 +0100)] 
Disable atomic refcounts with no-threads

This is needed for building with '-march=i386 no-threads', on platforms
where libatomic is not available (djgpp, specifically).  The
implementation now falls back to 'CRYPTO_atomic_add()', which performs
plain lock-free addition in a 'no-threads' build.

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/19751)
(cherry picked from commit b484c6268ce38ccbc1bf5ee95bbd36f76fba994f)

2 years agoFix incomplete error check on RSA_public_decrypt()
ndossche [Thu, 9 Feb 2023 08:49:47 +0000 (09:49 +0100)] 
Fix incomplete error check on RSA_public_decrypt()

According to the documentation and my analysis tool RSA_public_decrypt()
can return -1 on error, but this is not checked. Fix it by changing the
error condition.

CLA: trivial

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

(cherry picked from commit 8195e59986031f6f33e2569551d771904433fa04)

2 years agoFix incomplete error check on ASN1_item_i2d()
ndossche [Thu, 9 Feb 2023 10:39:58 +0000 (11:39 +0100)] 
Fix incomplete error check on ASN1_item_i2d()

According to the documentation and my analysis tool
ASN1_item_i2d() can return a negative value on error,
but this is not checked. Fix it by changing the error check condition.

CLA: trivial

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

(cherry picked from commit 5df5032ab02d7a17e07435de777d730bae190253)

2 years agoDocument the list of RAND algorithms in the default and fips providers.
slontis [Wed, 22 Feb 2023 23:09:57 +0000 (09:09 +1000)] 
Document the list of RAND algorithms in the default and fips providers.

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

(cherry picked from commit 7066c57dce88994778daa10ba2c81490fc5cf0c7)

2 years agoAdd provider pre-fetching documentation
slontis [Wed, 22 Feb 2023 00:11:33 +0000 (10:11 +1000)] 
Add provider pre-fetching documentation

Clearly document that implicit fetching is slower when using providers,
and explain prefetching. Added to crypto.pod and migration_guide.pod
links to it.

Add a link to EVP_default_properties_enable_fips() in crypto.pod.

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

(cherry picked from commit e798248c8461893ba29d97410b7c0dcecbf23d82)

2 years agoAdd documentation for "NULL" cipher and digest algorithms.
slontis [Wed, 22 Feb 2023 02:15:47 +0000 (12:15 +1000)] 
Add documentation for "NULL" cipher and digest algorithms.

Fixes #20340

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

(cherry picked from commit f7d76c3d7d09d95a9ceb5b69c8f951f53237ef78)

2 years agoCMS_decrypt_set1_*(): fix NULL deref on unsuitable content type
Dr. David von Oheimb [Mon, 2 Jan 2023 12:05:08 +0000 (13:05 +0100)] 
CMS_decrypt_set1_*(): fix NULL deref on unsuitable content type

Fixes #19975
for CMS_decrypt_set1_pkey_and_peer() in the obvious way,
and a related potential crash in CMS_decrypt_set1_password().

The point is that the input might have an unexpected content type,
so a guard is needed at both places after `ec` is obtained.

Note that in CMS_decrypt_set1_pkey_and_peer() there was
no such ec != NULL guard for
```
    if (ris != NULL)
        debug = ec->debug;
```
maybe because it is implied here by ris != NULL.

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

(cherry picked from commit ceb767bea442a3f9d8a40a26df1f760b7142e616)

2 years agoCMS_decrypt_set1_*(): remove misleading error queue entry when recipient mismatch...
Dr. David von Oheimb [Tue, 18 Oct 2022 16:12:38 +0000 (18:12 +0200)] 
CMS_decrypt_set1_*(): remove misleading error queue entry when recipient mismatch was not the issue

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

(cherry picked from commit 27d87391e63dcbbc576fe3b5f1e1c9615a1ac5ff)

2 years agoCMS_decrypt_set1_password(): prevent mem leak on any previously set decryption key
Dr. David von Oheimb [Fri, 14 Oct 2022 10:56:54 +0000 (12:56 +0200)] 
CMS_decrypt_set1_password(): prevent mem leak on any previously set decryption key

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

(cherry picked from commit c5febe9923cd5465fae5209a4f8e8be4aab43cac)

2 years agoCMS_decrypt*(): fix misconceptions and mem leak
Dr. David von Oheimb [Thu, 15 Sep 2022 09:51:30 +0000 (11:51 +0200)] 
CMS_decrypt*(): fix misconceptions and mem leak

Also document CMS_decrypt_set1_password() and fix CMS_EnvelopedData_create.pod.

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

(cherry picked from commit 26521faae48c14597877e330911171105ab6c30f)

2 years agoCMS_add0_cert.pod: remove wrong text on duplicate CRLs; small further improvements
Dr. David von Oheimb [Mon, 13 Feb 2023 12:14:54 +0000 (13:14 +0100)] 
CMS_add0_cert.pod: remove wrong text on duplicate CRLs; small further improvements

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/20275)

(cherry picked from commit 9fae775acf56d64854d76f0399a80919f9b115e7)

2 years agoCMS_add1_crl(): prevent double free on failure of CMS_add0_crl()
Dr. David von Oheimb [Fri, 10 Feb 2023 08:53:43 +0000 (09:53 +0100)] 
CMS_add1_crl(): prevent double free on failure of CMS_add0_crl()

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/20275)

(cherry picked from commit 416e155a21ba188fcd88f2e32318886b19f8b311)

2 years agoDo not have more data in a pipeline than the split_send_fragment
Matt Caswell [Fri, 3 Feb 2023 17:03:09 +0000 (17:03 +0000)] 
Do not have more data in a pipeline than the split_send_fragment

We shouldn't be putting more data into a pipeline than the value of
split_send_fragment.

This is a backport of a fix which was included in a much larger commit in
master (c6186792b98) related to moving the pipelining code into the new
record layer that exists there.

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

2 years agoUpdate the pipelining docs
Matt Caswell [Tue, 25 Oct 2022 14:55:38 +0000 (15:55 +0100)] 
Update the pipelining docs

Document the effect on the internal read buffer when using pipelining.

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

2 years agoFix read pipelining
Matt Caswell [Tue, 25 Oct 2022 14:47:36 +0000 (15:47 +0100)] 
Fix read pipelining

During read pipelining we must ensure that the buffer is sufficiently large
to read enough data to fill our pipelines. We also remove some code that
moved data to the start of the packet if we can. This was unnecessary
because of later code which would end up moving it anyway. The earlier move
was also incorrect in the case that |clearold| was 0. This would cause the
read pipelining code to fail with sufficiently large records.

Fixes #20197

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

2 years agoPipeline output/input buf arrays must live until the EVP_Cipher is called
Matt Caswell [Fri, 21 Oct 2022 13:08:29 +0000 (14:08 +0100)] 
Pipeline output/input buf arrays must live until the EVP_Cipher is called

The pipeline input/output buf arrays must remain accessible to the
EVP_CIPHER_CTX until EVP_Cipher is subsequently called. This fixes an
asan error discovered by the newly added pipeline test.

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

2 years agoAdd a test for TLS pipelining
Matt Caswell [Thu, 20 Oct 2022 15:36:37 +0000 (16:36 +0100)] 
Add a test for TLS pipelining

TLS pipelining provides the ability for libssl to read or write multiple
records in parallel. It requires special ciphers to do this, and there are
currently no built-in ciphers that provide this capability. However, the
dasync engine does have such a cipher, so we add a test for this capability
using that engine.

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

2 years agoSkip subdirectories in SSL_add_dir_cert_subjects_to_stack()
olszomal [Tue, 21 Feb 2023 13:20:24 +0000 (14:20 +0100)] 
Skip subdirectories in SSL_add_dir_cert_subjects_to_stack()

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

(cherry picked from commit 1dc35d44f355a7371a1ff8a457586938cc7b168a)

2 years agoFixes #20278: Fixed double free bug in crypto/http/http_client.c
Jeeban Sethi [Tue, 21 Feb 2023 16:01:43 +0000 (21:31 +0530)] 
Fixes #20278: Fixed double free bug in crypto/http/http_client.c

CLA: trivial

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

(cherry picked from commit 7fed5193d242938d9ac5a0c1cb32b22b33379a06)

2 years agoFix potential NULL pointer dereference in function evp_pkey_asn1_ctrl
zhailiangliang [Wed, 15 Feb 2023 02:43:01 +0000 (10:43 +0800)] 
Fix potential NULL pointer dereference in function evp_pkey_asn1_ctrl

CLA: trivial

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

(cherry picked from commit ab5a172f1b41b12133b95822d5bf004c322965cb)

2 years agoupdate documentation to note that EdDSA is not FIPS approved
Pauli [Mon, 20 Feb 2023 22:20:43 +0000 (09:20 +1100)] 
update documentation to note that EdDSA is not FIPS approved

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

(cherry picked from commit fdd4716dd61e3e8fce77c04987e9dc5df7be7d9d)

2 years agoupdate changes entry to note EdDSA is not FIPS approved
Pauli [Mon, 20 Feb 2023 22:20:22 +0000 (09:20 +1100)] 
update changes entry to note EdDSA is not FIPS approved

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

(cherry picked from commit 8c02b98fab688b0ccacbb2de5816a5d5fc7fb23b)

2 years agoRevert "Put EdDSA back as approved algorithms."
Pauli [Mon, 20 Feb 2023 22:11:44 +0000 (09:11 +1100)] 
Revert "Put EdDSA back as approved algorithms."

This reverts commit 09627a8ceb69e19d2855b36228f44a3660af177a.

NIST isn't allowing EdDSA at this stage after all, so flag it as not
FIPS approved in the FIPS provider.  Guidance for FIPS 140-3 is expected
later this month:

    The use of EdDSA still remains non-approved.

    Before the FIPS 186-5 and SP 800-186 algorithms / curves can be
    used in the approved mode, the CMVP will need to do (at least)
    the following:

    * Incorporate FIPS 186-5 and SP 800-186 into SP 800-140C/D;

    * Update IG 10.3.A to incorporate self-test requirements for the
      new algorithms/curves.

    * Write a new IG on this transition to clarify the issues raised in
      this thread and elsewhere and provide a clear transition schedule.

    The CMVP is working on all three of these items and hope to have
    drafts public by the end of March.

    Since security relevant changes are not permitted for new 140-2
    submissions, and under the assumption that this transition away
    from FIPS 186-4 algorithms will be 'soft' and not move modules to
    the historical list, we do not plan on writing 140-2 guidance for
    this transition.

It seems unlikely that all of these requirements will be completed before
we submit.

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

(cherry picked from commit 759ab5984eb981f2dd165979a7abb950ddad81ae)