]> git.ipfire.org Git - thirdparty/openssl.git/log
thirdparty/openssl.git
20 months agoDon't free aliased pointers in ctx cmp_ctx tests
Neil Horman [Wed, 22 Nov 2023 17:16:54 +0000 (12:16 -0500)] 
Don't free aliased pointers in ctx cmp_ctx tests

Coverity recorded issues 1551739 and 1551737, a potential double free in the
tests.  It occurs when the DUP operation fails in such a way val3_read is
returned as the same pointer as val2_read.  Ideally it should never
happen, but resetting val3_read to 0 should satisfy coverity that there
is no issue here

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

(cherry picked from commit c8ca810da9c47d8cb6988fd14e1cb4e20b0877e8)

20 months agoAdd locking to CRYPTO_secure_used
Neil Horman [Wed, 22 Nov 2023 19:20:39 +0000 (14:20 -0500)] 
Add locking to CRYPTO_secure_used

Coverity issue 1551719 noted CRYPTO_secure_used referenced a shared
variable without taking the appropriate read lock.  Add that.

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

(cherry picked from commit 7eae6ee0e503b0961d4f2e75baac981f2766b892)

20 months agoevp-cmac: do not seg-fault when getting mac-size before init
James Muir [Wed, 29 Nov 2023 03:43:52 +0000 (22:43 -0500)] 
evp-cmac: do not seg-fault when getting mac-size before init

Add null check to cmac_size().  This avoids a seg-fault encountered
with cmac when EVP_MAC_CTX_get_mac_size() is called before init.

Extend mac testing in evp_test.c to check that the sizes returned by
EVP_MAC_CTX_get_mac_size() before and after init make sense (this also
ensures that we no longer seg-fault).

Fixes #22842

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

(cherry picked from commit ff181969e28c1503b077b47a9ded3683524b3fd8)

20 months agoFix a possible memory leak in make_receipt_request
Bernd Edlinger [Wed, 15 Nov 2023 18:31:28 +0000 (19:31 +0100)] 
Fix a possible memory leak in make_receipt_request

When the CMS_ReceiptRequest cannot be created,
the rct_to and rct_from may be leaked.

Reviewed-by: Neil Horman <nhorman@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/22742)

(cherry picked from commit bed7a878107818c297301c6602013d364b266c67)

20 months agoFix a possible use after free in X509v3_asid_add_id_or_range
Bernd Edlinger [Wed, 15 Nov 2023 19:49:51 +0000 (20:49 +0100)] 
Fix a possible use after free in X509v3_asid_add_id_or_range

And clean up partially created choice objects, which have
still the default type = -1 from ASIdentifierChoice_new().

Fixes #22700

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

(cherry picked from commit 49e9436af3d85963fd6156b7d6f33e0734bf5ba9)

20 months agorsa-doc: fix typo
James Muir [Wed, 29 Nov 2023 17:37:44 +0000 (12:37 -0500)] 
rsa-doc: fix typo

"d_i in RFC8017" -> "d_i" in RFC8017

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

(cherry picked from commit c89b553bdc2587b483f38aa1ab2b142cc078343d)

20 months agodoc: Minor typo in SSL_CTX_set_tmp_dh_callback docs.
Sean Bright [Mon, 20 Nov 2023 20:08:19 +0000 (15:08 -0500)] 
doc: Minor typo in SSL_CTX_set_tmp_dh_callback docs.

well know -> well known

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

(cherry picked from commit db04cf25f3e0dda77a3b054ae12ae1874b1ae977)

20 months agoInitialize dstctx->mgf1_md to NULL in rsa_dupctx function
lan1120 [Wed, 22 Nov 2023 01:45:25 +0000 (09:45 +0800)] 
Initialize dstctx->mgf1_md to NULL in rsa_dupctx function

Signed-off-by: lan1120 <lanming@huawei.com>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22795)

(cherry picked from commit f95e3a09173b13dcfae668be6103e64c02222f08)

20 months agobn_nist: Fix strict-aliasing violations in little-endian optimizations
Xi Ruoyao [Sat, 25 Nov 2023 08:14:35 +0000 (16:14 +0800)] 
bn_nist: Fix strict-aliasing violations in little-endian optimizations

The little-endian optimization is doing some type-punning in a way
violating the C standard aliasing rule by loading or storing through a
lvalue with type "unsigned int" but the memory location has effective
type "unsigned long" or "unsigned long long" (BN_ULONG).  Convert these
accesses to use memcpy instead, as memcpy is defined as-is "accessing
through the lvalues with type char" and char is aliasing with all types.

GCC does a good job to optimize away the temporary copies introduced
with the change.  Ideally copying to a temporary unsigned int array,
doing the calculation, and then copying back to `r_d` will make the code
look better, but unfortunately GCC would fail to optimize away this
temporary array then.

I've not touched the LE optimization in BN_nist_mod_224 because it's
guarded by BN_BITS2!=64, then BN_BITS2 must be 32 and BN_ULONG must be
unsigned int, thus there is no aliasing issue in BN_nist_mod_224.

Fixes #12247.

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

(cherry picked from commit 990d9ff508070757912c000f0c4132dbb5a0bb0a)

20 months agoFix EVP_RAND-SEED-SRC documentation example
Jamie Cui [Wed, 29 Nov 2023 01:28:58 +0000 (01:28 +0000)] 
Fix EVP_RAND-SEED-SRC documentation example

Fixes #22810

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

(cherry picked from commit 58d926213f00ba7046d0868de8b37929aa067a1f)

20 months agoAdd self-hosted runners
Dmitry Misharov [Thu, 23 Nov 2023 13:22:35 +0000 (14:22 +0100)] 
Add self-hosted runners

Added self-hosted runners for freebsd-x86_64 and ubuntu-aarch64.

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

(cherry picked from commit 6b7a11d8aa7abe50e6ebdd09a238e0a0df8cd228)

20 months agoAdd last missing TLSA usage/selector/mtype test case
Viktor Dukhovni [Mon, 27 Nov 2023 16:23:54 +0000 (11:23 -0500)] 
Add last missing TLSA usage/selector/mtype test case

