]> git.ipfire.org Git - thirdparty/openssl.git/log
thirdparty/openssl.git
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)
(cherry picked from commit e83a231d3e1da1a55260503a06365b1950985933)

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

21 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)

21 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)

(cherry picked from commit 2fd4fd35bf906290a9c14b81f16e7ae01d297122)

21 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)

(cherry picked from commit bd864f058c495d97e42007128d62f7fb19ae1818)

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)

(cherry picked from commit 3629ce9c4cb638d9458d8febd21659920903a749)

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)

(cherry picked from commit ddeb4b6c6d527e54ce9a99cba785c0f7776e54b6)

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)

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

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.0.13
Matt Caswell [Tue, 24 Oct 2023 13:48:49 +0000 (14:48 +0100)] 
Prepare for 3.0.13

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

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

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

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

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

21 months agoCopyright year updates
Matt Caswell [Tue, 24 Oct 2023 13:47:21 +0000 (14:47 +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>
(cherry picked from commit efce76073edc228bbbbc09e65aa076ad5f15ac2c)

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>
(cherry picked from commit 3f636830e4dcfe9b6ab57bef42c0b3a1de194399)

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>
(cherry picked from commit 5f69f5c65e483928c4b28ed16af6e5742929f1ee)

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

(cherry picked from commit 307048cd4e887de688eb71af713c64962261cd29)

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

(cherry picked from commit f4bc5568a973e640a70f416da37a030c25a38ebc)

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)

22 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)

22 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)

22 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)

22 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 agoDon't use __ARMEL__/__ARMEB__ in aarch64 assembly
David Benjamin [Wed, 29 Dec 2021 18:05:12 +0000 (13:05 -0500)] 
Don't use __ARMEL__/__ARMEB__ in aarch64 assembly

GCC's __ARMEL__ and __ARMEB__ defines denote little- and big-endian arm,
respectively. They are not defined on aarch64, which instead use
__AARCH64EL__ and __AARCH64EB__.

However, OpenSSL's assembly originally used the 32-bit defines on both
platforms and even define __ARMEL__ and __ARMEB__ in arm_arch.h. This is
less portable and can even interfere with other headers, which use
__ARMEL__ to detect little-endian arm.

Over time, the aarch64 assembly has switched to the correct defines,
such as in 32bbb62ea634239e7cb91d6450ba23517082bab6. This commit
finishes the job: poly1305-armv8.pl needed a fix and the dual-arch
armx.pl files get one more transform to convert from 32-bit to 64-bit.

(There is an even more official endianness detector, __ARM_BIG_ENDIAN in
the Arm C Language Extensions. But I've stuck with the GCC ones here as
that would be a larger change.)

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

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)

22 months agoossl_property_list_to_string: handle quoted strings
Pauli [Sun, 24 Sep 2023 23:34:07 +0000 (09:34 +1000)] 
ossl_property_list_to_string: handle quoted strings

ossl_property_list_to_string() didn't quote strings correctly which
could result in a generated property string being unparsable.

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

(cherry picked from commit fb20e66c6b2651067f50bab8cf098c71e2caed4b)

22 months agod2i_PKCS8PrivateKey_bio.pod: evp.h include is unnecessary
Tomas Mraz [Wed, 4 Oct 2023 10:30:22 +0000 (12:30 +0200)] 
d2i_PKCS8PrivateKey_bio.pod: evp.h include is unnecessary

It is also not allowed by doc nits check to have
multiple includes.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/22276)

(cherry picked from commit 831602922f19a8f39d0c0fae425b81e9ab402c69)

22 months agoDon't (re-)initialize the FFC_PARAMs in dh_init and dsa_init
Matthias St. Pierre [Mon, 2 Oct 2023 10:10:01 +0000 (12:10 +0200)] 
Don't (re-)initialize the FFC_PARAMs in dh_init and dsa_init

The initialization was introduced in commit dc8de3e6f1ee and
changes the behaviour of the `init` method for DSA and DH
between 1.1.1 and 3.0, while the behaviour for RSA and EC_KEY
remains unchanged.