There were no PKIX-TA(0) SPKI(1) Full(0) (i.e. "0 1 0") test cases in
"danetest.in".

There is now at least a success case, which will exercise freeing the public
key after it is sanity checked, since with PKIX-TA(0) there's nothing we can do
with just the raw public key, a full chain to a local trust anchor is in any
case required.

The failure (to match) code path is already well oiled, but failure to decode
while adding malfored TLSA records could still use some additional tests...

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22821)

(cherry picked from commit c8fe4b5948486e792016208f7c8ccea9c380f354)

20 months agoFix freshly introduced double-free.
Viktor Dukhovni [Sat, 25 Nov 2023 18:26:20 +0000 (13:26 -0500)] 
Fix freshly introduced double-free.

We don't need the decoded X.509 Full(0) certificate for the EE usages 1 and 3,
because the leaf certificate is always part of the presented chain, so the
certificate is only validated as well-formed, and then discarded, but the
TLSA record is of course still used after the validation step.

Added DANE test cases for: 3 0 0, 3 1 0, 1 0 0, and 1 1 0

Reported by Claus Assmann.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22821)

(cherry picked from commit f636e7e6bd8e06c6d84e42729b4131b4f5df488f)

20 months agoFix a possible memory leak in ct_move_scts
Bernd Edlinger [Fri, 17 Nov 2023 13:47:36 +0000 (14:47 +0100)] 
Fix a possible memory leak in ct_move_scts

Instead of trying to move the doomed sct back
to the src stack, which may fail as well, simply
free the sct object, as the src list will be
deleted anyway.

Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22762)

(cherry picked from commit a435d786046fabc85acdb89cbf47f154a09796e1)

20 months agox86_64-xlate.pl: Fix build with icx and nvc compilers
Tomas Mraz [Mon, 13 Nov 2023 11:17:43 +0000 (12:17 +0100)] 
x86_64-xlate.pl: Fix build with icx and nvc compilers

Fixes #22594

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

(cherry picked from commit 1da7c09f7987a227701b6324e56003a89e9febf2)

20 months agoMove freeing of an old enc_write_ctx/write_hash to dtls1_clear_sent_buffer
Matt Caswell [Thu, 9 Nov 2023 14:45:33 +0000 (14:45 +0000)] 
Move freeing of an old enc_write_ctx/write_hash to dtls1_clear_sent_buffer

When we are clearing the sent messages queue we should ensure we free any
old enc_write_ctx/write_hash that are no longer in use. Previously this
logic was in dtls1_hm_fragment_free() - but this can end up freeing the
current enc_write_ctx/write_hash under certain error conditions.

Fixes #22664

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

20 months agozero data in hm_fragment on alloc
Neil Horman [Thu, 9 Nov 2023 13:13:58 +0000 (08:13 -0500)] 
zero data in hm_fragment on alloc

if we allocate a new hm_frament in dtls1_buffer_message with
dtls1_hm_fragment_new, the returned fragment contains uninitalized data in the
msg_header field.  If an error then occurs, and we free the fragment,
dtls_hm_fragment_free interrogates the msg_header field (which is garbage), and
potentially references undefined values, or worse, accidentally references
available memory that is not owned, leading to various corruptions.

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

20 months agoAdd negative test for key length change
Tomas Mraz [Wed, 1 Nov 2023 17:39:32 +0000 (18:39 +0100)] 
Add negative test for key length change

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 1aa08644ecd4005c0f55276b2e8dabd8a2a758f0)

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/22613)

20 months agoAdd negative test for iv length change
Tomas Mraz [Wed, 1 Nov 2023 17:14:09 +0000 (18:14 +0100)] 
Add negative test for iv length change

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 82750a0826cd4728f40df9ef31b3294d83aaafe0)

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/22613)

20 months agoupdate/final: Return error if key is not set
Tomas Mraz [Wed, 1 Nov 2023 15:54:58 +0000 (16:54 +0100)] 
update/final: Return error if key is not set

Also make sure the key is not set if the key
length is changed on the context after the key was
set previously.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 3a95d1e41abf2e8eb0f6f07003bac844950bfaae)

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/22613)

20 months agoWhen changing IV length invalidate previously set IV
Tomas Mraz [Wed, 1 Nov 2023 13:00:22 +0000 (14:00 +0100)] 
When changing IV length invalidate previously set IV

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit eddbb78f4e5196eee33b2fd3d6adeabb69d52eb7)

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/22613)

20 months agoCross Compiles CI: Run evp tests on pull requests
Tomas Mraz [Thu, 16 Nov 2023 12:02:20 +0000 (13:02 +0100)] 
Cross Compiles CI: Run evp tests on pull requests

Reviewed-by: Matt Caswell <matt@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/22750)

(cherry picked from commit 0414f89d5c5187260cca63c2066580ba90c44426)

20 months agocontributing-doc: give example commit message with "CLA: trivial"
James Muir [Mon, 20 Nov 2023 18:14:12 +0000 (13:14 -0500)] 
contributing-doc: give example commit message with "CLA: trivial"

The text "CLA: trivial" should go at the bottom of the commit message.
Also, update the force-push command to include the repository and
branch, which can avoid unexpected force-push results.

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

(cherry picked from commit cad48c5b0f7180c5fab8db70feb07e0846d80d67)

20 months agoAdapt C compiler detection for VSI C on x86_64
Richard Levitte [Tue, 21 Nov 2023 13:36:37 +0000 (14:36 +0100)] 
Adapt C compiler detection for VSI C on x86_64

VSI C on OpenVMS for x86_64 has a bit more information than on other
hardware.  This is no doubt because it's based on LLVM which leaves an
opening for cross compilation.

VSI C on Itanium:

    $ CC/VERSION
    VSI C V7.4-001 on OpenVMS IA64 V8.4-2L3

VSI C on x86_64:

    $ CC/VERSION
    VSI C x86-64 X7.4-843 (GEM 50XB9) on OpenVMS x86_64 V9.2-1

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

(cherry picked from commit df5e72d220d9c8b9316b1ce8e8c8bdf23c7201f0)

20 months agoFix a possible memory leak in SM2 provider
Huiyue Xu [Wed, 22 Nov 2023 01:55:27 +0000 (09:55 +0800)] 
Fix a possible memory leak in SM2 provider

ctx->propq that strdup from input parameter propq in sm2sig_newctx,
is not released. It should be released in sm2sig_freectx and copied
to dstctx in sm2sig_dupctx. And dstctx->id and dstctx->propq should
be set NULL to avoid releasing id/propq of srcctx when err occurs.

Signed-off-by: Huiyue Xu <xuhuiyue@huawei.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22796)

(cherry picked from commit e7d34d7ae32f16abbd79a49072cff580bee32269)

20 months agodoc: fix description of mac "block-size" parameter
James Muir [Fri, 17 Nov 2023 22:58:24 +0000 (17:58 -0500)] 
doc: fix description of mac "block-size" parameter

The macro for "block-size" is OSSL_MAC_PARAM_BLOCK_SIZE, and this
parameter is not settable.  Refer to the "customization string" rather
than the "custom value" (in the Blake2 spec, this is called the
personalization string).

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

(cherry picked from commit 1750689767cc922bdbe73358f7256475f0838c67)

20 months agodoc: better description of KECCAK-KMAC XOF
James Muir [Mon, 13 Nov 2023 19:28:23 +0000 (14:28 -0500)] 
doc: better description of KECCAK-KMAC XOF

KECCAK-KMAC-128 and KECCAK-KMAC-256 are extendable output functions
that have been defined because they are convenient for implementing
KMAC.  Give definitions for them so that users aren't left to figure
that out themselves.  KECCAK-KMAC-128 is very similar to SHAKE-128,
and KECCAK-KMAC-256 is very similar to SHAKE-256.

Related to #22619.

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

(cherry picked from commit f1bea887ef17802a2d83e9289e812c00fd0f0523)

20 months agoUpdate OpenSSL logos
James Muir [Sun, 5 Nov 2023 03:06:06 +0000 (23:06 -0400)] 
Update OpenSSL logos

Add two new files

  doc/images/openssl-square.svg
  doc/images/openssl-square-nontransparent.png

and update the existing file

  doc/images/openssl.svg

The "square" versions of the logo write "Open" and "SSL" on separate
lines, so that less horizontal space is used.

The png file (nontransparent, white background) can be used to update
the profile picture for the OpenSSL organization on GitHub.

For the existing logo, openssl.svg, the subtitle "Cryptography and
SSL/TLS Toolkit" has been dropped and the text-elements have been
converted to paths (so they are no longer dependent on what fonts the
renderer provides).

The svg files were provided by Anton A.

Part of https://github.com/openssl/project/issues/262

Reviewed-by: Anton Arapov <anton@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22626)

(cherry picked from commit 339e5cb0be8e57372548401a998d2e5145cfc7eb)

20 months agoFix possible memleak in PKCS7_add0_attrib_signing_time
Bernd Edlinger [Tue, 14 Nov 2023 01:42:42 +0000 (02:42 +0100)] 
Fix possible memleak in PKCS7_add0_attrib_signing_time

When PKCS7_add_signed_attribute fails, the ASN1_TIME
object may be leaked when it was not passed in as
input parameter.

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

(cherry picked from commit 7d52539f00144cb410c4e9d8da0b9574c0badb19)

20 months agoFix a possible use-after-free in custom_exts_free
Bernd Edlinger [Mon, 20 Nov 2023 09:05:49 +0000 (10:05 +0100)] 
Fix a possible use-after-free in custom_exts_free

This may happen when ssl_cert_dup calls custom_exts_copy, where
a possible memory allocation error causes custom_exts_free
to be called twice: once in the error handling of custom_exts_copy
and a second time in the error handling of ssl_cert_dup.

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

(cherry picked from commit bc0773bbbd4d3ace6957385f1f22a5cda25dc94f)

20 months agoFix a possible memleak in CMS_sign_receipt
Bernd Edlinger [Fri, 17 Nov 2023 06:12:42 +0000 (07:12 +0100)] 
Fix a possible memleak in CMS_sign_receipt

When an error happens after cms_encode_Receipt
the ASN1_OCTET_STRING object "os" may be leaked.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22758)

(cherry picked from commit 3e3aadd51cae1fbfb512cf4a0999d16c6a2888bd)

20 months agoFix a possible memleak in PKCS7_add_attrib_smimecap
Bernd Edlinger [Wed, 15 Nov 2023 19:32:59 +0000 (20:32 +0100)] 
Fix a possible memleak in PKCS7_add_attrib_smimecap

When PKCS7_add_signed_attribute fails, the ASN1_STRING
object may be leaked.

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

(cherry picked from commit ed3d2771278cfa1c355b40c681f5acc8404156c6)

20 months agoFix a possible memory leak in dane_tlsa_add
Bernd Edlinger [Wed, 15 Nov 2023 18:46:17 +0000 (19:46 +0100)] 
Fix a possible memory leak in dane_tlsa_add

Several error cases leak either the X509 object
or the pkey or the danetls_record object.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22743)

(cherry picked from commit e4a94bcc77f3fda0f185e62a73a66d9b9b9388f5)

20 months agoFix typo in variable name
Anders Jansson [Sat, 18 Nov 2023 22:40:33 +0000 (23:40 +0100)] 
Fix typo in variable name

Fix spelling $cppfags2 => $cppflags2 in file Configurations/windows-makefile.tmpl

CLA: trivial

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22771)

(cherry picked from commit 6d552a532754f6ee66d6cc604655deaeb5425b16)

20 months agocms demos: print signingTime attributes
James Muir [Fri, 3 Nov 2023 17:15:04 +0000 (13:15 -0400)] 
cms demos: print signingTime attributes

Add a makefile for the cms demos, and add a routine to cms_ver.c to
print any signingTime attributes from the CMS_ContentInfo object.
This provides an example that could be extended if an application
wants to examine the purported signing times.

Part of #8026

Testing:

  $ cd demos/cms
  $ make test

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(cherry picked from commit 9257a89b6f25dfa5aeee7114baec8ea992fcf5e5)

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