The initialization is not necessary in 3.x and master imho and
breaks the use-case of intercepting the methods of an existing
key.

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

(cherry picked from commit 706512ecbc31585d447b53c3aa89acdf6951f996)

22 months agotest: evp_extra: test signing with legacy app method based keys
Matthias St. Pierre [Sat, 23 Sep 2023 23:13:20 +0000 (01:13 +0200)] 
test: evp_extra: test signing with legacy app method based keys

This commit adds `test_EVP_PKEY_sign_with_app_method`, a regression
test for the bug fix in commit 1acc3e8cc3c6 (pull request #22163).

It is analogous to `test_EVP_PKEY_sign`, only with a fake app method
based key. (The EC key test case was omitted, because there is no
`EC_KEY_METHOD_dup` method.)

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

(cherry picked from commit 860e36d0dd72f4aa4791e88aa185cb42065a30c4)

22 months agotest: evp_extra: fix indentation error
Matthias St. Pierre [Sat, 23 Sep 2023 23:24:59 +0000 (01:24 +0200)] 
test: evp_extra: fix indentation error

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

(cherry picked from commit b49cafd86b295aa5e177d6c1368b06a1202ec2b3)

22 months agoCorrect documentation for PKCS5_PBKDF2_HMAC
Sumitra Sharma [Tue, 3 Oct 2023 03:58:44 +0000 (09:28 +0530)] 
Correct documentation for PKCS5_PBKDF2_HMAC

In OpenSSL 3.x, the documentation for PKCS5_PBKDF2_HMAC incorrectly states
that an iter value less than 1 is treated as a single iteration. Upon further
investigation in providers/implementations/kdfs/pbkdf2.c, it appears that
invalid iter values will result in failure and raise the
PROV_R_INVALID_ITERATION_COUNT error. This commit corrects the documentation
to accurately reflect the behavior in OpenSSL 3.x.

Closes openssl#22168

Signed-off-by: Sumitra Sharma <sumitraartsy@gmail.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22252)

(cherry picked from commit 82496b8663f20ff12f02adbe46a060a94b0cbfc5)

22 months agoRestore the meaning of EVP_PKEY_print_private()
Richard Levitte [Mon, 2 Oct 2023 07:12:12 +0000 (09:12 +0200)] 
Restore the meaning of EVP_PKEY_print_private()

With pre-3.0 OpenSSL, EVP_PKEY_print_private() calls the EVP_PKEY_ASN1_METHOD
function "priv_print", effectively asking the backend to print whatever it
regards as private key components.

In all backends that were built into libcrypto, this function printed what
was included in the private key structure, which usually includes the
public key components as well.

With OpenSSL 3.0, some of the corresponding key2text encoders got a
slightly different behavior, where the presence of the selector
OSSL_KEYMGMT_SELECT_PRIVATE_KEY without the presence of the selector
OSSL_KEYMGMT_SELECT_PUBLIC_KEY would only get what would intuitively be
regarded as private key components printed.  This isn't entirely consistent,
though, as the RSA key2text encoder will still print the public key
components regardless.

To compensate for the changed backend behavior, EVP_PKEY_print_private()
was made to ask the encoder to print the keypair rather than just the
private key, thereby moving the backend semantics to the application API.
Unfortunately, this causes confusion for providers where the key2text
encoder really should print the private key only.

This change restores the built-in 1.1.1 backend behavior in the encoders
that OpenSSL provides, and renders EVP_PKEY_print_private() more true to its
documented behavior, leaving it to the backend to decide what it regards as
"private key components".

Fixes #22233

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

(cherry picked from commit 1296c2ec7866a4f2f4d210432c771142e8de33a0)

22 months agoImproved detection of engine-provided private "classic" keys
Dmitry Belyavskiy [Mon, 26 Dec 2022 19:38:44 +0000 (20:38 +0100)] 
Improved detection of engine-provided private "classic" keys

Resolves #17092 (?)
Resolves #17286 (?)

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

(cherry picked from commit 2b74e75331a27fc89cad9c8ea6a26c70019300b5)