20 months agoFixup demo exit status magic numbers
slontis [Mon, 20 Mar 2023 04:48:33 +0000 (14:48 +1000)] 
Fixup demo exit status magic numbers

The demo code is quite often block copied for new demos,
so this PR changes demos to use EXIT_SUCCESS & EXIT_FAILURE
instead of using 0 and 1.
Internal functions use the normal notation of 0 = error, 1 = success,
but the value returned by main() must use EXIT_SUCCESS and EXIT_FAILURE.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(cherry picked from commit 09ff84bd2752cac649f57cfbf95b49dbce1c69ee)

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

20 months agoBump actions/github-script from 6 to 7
dependabot[bot] [Wed, 15 Nov 2023 10:14:21 +0000 (10:14 +0000)] 
Bump actions/github-script from 6 to 7

Bumps [actions/github-script](https://github.com/actions/github-script) from 6 to 7.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](https://github.com/actions/github-script/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/github-script
  dependency-type: direct:production
  update-type: version-update:semver-major
...

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

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

(cherry picked from commit 5f6b08e218974d4fbbd77ffedc2d94a08a194cc2)

20 months agoConfigure: do not check for an absolute prefix in cross-builds
Viktor Szakats [Fri, 27 Aug 2021 12:22:15 +0000 (12:22 +0000)] 
Configure: do not check for an absolute prefix in cross-builds

The check is always made according to the host platform's rules, which may
not be true for true when the target platform is different, e.g. when
cross-building for Windows on a Linux machine. So skip this check when
used together with the `--cross-compile-prefix=` option.

Fixes https://github.com/openssl/openssl/issues/9520

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

(cherry picked from commit 4ea752997df83c2a694fdb157aab07908303fc90)

20 months agoapps/list.c: Check the result of inserting a provider into provider's stack
Alexey Fofanov [Wed, 18 Oct 2023 11:23:22 +0000 (14:23 +0300)] 
apps/list.c: Check the result of inserting a provider into provider's stack

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

(cherry picked from commit 15b83e04a5e125ab873ace1e474790a4a5b44647)

20 months agoFix a bad backport
Matt Caswell [Thu, 9 Nov 2023 16:59:40 +0000 (16:59 +0000)] 
Fix a bad backport

This is causing compilation failure

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

20 months agoFix a possible memory leak of ssl->s3.tmp.psk
Bernd Edlinger [Mon, 6 Nov 2023 09:44:27 +0000 (10:44 +0100)] 
Fix a possible memory leak of ssl->s3.tmp.psk

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

(cherry picked from commit a2b1ab6100d5f0fb50b61d241471eea087415632)

21 months agoAdd CHANGES.md and NEWS.md entry for CVE-2023-5678
Tomas Mraz [Tue, 7 Nov 2023 14:22:00 +0000 (15:22 +0100)] 
Add CHANGES.md and NEWS.md entry for CVE-2023-5678

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

(cherry picked from commit 4ee71b4c302a06c24b46a5def1cff2096bd57f0b)

21 months agoapps/rehash.c: avoid printf format warning [-Wformat]
Matthias St. Pierre [Wed, 25 Oct 2023 09:05:58 +0000 (11:05 +0200)] 
apps/rehash.c: avoid printf format warning [-Wformat]

The `aarch64-linux-android33-clang` cross-compiler (v14.0.6)
complains twice about an unsupported '%n' format specifier,
preventing a successful `--strict-warnings` build:

    error: '%n' specifier not supported on this platform [-Werror,-Wformat]
                BIO_snprintf(buf, buflen, "%s%s%n%08x.%s%d",

This is a false positive, because BIO_snprintf() implements its
own format parsing (which is implemented in the _dopr() function).

This commit fixes the problem by rewriting the code to dispense with
the dubious '%n' format specifier. As a side-effect, the code becomes
a little bit more comprehensible and self-explaining.

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

(cherry picked from commit ec0d22fe1571508c08b714715cfdb6ac60c53f78)

21 months agoFix a possible memory leak in custom_ext_add
Bernd Edlinger [Mon, 6 Nov 2023 10:03:05 +0000 (11:03 +0100)] 
Fix a possible memory leak in custom_ext_add

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

21 months agoUse proper KDF SS parameter name
Dmitry Belyavskiy [Mon, 6 Nov 2023 09:53:46 +0000 (10:53 +0100)] 
Use proper KDF SS parameter name

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

(cherry picked from commit 1c6a37975495dd633847ff0c07747fae272d5e4d)

21 months agoFix conflicts between DH check flags and FFC check flags
Richard Levitte [Fri, 20 Oct 2023 07:24:01 +0000 (09:24 +0200)] 
Fix conflicts between DH check flags and FFC check flags

There are comments in include/openssl/dh.h and include/internal/ffc.h
that they must be aligned with each other, and yet, clashes have been
introduced.

The simplest fix is to move the offending FFC flags out of the way, as they
are indeed internal and shouldn't affect any public interface, apart from
those that are aligned with the DH flags, which are public.

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

21 months agoMake DH_check_pub_key() and DH_generate_key() safer yet
Richard Levitte [Fri, 20 Oct 2023 07:18:19 +0000 (09:18 +0200)] 
Make DH_check_pub_key() and DH_generate_key() safer yet

We already check for an excessively large P in DH_generate_key(), but not in
DH_check_pub_key(), and none of them check for an excessively large Q.

This change adds all the missing excessive size checks of P and Q.

It's to be noted that behaviours surrounding excessively sized P and Q
differ.  DH_check() raises an error on the excessively sized P, but only
sets a flag for the excessively sized Q.  This behaviour is mimicked in
DH_check_pub_key().

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

21 months agoFix documentation regarding KMAC sizes
Michael Hinz [Fri, 3 Nov 2023 13:17:39 +0000 (14:17 +0100)] 
Fix documentation regarding KMAC sizes

As per recommendation by jfinkhaeuser, this documents the defaults for
KMAC-128 as 32 and for KMAC-256 as 64. The code already accomodates for
these values, so no changes are needed there.

Fixes #22381

CLA: trivial

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

(cherry picked from commit 56d1ab3b6c7468ce0f534f09e305a539101f9c3d)

21 months agoFix a possible memory leak in load_builtin_compressions
Bernd Edlinger [Wed, 1 Nov 2023 07:05:30 +0000 (08:05 +0100)] 
Fix a possible memory leak in load_builtin_compressions

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

(cherry picked from commit daf26c2d7a4d29ec1040fc0d5d4215cfc2dcf4a7)

21 months agofree oaep label-octet-string on error
James Muir [Wed, 25 Oct 2023 00:08:54 +0000 (20:08 -0400)] 
free oaep label-octet-string on error

When X509_ALGOR_set0() fails, ownership of the the ASN1 object "los"
(label octet string) has not been passed on to the X509_ALGOR object
"oaep->pSourceFunc", so we need to free "los" in that case.

Check return value of X509_ALGOR_set0(), change the scope of "los" and
ensure it is freed on failure (on success, set it to NULL so it is not
freed inside the function).

Fixes #22336

Testing:
You can use the following script to test cms encryption with rsa-oaep:

  #!/bin/bash -x

  OSSLCMD="apps/openssl"

  # check we are calling the right openssl app
  LD_LIBRARY_PATH=. valgrind $OSSLCMD version

  echo "this is a confidential message." > msg.txt

  LD_LIBRARY_PATH=. valgrind $OSSLCMD cms -encrypt -in msg.txt \
   -stream -out msg.txt.cms \
   -recip test/smime-certs/smrsa1.pem \
          -keyopt rsa_padding_mode:oaep \
          -keyopt rsa_oaep_md:sha256 \
          -keyopt rsa_oaep_label:deadbeef

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

(cherry picked from commit a9a1b3da876456e1eecffbba15fb6d1820e8f379)

21 months agox509_print_ex: Remove unused setting when XN_FLAG_COMPAT is set
Damian Hobson-Garcia [Thu, 22 Dec 2022 22:15:55 +0000 (17:15 -0500)] 
x509_print_ex: Remove unused setting when XN_FLAG_COMPAT is set

Calling X509_NAME_print_ex with XN_FLAG_COMPAT falls back to calling
X509_NAME_print().  The obase parameter to X509_NAME_print() is not
used, so setting it to a different value has no effect.

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

(cherry picked from commit 2126ca3dba3907f49b232442c06db1cae8bee0c3)

21 months agoFix X509_REQ_print_ex bug
Damian Hobson-Garcia [Thu, 22 Dec 2022 22:04:39 +0000 (17:04 -0500)] 
Fix X509_REQ_print_ex bug

Similar to the bug fixed in 02db7354fe7 (Fix bug in X509_print_ex).
The error return value from X509_NAME_print_ex() is different
depending on whether the flags are XN_FLAG_COMPAT or not.
Apply a similar fix to what was done for X509_print_ex here as well.

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

(cherry picked from commit 2b5e028a2f70de216458a5140bcf4ec3d9236eeb)

21 months agox509_print_ex:Use correct constant for nmflag comparison
Damian Hobson-Garcia [Thu, 22 Dec 2022 21:36:05 +0000 (16:36 -0500)] 
x509_print_ex:Use correct constant for nmflag comparison

The X509_FLAG_COMPAT constant is defined as a value of the
X509_print_ex() cflags argument, and so it should not be used
to compare against values for use with X509_NAME_print flags.
Use XN_FLAG_COMPAT, which has the same value, instead.

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

(cherry picked from commit da2dd3b51ddd69aae0fd840c0d23afa954c24ded)

21 months agoFix potential NULL deref in ssl_old_test.c
Todd Short [Fri, 13 Oct 2023 14:18:52 +0000 (10:18 -0400)] 
Fix potential NULL deref in ssl_old_test.c

Fix #22367

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

(cherry picked from commit 42772df59bef7422060fbe70551c72d804bc669a)

21 months agoaes-gcm-avx512.pl: fix non-reproducibility issue
trigpolynom [Wed, 18 Oct 2023 02:44:45 +0000 (22:44 -0400)] 
aes-gcm-avx512.pl: fix non-reproducibility issue

Replace the random suffix with a counter, to make the
build reproducible.

Fixes #20954

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22415)

(cherry picked from commit 0fbc50ef0cb8894973d4739af62e95be825b7ccf)

21 months agobn: Properly error out if aliasing return value with modulus
Tomas Mraz [Wed, 18 Oct 2023 13:50:30 +0000 (15:50 +0200)] 
bn: Properly error out if aliasing return value with modulus

Test case amended from code initially written by Bernd Edlinger.

Fixes #21110

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

(cherry picked from commit af0025fc40779cc98c06db7e29936f9d5de8cc9e)

21 months agoLink libatomic on riscv32
Khem Raj [Sat, 21 Oct 2023 20:03:52 +0000 (13:03 -0700)] 
Link libatomic on riscv32

GCC toolchains on linux are not able to build libcrypto without linking
to libatomic as it does not have all needed atomics implemented as
intrinsics

Fixes errors like

| ld: ./libcrypto.so: undefined reference to `__atomic_is_lock_free'

CLA: trivial
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22460)

(cherry picked from commit d2e03c60347e19509e18a33ecb7f74502feb42ef)

21 months agoreturn 0 if an error occurred
Alexey Fofanov [Wed, 25 Oct 2023 11:29:06 +0000 (14:29 +0300)] 
return 0 if an error occurred

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

(cherry picked from commit f0d88b4d070426493749cfd6b657e42dc3c2f5dd)

21 months agoAvoid using gets as an argument name in a prototype
Tomas Mraz [Mon, 9 Oct 2023 08:32:44 +0000 (10:32 +0200)] 
Avoid using gets as an argument name in a prototype

This otherwise breaks compilation of applications using ssl.h on MingW.

Fixes #22296

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

(cherry picked from commit 2e471a740b621481b3f3236f82fdd677414900a1)

21 months agoPrepare for 3.1.5
Matt Caswell [Tue, 24 Oct 2023 13:42:06 +0000 (14:42 +0100)] 
Prepare for 3.1.5

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

21 months agoPrepare for release of 3.1.4 openssl-3.1.4
Matt Caswell [Tue, 24 Oct 2023 13:41:51 +0000 (14:41 +0100)] 
Prepare for release of 3.1.4

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

21 months agomake update
Matt Caswell [Tue, 24 Oct 2023 13:41:50 +0000 (14:41 +0100)] 
make update

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

21 months agoCopyright year updates
Matt Caswell [Tue, 24 Oct 2023 13:40:29 +0000 (14:40 +0100)] 
Copyright year updates

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

21 months agotest: add unit test for CVE-2023-5363
Pauli [Thu, 5 Oct 2023 23:32:20 +0000 (10:32 +1100)] 
test: add unit test for CVE-2023-5363

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
21 months agochanges and news entries for CVE-2023-5363
Pauli [Thu, 5 Oct 2023 23:43:46 +0000 (10:43 +1100)] 
changes and news entries for CVE-2023-5363

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
21 months agoevp: process key length and iv length early if present
Pauli [Thu, 5 Oct 2023 23:26:23 +0000 (10:26 +1100)] 
evp: process key length and iv length early if present

evp_cipher_init_internal() takes a params array argument and this is processed
late in the initialisation process for some ciphers (AEAD ones).

This means that changing the IV length as a parameter will either truncate the
IV (very bad if SP 800-38d section 8.2.1 is used) or grab extra uninitialised
bytes.

Truncation is very bad if SP 800-38d section 8.2.1 is being used to
contruct a deterministic IV.  This leads to an instant loss of confidentiality.

Grabbing extra bytes isn't so serious, it will most likely result in a bad
decryption.

Problem reported by Tony Battersby of Cybernetics.com but earlier discovered
and raised as issue #19822.

Fixes CVE-2023-5363
Fixes #19822

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
21 months agoFix Coverity 1547856: memset() uses only the lowest byte of c
Tomas Mraz [Thu, 19 Oct 2023 06:37:47 +0000 (08:37 +0200)] 
Fix Coverity 1547856: memset() uses only the lowest byte of c

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

(cherry picked from commit 0bf18140f491024232beca4e139c8feecfe207e9)

21 months agorand: fix seeding from a weak entropy source
Matthias St. Pierre [Sun, 15 Oct 2023 23:35:48 +0000 (01:35 +0200)] 
rand: fix seeding from a weak entropy source

The 'rand_generate' method is not well suited for being used with
weak entropy sources in the 'get_entropy' callback, because the
caller needs to provide a preallocated buffer without knowing
how much bytes are actually needed to collect the required entropy.

Instead we use the 'rand_get_seed' and 'rand_clear_seed' methods
which were exactly designed for this purpose: it's the callee who
allocates and fills the buffer, and finally cleans it up again.

The 'rand_get_seed' and 'rand_clear_seed' methods are currently
optional for a provided random generator. We could fall back to
using 'rand_generate' if those methods are not implemented.
However, imo it would be better to simply make them an officially
documented requirement for seed sources.

Fixes #22332

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

(cherry picked from commit 7998e7dc07d8f1f516af32887f2490c03cd8c594)

21 months agorand: improve error message for rand pool overflows
Richard Levitte [Wed, 11 Oct 2023 01:19:23 +0000 (12:19 +1100)] 
rand: improve error message for rand pool overflows

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

(cherry picked from commit 0a8faac3c7cc2e88f46a8bdce5bd039dc22abdec)

21 months agoReference the non-"legacy" provider names directly from EVP_md5(3) &c.
наб [Wed, 18 Oct 2023 13:35:55 +0000 (15:35 +0200)] 
Reference the non-"legacy" provider names directly from EVP_md5(3) &c.

Earlier today, it took me five manuals! to find what on earth the
"Performance"/"EVP_MD_fetch(3)" crosslinks actually mean:
  EVP_sha1(3)
  crypto(7)
  EVP_MD_fetch(3) (but not there! don't read that!)
  OSSL_PROVIDER-default(7)
  EVP_MD-SHA1(7)

If, instead, EVP_sha1(3) referenced EVP_MD-SHA1(7) at /all/,
which it should do, since it's supposed to be what you're replacing it
with, but it doesn't actually say that, maybe people would use it.
I know I didn't because it's basically just deadass buried

As found by git grep -l 'and should consider using'

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

(cherry picked from commit b6eb95fa4439ea6254a5330487dabb2a499fb6c8)

21 months agorand: add callbacks to cleanup the user entropy resp. nonce
Matthias St. Pierre [Mon, 16 Oct 2023 21:48:03 +0000 (23:48 +0200)] 
rand: add callbacks to cleanup the user entropy resp. nonce

The `get_user_{entropy,nonce}` callbacks were add recently to the
dispatch table in commit 4cde7585ce8e. Instead of adding corresponding
`cleanup_user_{entropy,nonce}` callbacks, the `cleanup_{entropy,nonce}`
callbacks were reused. This can cause a problem in the case where the
seed source is replaced by a provider: the buffer gets allocated by
the provider but cleared by the core.

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

(cherry picked from commit 5516d20226c496c2b22fa741698b4d48dad0428f)

21 months agoload_key_certs_crls(): There is no quiet argument
Tomas Mraz [Thu, 19 Oct 2023 08:30:15 +0000 (10:30 +0200)] 
load_key_certs_crls(): There is no quiet argument

This fixes broken cherry-pick from the master branch
where there is a quiet argument.

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

21 months agocms_enc.c: Include crypto/asn1.h for struct asn1_object_st
Tomas Mraz [Thu, 19 Oct 2023 07:23:43 +0000 (09:23 +0200)] 
cms_enc.c: Include crypto/asn1.h for struct asn1_object_st

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

(cherry picked from commit fa9e6ad46860ea92aa2e1ba997b20c6dff76b42c)

21 months agoapps: Print out a proper message when a store cannot be opened
Tomas Mraz [Mon, 9 Oct 2023 09:36:50 +0000 (11:36 +0200)] 
apps: Print out a proper message when a store cannot be opened

Fixes #22306

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

(cherry picked from commit edc2b6e3b1950ab0fb71e2d7dca0836b43a9ec3b)

21 months agoAdd a test to confirm that legacy rsa keys work
Neil Horman [Wed, 11 Oct 2023 16:45:44 +0000 (12:45 -0400)] 
Add a test to confirm that legacy rsa keys work

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

(cherry picked from commit e62097f48c3d0b8b61ca6a061b8098b0086b3fbc)

21 months agoDont require CRT params on ossl_rsa_set0_all_params
Neil Horman [Tue, 10 Oct 2023 15:06:44 +0000 (11:06 -0400)] 
Dont require CRT params on ossl_rsa_set0_all_params

Its not required that crt params be available in an RSA key, so don't
perform an error check on them

Fixes #29135

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

(cherry picked from commit 2647726bd3ca63dc5f07ae3f10e16dff35d95626)

21 months agoremove sanity check from ossl_rsa_todata
Neil Horman [Tue, 5 Sep 2023 16:08:19 +0000 (12:08 -0400)] 
remove sanity check from ossl_rsa_todata

Theres no reason we should gate ossl_rsa_todata on there being a minimum
set of parameters. EVP_PKEY_todata makes no guarantees about the
validity of a key, it only returns the parameters that are set in the
requested key, whatever they may be.  Remove the check.

Fixes #21935

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

(cherry picked from commit 4ad3a44ba45a4026170336161228d435f6784564)

21 months agoossl_param_build_set_multi_key_bn(): Do not set NULL BIGNUMs
Tomas Mraz [Mon, 4 Sep 2023 09:10:42 +0000 (11:10 +0200)] 
ossl_param_build_set_multi_key_bn(): Do not set NULL BIGNUMs

This makes them zeroes otherwise
where NULLs actually mean the values aren't present.

Fixes #21935

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

(cherry picked from commit 15a39e7025e0ed4e31664c499894006e41582068)

21 months agoensure that ossl_obj_nid_lock is allocated before use
Neil Horman [Wed, 11 Oct 2023 13:34:02 +0000 (09:34 -0400)] 
ensure that ossl_obj_nid_lock is allocated before use

external calls to OBJ_new_nid will fail on an attempt to lock the
ossl_obj_nid_lock as it won't have been initalized yet.

Bifurcate OBJ_new_nid into an external and internal variant, in which
the former calls ossl_obj_write_lock (ensuring that the nid_lock is
initalized), while OBJ_create (the sole internal caller) uses the latter
to avoid having to drop and re-acquire the lock

Fixes #22337

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

(cherry picked from commit cd920f8fa1bb603a620bea697027f5573fadc12e)

21 months agocms encrypt, better OBJ_nid2obj() return check
James Muir [Sat, 14 Oct 2023 23:36:57 +0000 (19:36 -0400)] 
cms encrypt, better OBJ_nid2obj() return check

Fixes #22225

In OBJ_nid2obj(), if the NID does not have an OID, then a pointer to
the special "undefined" ASN1_OBJECT is returned.  Check for the
undefined-ASN1_OBJECT and return an error.  Also, add a test for this
in 80-test_cms.t.

Testing:

  #!/bin/bash -x

  shopt -s expand_aliases

  alias openssl="LD_LIBRARY_PATH=~/git/openssl ~/git/openssl/apps/openssl"

  echo "This is a confidential message.  It should be encrypted." > msg.txt

  ## this should fail b/c there is no OID for aes-256-ctr
  openssl cms -encrypt -in msg.txt -aes-256-ctr -out msg.txt.cms -recip demos/cms/signer.pem
  echo $?

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

(cherry picked from commit bd160912dcc5e39bcdc925d9aa6538f20e37ad16)

21 months agofix: LINEAR search doesn't work properly (if CHARSET_EBCDIC is defined)
Pavel Stetsuk [Thu, 14 Sep 2023 20:05:49 +0000 (23:05 +0300)] 
fix: LINEAR search doesn't work properly (if CHARSET_EBCDIC is defined)

CLA: trivial

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

(cherry picked from commit a47fc4ed401da4e2d84e035cc4add566e85b03d0)

21 months agorsa: Accept NULL OAEP label for backward compatibility
Daiki Ueno [Mon, 16 Oct 2023 05:42:12 +0000 (14:42 +0900)] 
rsa: Accept NULL OAEP label for backward compatibility

According to the manual page, EVP_PKEY_CTX_set0_rsa_oaep_label()
should accept NULL as the label argument, though the function
currently rejects it while setting the corresponding octet string
parameter with OSSL_PARAM_construct_octet_string, which expects
non-NULL input.  This adds a workaround to the caller for backward
compatibility.

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

(cherry picked from commit 21b98da9d80c561b6273b0c51c259196d6740e70)

21 months agoUpdate unix Makefile template to handle paths with spaces
James Muir [Tue, 10 Oct 2023 16:41:59 +0000 (12:41 -0400)] 
Update unix Makefile template to handle paths with spaces

Fixes #4668 (on unix-like platforms)

Testing:

  rm -rf "$HOME/tmp/beforespace afterspace"
  ./Configure -Werror --strict-warnings --prefix="$HOME/tmp/beforespace afterspace"
  make -j6 update
  make -j6
  make install
  make test

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

21 months agoEVP shake_ctrl(): add missing NULL evp_ctx check
Dr. David von Oheimb [Fri, 13 Oct 2023 20:27:31 +0000 (22:27 +0200)] 
EVP shake_ctrl(): add missing NULL evp_ctx check

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

(cherry picked from commit 410c80dc7bf2085167553ab9fa517189eed2b3a6)

21 months agoCMS_add1_signer(): add missing ERR_raise() calls
Dr. David von Oheimb [Fri, 13 Oct 2023 20:12:22 +0000 (22:12 +0200)] 
CMS_add1_signer(): add missing ERR_raise() calls

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

(cherry picked from commit 72a99ef665b26fa207c0eee6e7e4842d1e42752c)

21 months agoCMS_add1_signer.pod: add missing info on CMS_SignerInfo_sign() return values
Dr. David von Oheimb [Fri, 13 Oct 2023 20:39:25 +0000 (22:39 +0200)] 
CMS_add1_signer.pod: add missing info on CMS_SignerInfo_sign() return values

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

(cherry picked from commit 2c581eb2fd92e997dfe0761b086eb690271cefc2)

21 months agoPKCS7_SIGNER_INFO: point out confusing names of digest_enc_alg and enc_digest fields
Dr. David von Oheimb [Fri, 13 Oct 2023 20:30:31 +0000 (22:30 +0200)] 
PKCS7_SIGNER_INFO: point out confusing names of digest_enc_alg and enc_digest fields

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

(cherry picked from commit e15891b477fe9c3d3dc6f331812c9e8afc48dc05)

21 months agocmp: add null pointer check in tear_down test function
Pauli [Wed, 11 Oct 2023 21:46:19 +0000 (08:46 +1100)] 
cmp: add null pointer check in tear_down test function

problem reported by: 2ourc3

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22355)

(cherry picked from commit 91a5c0e40cf272d18b65c9e4c9a0268f244758a8)

21 months agoFix parenthesis, use a colon
James Muir [Wed, 11 Oct 2023 22:11:42 +0000 (18:11 -0400)] 
Fix parenthesis, use a colon

Reviewed-by: Paul Dale <pauli@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/22356)

(cherry picked from commit 008ca01e506d85acf0cc06ea8f219a883328344c)

21 months agoWindows: use srand() instead of srandom()
Tomas Mraz [Wed, 11 Oct 2023 09:20:02 +0000 (11:20 +0200)] 
Windows: use srand() instead of srandom()

This is used for memory allocation failure debugging only

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

(cherry picked from commit 3b107b86ca7d1c6309bc7071ead59acb8c098f3b)

21 months agoWindows CI: Add some non-default options to check they are working
Tomas Mraz [Wed, 11 Oct 2023 09:05:37 +0000 (11:05 +0200)] 
Windows CI: Add some non-default options to check they are working

Some of the non-default options that enable more
code to be built need to be enabled in one of the
Windows builds to avoid regressions.

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

(cherry picked from commit 10767fd9db14b6eedfb0827f9e404c0d4b94424b)

21 months agoDH_check_pub_key() should not fail when setting result code
Tomas Mraz [Thu, 5 Oct 2023 09:11:16 +0000 (11:11 +0200)] 
DH_check_pub_key() should not fail when setting result code

The semantics of ossl_ffc_validate_public_key() and
ossl_ffc_validate_public_key_partial() needs to be changed
to not return error on non-fatal problems.

Fixes #22287

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

(cherry picked from commit eaee1765a49c6a8ba728e3e2d18bb67bff8aaa55)

21 months agotest/recipes/05-test_rand.t: replace 'and' with '&&'
Richard Levitte [Tue, 10 Oct 2023 10:32:40 +0000 (12:32 +0200)] 
test/recipes/05-test_rand.t: replace 'and' with '&&'

The lower priority 'and' seems to have some "interesting" interactions with
function argument parsing in some perl versions (presumably because 'and' is
lower priority than the comma).

For the lines that are changed here, perl v5.20.1 says this:

    Useless use of string eq in void context at [.test.recipes]05-test_rand.t line 33.
    Useless use of numeric eq (==) in void context at [.test.recipes]05-test_rand.t line 39.

Replacing 'and' with '&&' in these two cases fixes the problem.

Replacing

Reviewed-by: Hugo Landau <hlandau@openssl.org>
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/22331)

(cherry picked from commit 715242b1ca2b7267a70fb13c3544a84b947a6e81)

21 months agoImprove Malloc Failure Test
Bernd Edlinger [Mon, 18 Sep 2023 06:16:01 +0000 (08:16 +0200)] 
Improve Malloc Failure Test

Allow 2 digits after the comma in percentage in OPENSSL_MALLOC_FAILURES.
Add OPENSSL_MALLOC_SEED to allow for some randomization.

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

(cherry picked from commit 3df5736cf303d2c69654ba1c295a9772b738608e)

21 months agoAdded check for the return value of the RAND_bytes() function
Klavishnik [Thu, 10 Aug 2023 10:56:24 +0000 (13:56 +0300)] 
Added check for the return value of the RAND_bytes() function

Call app_bail_out if RAND_bytes() fails.

Also changed the output parameter of RAND_bytes() to inp as
writing to encrypted output buffer does not make sense.

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

(cherry picked from commit 8d120aef951d7bb7deac0b8b559f8003f5ea6384)

22 months agoAvoid divide-by-zero in kmac_prov.c's bytepad()
Klavishnik [Wed, 9 Aug 2023 14:05:03 +0000 (17:05 +0300)] 
Avoid divide-by-zero in kmac_prov.c's bytepad()

This would happen if EVP_MD_get_block_size() returned 0
so we return an error instead.

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

(cherry picked from commit 91895e39b10033178e662fc7427a09d7562cf8e1)

22 months agoOptimize out unneeded up_ref/free of EVP_CIPHER
Tomas Mraz [Tue, 26 Sep 2023 15:39:50 +0000 (17:39 +0200)] 
Optimize out unneeded up_ref/free of EVP_CIPHER

Fixes #22189

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

(cherry picked from commit 8ed76c62b5d3214e807e684c06efd69c6471c800)

22 months agod2i_X509.pod: Better document using the reuse capability for libctx setup
Tomas Mraz [Tue, 3 Oct 2023 13:45:13 +0000 (15:45 +0200)] 
d2i_X509.pod: Better document using the reuse capability for libctx setup

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

(cherry picked from commit 4ca56f51803a8ae010423180ac80ef991cf78fc5)

22 months agoBN_gcd(): Avoid shifts of negative values
Tomas Mraz [Wed, 4 Oct 2023 07:30:43 +0000 (09:30 +0200)] 
BN_gcd(): Avoid shifts of negative values

Fixes #22216

Thanks to Leland Mills for investigation and testing.

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

(cherry picked from commit 0f7a3b0caa33a87c900536dc1c02fa553d2193cc)

22 months agoDH_check: Emphasize the importance of return value check
Tomas Mraz [Tue, 3 Oct 2023 12:43:13 +0000 (14:43 +0200)] 
DH_check: Emphasize the importance of return value check

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

(cherry picked from commit f7b80136a3df4396b19ebb86d4814d8cefe6d6db)