22 months agoRemove duplicates of EVP_aes_xxx_wrap() from EVP_aes_128_gcm.pod
Frederik Wedel-Heinen [Mon, 2 Oct 2023 08:58:48 +0000 (10:58 +0200)] 
Remove duplicates of EVP_aes_xxx_wrap() from EVP_aes_128_gcm.pod

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

(cherry picked from commit 5c20c202699ba9c08183c5227df0ad4352e0974b)

22 months agodoc/man3: fix misnamed function name
Matthias St. Pierre [Tue, 26 Sep 2023 16:25:27 +0000 (18:25 +0200)] 
doc/man3: fix misnamed function name

Rename `DSA_generate_prime[_ex]` to `DSA_generate_parameters[_ex]`,
fixing a copy&paste error from the `BN_generate_prime[_ex]` paragraph
in commit b3696a55a5ed.

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

(cherry picked from commit 515856f5ceb1ef0065466ac85164766623457000)

22 months agoAdd openssl/pem.h inclusion for d2i_PKCS8PrivateKey
Sumitra Sharma [Mon, 2 Oct 2023 15:23:52 +0000 (20:53 +0530)] 
Add openssl/pem.h inclusion for d2i_PKCS8PrivateKey

Include the necessary header file openssl/pem.h in the
documentation to ensure that all functions related to
d2i_PKCS8PrivateKey are correctly defined.

Closes openssl#22188

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

(cherry picked from commit cda2e7c914bffc904e3ee79f360953fd370e19e9)

22 months agoBump actions/setup-python from 4.7.0 to 4.7.1
dependabot[bot] [Mon, 2 Oct 2023 17:23:41 +0000 (17:23 +0000)] 
Bump actions/setup-python from 4.7.0 to 4.7.1

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

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

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

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

(cherry picked from commit f7e7bbcd7850b96d02dd0f4dd49b3365b320776c)

22 months agodoc: correct the SSL_CTX_set_info_callback(3) manual page
Matthias St. Pierre [Fri, 29 Sep 2023 13:31:37 +0000 (15:31 +0200)] 
doc: correct the SSL_CTX_set_info_callback(3) manual page

The info callback is not prototyped correctly, and the code
example fails to compile because of const-incorrectness.

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

(cherry picked from commit 92986c0be56bc8bf9c414dab59d4f1e128f1e843)

22 months agono-engine: fix signing with legacy app method based keys
Matthias St. Pierre [Thu, 21 Sep 2023 14:43:43 +0000 (16:43 +0200)] 
no-engine: fix signing with legacy app method based keys

Signing with an app method based key (i.e. an `EVP_PKEY` which wraps an
`RSA` key with an application defined `RSA_METHOD`) used to work in 1.1.1.
That feature was broken in commit 60488d2434, but later on fixed by @t8m
in commit b247113c05 (see #14859).

This commit corrects a  minor flaw of the fix, which affects only
`no-engine` builds: the special treatment for foreign keys is guarded
by an `OPENSSL_NO_ENGINE` check.

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

(cherry picked from commit 1acc3e8cc3c69187b55cc557c1bc03278ab38063)
(cherry picked from commit c67a1988fcf8fe34b1d31e29849f2528d553dd66)

22 months agoDo not include sparse_array.o in libssl
Huiyue Xu [Thu, 14 Sep 2023 08:21:35 +0000 (16:21 +0800)] 
Do not include sparse_array.o in libssl

sparse_array.o is not needed in libssl at 3.0.x version.

Signed-off-by: Huiyue Xu <xuhuiyue@huawei.com>
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/22111)

22 months agoFix test_cms if DSA is not supported
Steffen Klee [Tue, 19 Sep 2023 22:04:18 +0000 (00:04 +0200)] 
Fix test_cms if DSA is not supported

CLA: trivial

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

(cherry picked from commit dee2129802d9694d72e8745aec2d8bd4577ee4ee)

22 months agoFix error handling in lhash contract
Bernd Edlinger [Wed, 20 Sep 2023 13:45:56 +0000 (15:45 +0200)] 
Fix error handling in lhash contract

When the realloc fails in contract, this not a fatal
error, since the memory is only shrinked. It is also no
option to exit the function at this point, since that
would leave the hash table in an inconsistent state.

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

(cherry picked from commit 5fbfd641aeebdf4b29a0749e13a79a1e59502878)

22 months agoFix error handling in CRYPTO_get_ex_new_index
Bernd Edlinger [Tue, 19 Sep 2023 18:15:18 +0000 (20:15 +0200)] 
Fix error handling in CRYPTO_get_ex_new_index

If an out of memory error happens when the index zero
is reserved in a newly created ip->meth stack object,
that reservation is not done in a second attempt, which makes
various X_set_ex_data overwrite the value of X_set_app_data.

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

(cherry picked from commit d4f22a915ac50570015a23ad794032c4fb9496cb)

22 months agoFix some memory leaks in the openssl app
Bernd Edlinger [Mon, 11 Sep 2023 04:38:31 +0000 (06:38 +0200)] 
Fix some memory leaks in the openssl app

In some error cases the normal cleanup did not
happen, but instead an exit(1) which caused some
memory leaks, as reported in #22049.

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

(cherry picked from commit 8c040c086ca11a519975c58961a5dc933aa6524a)

22 months agocoverity: NULL dereference
Pauli [Tue, 19 Sep 2023 01:07:21 +0000 (11:07 +1000)] 
coverity: NULL dereference

Fixes coverity 1544699.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/22138)

(cherry picked from commit be01f609f98a8930f2c91b813715e515a88f4d54)

22 months agoAdd documentation for the function SSL_CONF_CTX_finish.
Sumitra Sharma [Mon, 18 Sep 2023 11:08:11 +0000 (16:38 +0530)] 
Add documentation for the function SSL_CONF_CTX_finish.

Add documentation for the function SSL_CONF_CTX_finish() in man3.

Fixes #22084

Signed-off-by: Sumitra Sharma <sumitraartsy@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22128)

(cherry picked from commit 955c133ccccd2b6e3f5a1b1342045111fe8b3e86)

22 months agoenc: "bad decrypt" only in decryption
Mathieu Tortuyaux [Mon, 18 Sep 2023 14:02:21 +0000 (16:02 +0200)] 
enc: "bad decrypt" only in decryption

CLA: trivial

Signed-off-by: Mathieu Tortuyaux <mathieu.tortuyaux@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22134)

(cherry picked from commit 0e138b7b591f160a50aff22f662254d1b39c9cac)

22 months agoPrepare for 3.0.12 22146/head
Richard Levitte [Tue, 19 Sep 2023 13:03:18 +0000 (15:03 +0200)] 
Prepare for 3.0.12

Reviewed-by: Matt Caswell <matt@openssl.org>
Release: yes

22 months agoPrepare for release of 3.0.11 openssl-3.0.11
Richard Levitte [Tue, 19 Sep 2023 13:02:31 +0000 (15:02 +0200)] 
Prepare for release of 3.0.11

Reviewed-by: Matt Caswell <matt@openssl.org>
Release: yes

22 months agomake update
Richard Levitte [Tue, 19 Sep 2023 13:02:19 +0000 (15:02 +0200)] 
make update

Reviewed-by: Matt Caswell <matt@openssl.org>
Release: yes

22 months agoCopyright year updates
Richard Levitte [Tue, 19 Sep 2023 12:58:35 +0000 (14:58 +0200)] 
Copyright year updates

Reviewed-by: Matt Caswell <matt@openssl.org>
Release: yes

22 months agoCMP app and API doc: add note on critical server auth on receiving trust anchor certs
Dr. David von Oheimb [Sat, 3 Jun 2023 15:17:14 +0000 (17:17 +0200)] 
CMP app and API doc: add note on critical server auth on receiving trust anchor certs

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

22 months agoCMP doc: various small corrections, mostly on PBM vs. MAC-based protection
Dr. David von Oheimb [Sat, 3 Jun 2023 15:15:06 +0000 (17:15 +0200)] 
CMP doc: various small corrections, mostly on PBM vs. MAC-based protection

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