]> git.ipfire.org Git - thirdparty/openssl.git/log
thirdparty/openssl.git
10 months agoCopyright year updates
Tomas Mraz [Thu, 5 Sep 2024 07:35:49 +0000 (09:35 +0200)] 
Copyright year updates

Reviewed-by: Neil Horman <nhorman@openssl.org>
Release: yes

10 months agoutil/mkinstallvars.pl: replace List::Util::pairs with out own
Richard Levitte [Tue, 3 Sep 2024 17:16:05 +0000 (19:16 +0200)] 
util/mkinstallvars.pl: replace List::Util::pairs with out own

Unfortunately, List::Util::pairs didn't appear in perl core modules
before 5.19.3, and our minimum requirement is 5.10.

Fortunately, we already have a replacement implementation, and can
re-apply it in this script.

Fixes #25366

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

10 months agoCI: Update upload-artifact action to be compatible
Tomas Mraz [Wed, 4 Sep 2024 15:17:29 +0000 (17:17 +0200)] 
CI: Update upload-artifact action to be compatible

The download-artifact action was updated to 4.x
and the upload-artifact must be kept in sync.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25383)

10 months agobuild(deps): bump actions/download-artifact in /.github/workflows
dependabot[bot] [Tue, 3 Sep 2024 22:45:53 +0000 (22:45 +0000)] 
build(deps): bump actions/download-artifact in /.github/workflows

Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4.1.7.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v3...v4.1.7)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
...

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

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

10 months agoEVP_CIPHER_CTX_get_algor_params() may attempt to access params array
Alexandr Nedvedicky [Wed, 28 Aug 2024 12:37:07 +0000 (14:37 +0200)] 
EVP_CIPHER_CTX_get_algor_params() may attempt to access params array
at position -1 (prams[=1]).

The issue has been reported by coverity check.

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

10 months agos390x: Fix prehash-by-caller handling for ED25519 and ED448
Ingo Franzki [Mon, 2 Sep 2024 07:08:02 +0000 (09:08 +0200)] 
s390x: Fix prehash-by-caller handling for ED25519 and ED448

In case of prehash or prehash-by-caller is set skip the s390x specific
acceleration an fallback to the non-accelerated code path.

Fixes: 66966827740a04249300b0b25735e9d4c9bcab26
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25351)

10 months agos390x: Disable HMAC hardware acceleration when an engine is used for the digest
Ingo Franzki [Mon, 26 Aug 2024 09:26:03 +0000 (11:26 +0200)] 
s390x: Disable HMAC hardware acceleration when an engine is used for the digest

The TLSProxy uses the 'ossltest' engine to produce known output for digests
and HMAC calls. However, when running on a s390x system that supports
hardware acceleration of HMAC, the engine is not used for calculating HMACs,
but the s390x specific HMAC implementation is used, which does produce correct
output, but not the known output that the engine would produce. This causes
some tests (i.e. test_key_share, test_sslextension, test_sslrecords,
test_sslvertol, and test_tlsextms) to fail.

Disable the s390x HMAC hardware acceleration if an engine is used for the
digest of the HMAC calculation. This provides compatibility for engines that
provide digest implementations, and assume that these implementations are also
used when calculating an HMAC.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25287)

10 months agoAdd CVE-2024-5535 to CHANGES and NEWS
Tomas Mraz [Tue, 3 Sep 2024 10:24:58 +0000 (12:24 +0200)] 
Add CVE-2024-5535 to CHANGES and NEWS

Reviewed-by: Neil Horman <nhorman@openssl.org>
Release: yes
(cherry picked from commit abcb0f83d060eb816503a6a36959ce8498a24111)

10 months agoUpdated CHANGES and NEWS for CVE-2024-6119 fix
Viktor Dukhovni [Wed, 10 Jul 2024 09:50:57 +0000 (19:50 +1000)] 
Updated CHANGES and NEWS for CVE-2024-6119 fix

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(cherry picked from commit cf384d35aa7142cc3b5de19f64d3972e77d3ff74)

10 months agoAvoid type errors in EAI-related name check logic.
Viktor Dukhovni [Wed, 19 Jun 2024 11:04:11 +0000 (21:04 +1000)] 
Avoid type errors in EAI-related name check logic.

The incorrectly typed data is read only, used in a compare operation, so
neither remote code execution, nor memory content disclosure were possible.
However, applications performing certificate name checks were vulnerable to
denial of service.

The GENERAL_TYPE data type is a union, and we must take care to access the
correct member, based on `gen->type`, not all the member fields have the same
structure, and a segfault is possible if the wrong member field is read.

The code in question was lightly refactored with the intent to make it more
obviously correct.

Fixes CVE-2024-6119

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
10 months agoAdd CHANGES.md and NEWS.md updates for the 3.4 release
Tomas Mraz [Fri, 30 Aug 2024 15:06:12 +0000 (17:06 +0200)] 
Add CHANGES.md and NEWS.md updates for the 3.4 release

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/25339)

10 months agoAdd support for elf_aux_info() on OpenBSD
Brad Smith [Sun, 1 Sep 2024 05:07:16 +0000 (01:07 -0400)] 
Add support for elf_aux_info() on OpenBSD

CLA: trivial

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

10 months agoMissing .rodata for AVX2/AVX512 codepaths
Theo Buehler [Fri, 30 Aug 2024 15:06:26 +0000 (17:06 +0200)] 
Missing .rodata for AVX2/AVX512 codepaths

This is a follow-up to #23997

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25340)

10 months agoDetect MinGW 32 bit for NO_INTERLOCKEDOR64
Adam (ThinLinc team) [Mon, 29 Jul 2024 11:54:46 +0000 (13:54 +0200)] 
Detect MinGW 32 bit for NO_INTERLOCKEDOR64

Builds using 32 bit MinGW will fail, due to the same reasoning described in commit 2d46a44ff24173d2cf5ea2196360cb79470d49c7.

CLA: trivial

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

10 months agos390x: Fix HMAC digest detection
Ingo Franzki [Wed, 28 Aug 2024 12:56:33 +0000 (14:56 +0200)] 
s390x: Fix HMAC digest detection

Use EVP_MD_is_a() instead of EVP_MD_get_type() to detect the digest
type. EVP_MD_get_type() does not always return the expected NID, e.g.
when running in the FIPS provider, EVP_MD_get_type() returns zero,
causing to skip the HMAC acceleration path.

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

11 months agoImprove base64 BIO correctness and error reporting
Viktor Dukhovni [Wed, 21 Aug 2024 14:43:33 +0000 (00:43 +1000)] 
Improve base64 BIO correctness and error reporting

Also improve related documentation.

- The BIO_FLAGS_BASE64_NO_NL flag did not behave as advertised, only
  leading and trailing, but not internal, whitespace was supported:

      $ echo 'AA AA' | openssl base64 -A -d | wc -c
      0

- Switching from ignored leading input to valid base64 input misbehaved
  when the length of the skipped input was one more than the length of
  the second and subsequent valid base64 lines in the internal 1k
  buffer:

    $ printf '#foo\n#bar\nA\nAAA\nAAAA\n' | openssl base64 -d | wc -c
    0

- When the underlying BIO is retriable, and a read returns less than
  1k of data, some of the already buffered input lines that could have
  been decoded and returned were retained internally for a retry by the
  caller.  This is somewhat surprising, and the new code decodes as many
  of the buffered lines as possible.  Issue reported by Michał Trojnara.

- After all valid data has been read, the next BIO_read(3) should
  return 0 when the input was all valid or -1 if an error was detected.
  This now occurs in more consistently, but further tests and code
  refactoring may be needed to ensure this always happens.

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

11 months agofix: ossl_digest_get_approved_nid() returns NID_undef on invalid digest
Richard Levitte [Wed, 28 Aug 2024 14:36:31 +0000 (16:36 +0200)] 
fix: ossl_digest_get_approved_nid() returns NID_undef on invalid digest

We checked using 'md_nid < 0', which is faulty.

Impact: DSA and ECDSA signature provider implementations

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

11 months agoRefactor OpenSSL 'ECDSA' EVP_SIGNATURE to also include ECDSA+hash composites
Richard Levitte [Wed, 24 Jul 2024 20:07:32 +0000 (22:07 +0200)] 
Refactor OpenSSL 'ECDSA' EVP_SIGNATURE to also include ECDSA+hash composites

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

11 months agoRefactor OpenSSL 'DSA' EVP_SIGNATURE to also include DSA+hash composites
Richard Levitte [Wed, 24 Jul 2024 13:37:08 +0000 (15:37 +0200)] 
Refactor OpenSSL 'DSA' EVP_SIGNATURE to also include DSA+hash composites

(in the code, "sigalg" is used to refer to these composite algorithms,
which is a nod to libcrypto and libssl, where that term is commonly used
for composite algorithms)

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

11 months agoendecode_test.c: Fix !fips v3.0.0 check
Pauli [Fri, 30 Aug 2024 01:43:29 +0000 (11:43 +1000)] 
endecode_test.c: Fix !fips v3.0.0 check

The fips_provider_version_* functions return true if the FIPS provider isn't
loaded.  This is somewhat counterintuitive and the fix in #25327 neglected
this nuance resulting in not running the SM2 tests when the FIPS provider
wasn't being loaded.

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

11 months agoexporters for pkg-config: align with the changes for CMake
Richard Levitte [Wed, 28 Aug 2024 16:52:39 +0000 (18:52 +0200)] 
exporters for pkg-config: align with the changes for CMake

The latest CMake exporter changes reworked the the variables in builddata.pm
and installdata.pm.  Unfortunately, the pkg-config exporter templates were
forgotten in that effort.

Fixes #25299

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

11 months agoendecode_test.c: Avoid running the SM2 tests with 3.0.0 FIPS provider
Tomas Mraz [Thu, 29 Aug 2024 16:42:14 +0000 (18:42 +0200)] 
endecode_test.c: Avoid running the SM2 tests with 3.0.0 FIPS provider

Fixes #25326

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25327)

11 months agoCheck for excess data in CertificateVerify
Viktor Dukhovni [Wed, 28 Aug 2024 10:36:09 +0000 (20:36 +1000)] 
Check for excess data in CertificateVerify

As reported by Alicja Kario, we ignored excess bytes after the
signature payload in TLS CertificateVerify Messages.  These
should not be present.

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

11 months agos390x: support CPACF sha3/shake performance improvements
Joerg Schmidbauer [Thu, 29 Feb 2024 11:50:05 +0000 (12:50 +0100)] 
s390x: support CPACF sha3/shake performance improvements

On newer machines the SHA3/SHAKE performance of CPACF instructions KIMD and KLMD
can be enhanced by using additional modifier bits. This allows the application
to omit initializing the ICV, but also affects the internal processing of the
instructions. Performance is mostly gained when processing short messages.

The new CPACF feature is backwards compatible with older machines, i.e. the new
modifier bits are ignored on older machines. However, to save the ICV
initialization, the application must detect the MSA level and omit the ICV
initialization only if this feature is supported.

Signed-off-by: Joerg Schmidbauer <jschmidb@de.ibm.com>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25235)

11 months agodoc: Document properties param for Argon2 KDF
Clemens Lang [Wed, 28 Aug 2024 15:18:03 +0000 (17:18 +0200)] 
doc: Document properties param for Argon2 KDF

The Argon2 KDF uses OSSL_KDF_PARAM_PROPERTIES to fetch implementations
of blake2bmac and blake2b512 if ctx->mac and ctx->md are NULL. This
isn't documented in the manpage, so users that might, for example, want
to fetch an instance of Argon2 with the -fips property query to obtain
a working Argon2 KDF even though the default property query requires
fips=yes are left wondering why this fails.

Fortunately, EVP_KDF(3)/PARAMETERS already explains what the properties
are used for, so we really just need to add a single line.

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

11 months agoRefactor and Enhance Compression Field Testing
erbsland-dev [Sun, 25 Aug 2024 10:08:36 +0000 (12:08 +0200)] 
Refactor and Enhance Compression Field Testing

Fixes #7940: Enhances the existing test for compression methods in the ClientHello message, aligning with RFC 8446 specifications.

Refactored the test code to improve modularity and maintainability, making it easier to extend and modify in the future.

Added checks for the appropriate alerts, ensuring that `SSL_AD_ILLEGAL_PARAMETER` or `SSL_AD_DECODE_ERROR` are correctly triggered as per the RFC 8446 guidelines.

Expanded Test Coverage: Introduced additional test cases to cover scenarios involving:
- Lists of unknown compression methods
- Absence of any compression method
- Validation of a single null compression method, which should always succeed.

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

11 months agoCorrect Alert Handling for Missing Compression Methods
erbsland-dev [Wed, 21 Aug 2024 16:18:58 +0000 (18:18 +0200)] 
Correct Alert Handling for Missing Compression Methods

Fixes #7940: Updated the compression check logic to improve protocol compliance. The code now returns `SSL_AD_DECODE_ERROR` when no compression method is provided in the ClientHello message. It returns `SSL_AD_ILLEGAL_PARAMETER` if the “null” compression method (0x00) is missing.

Additionally, refactored the related test code for enhanced readability and maintainability.

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

11 months agoAdd ED25519 and ED448 support for EVP_PKEY_{sign,verify}_init_ex2()
Richard Levitte [Wed, 24 Jul 2024 05:25:57 +0000 (07:25 +0200)] 
Add ED25519 and ED448 support for EVP_PKEY_{sign,verify}_init_ex2()

In this mode, only the ph instances are supported, and must be set
explicitly through a parameter.  The caller is assumed to pass a
prehash to EVP_PKEY_{sign,verify}().

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

11 months agoRefactor OpenSSL 'EdDSA' EVP_SIGNATURE to allow use with EVP_PKEY functions
Richard Levitte [Fri, 2 Feb 2024 07:20:06 +0000 (08:20 +0100)] 
Refactor OpenSSL 'EdDSA' EVP_SIGNATURE to allow use with EVP_PKEY functions

Add EVP_PKEY_{sign,verify}_message support for our Ed25519 and Ed448
implementations, including ph and ctx variants.

Tests are added with test_evp stanzas.

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

11 months agoFix compile err when building VC-CLANG-WIN64-CLANGASM-ARM target
Zhiqing Xie [Thu, 25 Jul 2024 02:25:01 +0000 (10:25 +0800)] 
Fix compile err when building VC-CLANG-WIN64-CLANGASM-ARM target

The error happens with MSVC v143,C++ Clang Compiler for Windows(16.0.5)

Error is "brackets expression not supported on this target" in libcrypto-shlib-bsaes-armv8.obj.asm

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

11 months agoFix decoder error on SM2 private key
Jamie Cui [Thu, 22 Aug 2024 03:41:50 +0000 (11:41 +0800)] 
Fix decoder error on SM2 private key

Added sm2 testcases to endecode_test.c.

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

11 months agoEVP_MD_size() updates
slontis [Mon, 26 Aug 2024 01:24:24 +0000 (11:24 +1000)] 
EVP_MD_size() updates

For SHAKE algorithms we now return 0 from EVP_MD_size().
So all the places that check for < 0 needed to change to <= 0
(Otherwise the behaviour will be to digest nothing in most cases).

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

11 months agoUpdate code to use EVP_MD_xof()
slontis [Mon, 26 Aug 2024 01:14:55 +0000 (11:14 +1000)] 
Update code to use EVP_MD_xof()

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

11 months agoXOF / EVP_MD_size() changes.
slontis [Sun, 25 Aug 2024 23:38:56 +0000 (09:38 +1000)] 
XOF / EVP_MD_size() changes.

Added the function EVP_MD_CTX_get_size_ex() which checks for XOF and
does a ctx get rather than just returning EVP_MD_size().
SHAKE did not have a get_ctx_params() so that had to be added to return the xoflen.

Added a helper function EVP_MD_xof()
EVP_MD_CTX_size() was just an aliased macro for EVP_MD_size(), so to
keep it the same I added an extra function.

EVP_MD_size() always returns 0 for SHAKE now, since it caches the value
of md_size at the time of an EVP_MD_fetch(). This is probably better
than returning the incorrect initial value it was before e.g (16 for
SHAKE128) and returning tht always instead of the set xoflen.

Note BLAKE2B uses "size" instead of "xoflen" to do a similar thing.

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

11 months agoRSA decoder should check also sanity of p, q, e, d ... with respect to n
sashan [Wed, 14 Aug 2024 18:07:29 +0000 (20:07 +0200)] 
RSA decoder should check also sanity of p, q, e, d ... with respect to n

This issue has been discovered by osss-fuzzer [1]. The test function decodes
RSA key created by fuzzer and calls EVP_PKEY_pairwise_check() which
proceeds to ossl_bn_miller_rabin_is_prime() check which takes too long
exceeding timeout (45secs).

The idea is to fix OSSL_DECODER_from_data() code path so invalid
RSA keys will be refused.

[1] https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=69134

Test case generated by the fuzzer is added.

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

11 months agoCleanups for FIPS options..
slontis [Mon, 12 Aug 2024 09:31:10 +0000 (19:31 +1000)] 
Cleanups for FIPS options..

The options in fipsprov.c are now generated using macros with fips_indicator_params.inc.
This should keep the naming consistent.

Some FIPS related headers have moved to providers/fips/include so that
they can use fips_indicator_params.inc.
securitycheck.h now includes fipsindicator.h, and fipsindicator.h includes
fipscommon.h.

fipsinstall.c uses OSSL_PROV_PARAM_ for the configurable FIPS options rather than
using OSSL_PROV_FIPS_PARAM_* as this was confusing as to which one should be used.
fips_names.h just uses aliases now for existing public names.

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

11 months agofix: for exporters to work for build config, there may be two include dirs
Richard Levitte [Wed, 17 Jul 2024 16:23:57 +0000 (18:23 +0200)] 
fix: for exporters to work for build config, there may be two include dirs

For CMake / pkg-config configuration files to be used for an uninstalled
build, the include directory in the build directory isn't enough, if that
one is separate from the source directory.  The include directory in the
source directory must be accounted for too.

This includes some lighter refactoring of util/mkinstallvars.pl, with the
result that almost all variables in builddata.pm and installdata.pm have
become arrays, even though unnecessarily for most of them; it was simpler
that way.  The CMake / pkg-config templates are adapted accordingly.

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

11 months agofix: exporters/cmake/OpenSSLConfig.cmake.in to work for build config
Richard Levitte [Wed, 17 Jul 2024 09:09:11 +0000 (11:09 +0200)] 
fix: exporters/cmake/OpenSSLConfig.cmake.in to work for build config

This template file is made to make both:

1. OpenSSLConfig.cmake (CMake config used when building a CMake package
   against an uninstalled OpenSSL build)
2. exporters/OpenSSLConfig.cmake (CMake config that's to be installed
   alongside OpenSSL, and is used when building a CMake package against
   an OpenSSL installation).

Variant 1 was unfortunately getting the internal '_ossl_prefix' variable
wrong, which is due to how the perl snippet builds the command(s) to figure
out its value.  That needed some correction.

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

11 months agotest: issuedOnBehalfOf X.509v3 extension
Jonathan M. Wilbur [Tue, 20 Aug 2024 23:27:43 +0000 (23:27 +0000)] 
test: issuedOnBehalfOf X.509v3 extension

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

11 months agofeat: add support for issuedOnBehalfOf X.509v3 extension
Jonathan M. Wilbur [Tue, 20 Aug 2024 23:24:01 +0000 (23:24 +0000)] 
feat: add support for issuedOnBehalfOf X.509v3 extension

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

11 months agofix coding style
Richard Levitte [Wed, 21 Aug 2024 09:10:00 +0000 (11:10 +0200)] 
fix coding style

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

11 months agodoc: Document EVP_{TYPE}_CTX_get_algor etc
Richard Levitte [Thu, 25 Jul 2024 14:55:08 +0000 (16:55 +0200)] 
doc: Document EVP_{TYPE}_CTX_get_algor etc

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

11 months agofeat: Implement EVP_PKEY_CTX_{set,get}_algor_params() and EVP_PKEY_CTX_get_algor()
Richard Levitte [Thu, 25 Jul 2024 11:30:28 +0000 (13:30 +0200)] 
feat: Implement EVP_PKEY_CTX_{set,get}_algor_params() and EVP_PKEY_CTX_get_algor()

This should be sufficient to cover the intent with the following legacy ctrls:

- EVP_PKEY_CTRL_PKCS7_ENCRYPT (through EVP_ASYM_CIPHER implementations)
- EVP_PKEY_CTRL_PKCS7_DECRYPT (through EVP_ASYM_CIPHER implementations)
- EVP_PKEY_CTRL_PKCS7_SIGN (through EVP_SIGNATURE implementations)
- EVP_PKEY_CTRL_CMS_ENCRYPT (through EVP_ASYM_CIPHER implementations)
- EVP_PKEY_CTRL_CMS_DECRYPT (through EVP_ASYM_CIPHER implementations)
- EVP_PKEY_CTRL_CMS_SIGN (through EVP_SIGNATURE implementations)

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

11 months agofeat: Implement EVP_CIPHER_CTX_{set,get}_algor_params() and EVP_CIPHER_CTX_get_algor()
Richard Levitte [Thu, 25 Jul 2024 10:34:06 +0000 (12:34 +0200)] 
feat: Implement EVP_CIPHER_CTX_{set,get}_algor_params() and EVP_CIPHER_CTX_get_algor()

EVP_CIPHER_CTX_set_algor_params() and EVP_CIPHER_CTX_set_algor_params() can
be used instead of EVP_CIPHER_asn1_to_param() and EVP_CIPHER_param_to_asn1().

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

11 months agofix: in RC2 implementation, handle both old and new AID.params keys
Richard Levitte [Thu, 25 Jul 2024 10:18:24 +0000 (12:18 +0200)] 
fix: in RC2 implementation, handle both old and new AID.params keys

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

11 months agoAmend the design of AlgorithmIdentifier parameter passing
Richard Levitte [Thu, 25 Jul 2024 09:56:13 +0000 (11:56 +0200)] 
Amend the design of AlgorithmIdentifier parameter passing

I realised that any application that passes AlgorithmIdentifier parameters
to and from a provider may also be interested in the full AlgorithmIdentifier
of the implementation invocation.

Likewise, any application that wants to get the full AlgorithmIdentifier
from an implementation invocation may also want to pass AlgorithmIdentifier
parameters to that same implementation invocation.

These amendments should be useful to cover all intended uses of the legacy
ctrls for PKCS7 and CMS:

- EVP_PKEY_CTRL_PKCS7_ENCRYPT
- EVP_PKEY_CTRL_PKCS7_DECRYPT
- EVP_PKEY_CTRL_PKCS7_SIGN
- EVP_PKEY_CTRL_CMS_ENCRYPT
- EVP_PKEY_CTRL_CMS_DECRYPT
- EVP_PKEY_CTRL_CMS_SIGN

It should also cover a number of other cases that were previously implemented
through EVP_PKEY_ASN1_METHOD, as well as all sorts of other cases where the
application has had to assemble a X509_ALGOR on their own.

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

11 months agoReturn SSL_AD_UNEXPECTED_MESSAGE alert when receiving any other change_cipher_spec... 24998/head
cx [Wed, 21 Aug 2024 18:13:01 +0000 (02:13 +0800)] 
Return SSL_AD_UNEXPECTED_MESSAGE alert when receiving any other change_cipher_spec value(RFC 8446)
Fixes: #25086
CLA: trivial

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

11 months agofix: alias auditEntity OID
Jonathan M. Wilbur [Thu, 1 Aug 2024 17:45:54 +0000 (17:45 +0000)] 
fix: alias auditEntity OID

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

11 months agotest: auditIdentity X.509v3 extension decoding and display
Jonathan M. Wilbur [Thu, 27 Jun 2024 20:30:06 +0000 (20:30 +0000)] 
test: auditIdentity X.509v3 extension decoding and display

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

11 months agofeat: support auditIdentity X.509v3 extension
Jonathan M. Wilbur [Thu, 27 Jun 2024 20:29:49 +0000 (20:29 +0000)] 
feat: support auditIdentity X.509v3 extension

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

11 months agofix: wrong name for OID -> auditIdentity
Jonathan M. Wilbur [Thu, 27 Jun 2024 20:29:26 +0000 (20:29 +0000)] 
fix: wrong name for OID -> auditIdentity

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

11 months agoCleanups for FIPS indicator documentation
slontis [Thu, 15 Aug 2024 06:20:26 +0000 (16:20 +1000)] 
Cleanups for FIPS indicator documentation

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

11 months agoAdd FIPS indicator documentation
slontis [Thu, 15 Aug 2024 06:18:56 +0000 (16:18 +1000)] 
Add FIPS indicator documentation

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

11 months agoAdd FIPS indicators to X25519 and X448.
slontis [Wed, 21 Aug 2024 07:43:19 +0000 (17:43 +1000)] 
Add FIPS indicators to X25519 and X448.
X25519 and X448 are unapproved in FIPS 140-3
So always trigger the indicator callback if these Keys are used,
and add "fips-indicator" getters that return 0.

This has been added to keygen and key exchange.
(KEM will also require it if ever becomes a FIPS algorithm).

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

11 months agoUpdate new FIPS indicator evp_tests to use FIPSversion + Availablein options.
slontis [Thu, 22 Aug 2024 04:11:13 +0000 (14:11 +1000)] 
Update new FIPS indicator evp_tests to use FIPSversion + Availablein options.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25267)

11 months agoRevert evp_test change that made "FIPSversion" skip the default provider.
slontis [Thu, 22 Aug 2024 04:07:33 +0000 (14:07 +1000)] 
Revert evp_test change that made "FIPSversion" skip the default provider.

Fixes #25199
This should be done using "Availablein" if required.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25267)

11 months agoFIPS: Add EDDSA public key validation.
slontis [Thu, 22 Aug 2024 01:50:17 +0000 (11:50 +1000)] 
FIPS: Add EDDSA public key validation.

EVP_PKEY_public_check() can be used by ED25519 and ED448 in order to
determine if the public key is a valid point on the curve.

The FIPS ACVP tests require public key validation tests.
See https://github.com/usnistgov/ACVP-Server/blob/master/gen-val/json-files/EDDSA-KeyVer-1.0/internalProjection.json

Note that this is NOT required to be called before EDDSA signature verification
since it is done internally.

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

11 months agoUpdate FIPS 140-3 self tests
slontis [Mon, 19 Aug 2024 02:01:53 +0000 (12:01 +1000)] 
Update FIPS 140-3 self tests

Cleanup + remove a few tests that are not required.

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

11 months agoFIPS: Change fips tests to use SHA2 for corruption test.
slontis [Wed, 21 Aug 2024 23:09:14 +0000 (09:09 +1000)] 
FIPS: Change fips tests to use SHA2 for corruption test.

Fixes cross testing with OpenSSL 3.4 with removed SHA1 from the self
tests.

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

11 months agos390x: Fix memory leak in s390x_HMAC_CTX_copy()
Ingo Franzki [Tue, 20 Aug 2024 09:35:20 +0000 (11:35 +0200)] 
s390x: Fix memory leak in s390x_HMAC_CTX_copy()

When s390x_HMAC_CTX_copy() is called, but the destination context already
has a buffer allocated, it is not freed before duplicating the buffer from
the source context.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/25238)

11 months agoacvptest: add positive and negative tests for verify message param
Pauli [Mon, 19 Aug 2024 01:34:12 +0000 (11:34 +1000)] 
acvptest: add positive and negative tests for verify message param

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

11 months agorsa: add verify_message param support
Pauli [Mon, 19 Aug 2024 00:40:24 +0000 (10:40 +1000)] 
rsa: add verify_message param support

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

11 months agoecdsa: add verify_message param support
Pauli [Mon, 19 Aug 2024 00:40:14 +0000 (10:40 +1000)] 
ecdsa: add verify_message param support

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

11 months agoparam: add OSSL_SIGNATURE_PARAM_FIPS_VERIFY_MESSAGE parameter name
Pauli [Fri, 16 Aug 2024 00:24:05 +0000 (10:24 +1000)] 
param: add OSSL_SIGNATURE_PARAM_FIPS_VERIFY_MESSAGE parameter name

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

11 months agodoc: document the OSSL_SIGNATURE_PARAM_FIPS_VERIFY_MESSAGE parameter
Pauli [Fri, 16 Aug 2024 00:21:12 +0000 (10:21 +1000)] 
doc: document the OSSL_SIGNATURE_PARAM_FIPS_VERIFY_MESSAGE parameter

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

11 months agofuzz/hashtable.c: rc == -1 on insert is OK when fuzzing
Tomas Mraz [Thu, 22 Aug 2024 12:49:05 +0000 (14:49 +0200)] 
fuzz/hashtable.c: rc == -1 on insert is OK when fuzzing

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

11 months agoossl_ht_insert(): Allow for 4 iterations of grow_hashtable()
Tomas Mraz [Thu, 22 Aug 2024 12:44:02 +0000 (14:44 +0200)] 
ossl_ht_insert(): Allow for 4 iterations of grow_hashtable()

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

11 months agoReplace PKCS#1 v1.5 padding in RSA PCT
Joachim Vandersmissen [Fri, 15 Mar 2024 16:34:12 +0000 (11:34 -0500)] 
Replace PKCS#1 v1.5 padding in RSA PCT

After December 31, 2023, SP 800-131Ar2 [0] no longer allows PKCS#1 v1.5
padding for RSA "key-transport" (aka encryption and decryption).
There's a few good options to replace this usage in the RSA PCT, but
the simplest is verifying m = (m^e)^d mod n, (where 1 < m < (n − 1)).
This is specified in SP 800-56Br2 (Section 6.4.1.1) [1] and allowed by
FIPS 140-3 IG 10.3.A. In OpenSSL, this corresponds to RSA_NO_PADDING.

[0]: https://doi.org/10.6028/NIST.SP.800-131Ar2
[1]: https://doi.org/10.6028/NIST.SP.800-56Br2

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

11 months agoReplace PKCS#1 v1.5 encryption in RSA PCT
Joachim Vandersmissen [Thu, 14 Mar 2024 00:26:21 +0000 (19:26 -0500)] 
Replace PKCS#1 v1.5 encryption in RSA PCT

After December 31, 2023, SP 800-131Ar2 [0] no longer allows PKCS#1 v1.5
padding for RSA "key-transport" (aka encryption and decryption).
There's a few good options to replace this usage in the RSA PCT, but
signature generation and verification using PKCS#1 v1.5 padding (which
remains approved) is the simplest.

[0]: https://doi.org/10.6028/NIST.SP.800-131Ar2

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

11 months agoFix error handling in OBJ_add_object
Bernd Edlinger [Fri, 27 Oct 2023 10:05:05 +0000 (12:05 +0200)] 
Fix error handling in OBJ_add_object

This fixes the possible memory leak in OBJ_add_object
when a pre-existing object is replaced by a new one,
with identical NID, OID, and/or short/long name.
We do not try to delete any orphans, but only mark
them as type == -1, because the previously returned
pointers from OBJ_nid2obj/OBJ_nid2sn/OBJ_nid2ln
may be cached by applications and can thus not
be cleaned up before the application terminates.

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

11 months agox_attrib: fix a memory leak
Beat Bolli [Thu, 15 Aug 2024 10:35:02 +0000 (12:35 +0200)] 
x_attrib: fix a memory leak

The X509_NAME object needs to be free'd even if printing it fails.

Introduced in be5adfd6e3 ("Support subjectDirectoryAttributes and
associatedInformation exts", 2024-06-18), but subsequently moved in
7bcfb41489 ("ossl_print_attribute_value(): use a sequence value only if
type is a sequence", 2024-08-05).

Signed-off-by: Beat Bolli <dev@drbeat.li>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25207)

11 months agoAdd Changes entry for debuginfo generation
Neil Horman [Thu, 15 Aug 2024 12:29:34 +0000 (08:29 -0400)] 
Add Changes entry for debuginfo generation

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

11 months agoAdd a test for debuginfo generation
Neil Horman [Wed, 14 Aug 2024 15:18:04 +0000 (11:18 -0400)] 
Add a test for debuginfo generation

Add a check to ensure debug info generation works.

We piggyback on a test that already builds DWARF symbols (--debug)
The test
1) makes the debuginfo files
2) runs gdb, loading the libcrypto.so.3 file
3) Check to make sure that the output of gdb indicates that it loads the
   .debug file base on the reference in the loaded file

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

11 months agoAdd debuginfo build target
Neil Horman [Tue, 13 Aug 2024 19:16:08 +0000 (15:16 -0400)] 
Add debuginfo build target

In the webinar we are currently producing on debugging openssl
applications, we talk about ways to allow debugable binaries without
having to ship all the debug DWARF information to production systems.

Add an optional target to do that DWARF separation to aid users

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

11 months agotest/provider_test.c: Add OSSL_PROVIDER_unload() to avoid memory leak
Jiasheng Jiang [Tue, 6 Aug 2024 19:18:34 +0000 (19:18 +0000)] 
test/provider_test.c: Add OSSL_PROVIDER_unload() to avoid memory leak

Add OSSL_PROVIDER_unload() when OSSL_PROVIDER_add_builtin() fails to avoid memory leak.

Fixes: 5442611dff ("Add a test for OSSL_LIB_CTX_new_child()")
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@outlook.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25109)

11 months agotest/provider_fallback_test.c: Add OSSL_PROVIDER_unload() to avoid memory leak
Jiasheng Jiang [Tue, 6 Aug 2024 18:42:06 +0000 (18:42 +0000)] 
test/provider_fallback_test.c: Add OSSL_PROVIDER_unload() to avoid memory leak

Add OSSL_PROVIDER_unload() when test_provider() fails to avoid memory leak.

Fixes: f995e5bdcd ("TEST: Add provider_fallback_test, to test aspects of
fallback providers")
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@outlook.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25108)

11 months agoFix the alert used on a missing key_share
Matt Caswell [Wed, 31 Jul 2024 14:25:48 +0000 (15:25 +0100)] 
Fix the alert used on a missing key_share

RFC8446 requires we send an illegal_parameter alert if we don't get a
key_share back from the server and our kex_modes require one. We were
instead reporting this as missing_extension.

Fixes #25040

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

11 months agoAdd additional test cases for Single Step KDF.
slontis [Wed, 7 Aug 2024 00:58:10 +0000 (10:58 +1000)] 
Add additional test cases for Single Step KDF.

SSKDF KMAC tests added.
Added FIPS indicator tests for SSKDF Hash, HMAC, and KMAC cases.
Added short salt length tests for SSKDF HMAC and KMAC.

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

11 months agoAdd FIPS KMAC key check
slontis [Mon, 5 Aug 2024 05:25:35 +0000 (15:25 +1000)] 
Add FIPS KMAC key check

This adds a FIPS indicator for KMAC key size.
Note that 112 bits keys are still smaller than the
sizes required to reach 128 bits for KMAC128 and
256 bits for KMAC256

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

11 months agoAdd HMAC FIPS keysize check.
slontis [Wed, 31 Jul 2024 04:56:44 +0000 (14:56 +1000)] 
Add HMAC FIPS keysize check.

HMAC has been changed to use a FIPS indicator for its key check.

HKDF and Single Step use a salt rather than a key when using HMAC,
so we need a mechanism to bypass this check in HMAC.

A seperate 'internal' query table has been added to the FIPS provider
for MACS. Giving HMAC a seprate dispatch table allows KDF's to ignore
the key check. If a KDF requires the key check then it must do the
check itself. The normal MAC dipatch table is used if the user fetches
HMAC directly.

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

11 months agohashtable.c: Code style fixes
Tomas Mraz [Fri, 16 Aug 2024 14:27:17 +0000 (16:27 +0200)] 
hashtable.c: Code style fixes

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/24504)

11 months agocore_namemap.c: 2048 hashtable buckets should be sufficient
Tomas Mraz [Fri, 16 Aug 2024 13:54:15 +0000 (15:54 +0200)] 
core_namemap.c: 2048 hashtable buckets should be sufficient

It is unlikely we would need more than 4000 names and even
with more names (up to 8192) it would still work, just
the performance fo the namemap would degrade.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/24504)

11 months agoFor lockless reads use the whole hashtable for colliding entries
Tomas Mraz [Fri, 16 Aug 2024 13:40:43 +0000 (15:40 +0200)] 
For lockless reads use the whole hashtable for colliding entries

Instead of just using the neighborhood, fill
subsequent neighborhoods with colliding entries.

If the hashtable is properly sized, it won't degrade
performance too much.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/24504)

11 months agoUse the new hashtable for core_namemap
Tomas Mraz [Mon, 27 May 2024 14:50:05 +0000 (16:50 +0200)] 
Use the new hashtable for core_namemap

This replaces LHASH in core_namemap with the new hashtable and adds
a reverse mapping in form of stack of stacks instead of iterating
the existing hash table members.

The new hashtable is used in lockless-read mode.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/24504)

11 months agohashtable: Support lockless reads
Tomas Mraz [Mon, 27 May 2024 14:49:15 +0000 (16:49 +0200)] 
hashtable: Support lockless reads

Also build it in the FIPS provider too and properly
report error on insert when hashtable cannot be grown.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/24504)

11 months agohashtable.c: Avoid infinite loop in ossl_ht_insert()
Tomas Mraz [Fri, 17 May 2024 11:41:09 +0000 (13:41 +0200)] 
hashtable.c: Avoid infinite loop in ossl_ht_insert()

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/24504)

11 months agosome performance improvements
Neil Horman [Wed, 15 May 2024 19:34:15 +0000 (15:34 -0400)] 
some performance improvements

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

11 months agoalternate collision checking support
Neil Horman [Wed, 15 May 2024 13:20:30 +0000 (09:20 -0400)] 
alternate collision checking support

Add full key matching to hashtable

the idea is that on a hash value match we do a full memory comparison of
the unhashed key to validate that its actually the key we're looking for

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

11 months agofix: Have util/mkerr.pl comply better with our coding style
Richard Levitte [Tue, 16 Jul 2024 04:52:07 +0000 (06:52 +0200)] 
fix: Have util/mkerr.pl comply better with our coding style

util/mkerr.pl produced lines like these:

    {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE),
    "operation not supported for this keytype"},

According to our coding style, they should look like this:

    {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE),
     "operation not supported for this keytype"},

This nit was correctly picked up by util/check-format.pl

Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24902)

11 months agoEnable RSA-SM3 in the default provider
Richard Levitte [Mon, 19 Aug 2024 06:38:56 +0000 (08:38 +0200)] 
Enable RSA-SM3 in the default provider

It turns out that we didn't allow the combination RSA + SM3 anywhere.

This is perfectly reasonable in the FIPS module, but less so in the default
provider.  This change enables it in the default provider, and adds a simple
evp_test stanza for the RSA-SM3 signature scheme.

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

11 months agofix coding style
Richard Levitte [Tue, 16 Jul 2024 05:06:05 +0000 (07:06 +0200)] 
fix coding style

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

11 months agoAdd new test types in test/evp_test.c, and a test for RSA sigalgs
Richard Levitte [Wed, 10 Jul 2024 19:26:30 +0000 (21:26 +0200)] 
Add new test types in test/evp_test.c, and a test for RSA sigalgs

With these tests, we get to test:

- EVP_PKEY_sign_init_ex()
- EVP_PKEY_verify_init_ex2()
- EVP_PKEY_verify_recover_init_ex2()
- EVP_PKEY_sign_message_init() and friends
- EVP_PKEY_verify_message_init() and friends

A few test cases for RSA-{hash} are added, in
test/recipes/30-test_evp_data/evppkey_rsa_sigalg.txt

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

11 months agoRefactor OpenSSL 'RSA' EVP_SIGNATURE to also include RSA+hash composites
Richard Levitte [Sat, 6 Jul 2024 14:26:39 +0000 (16:26 +0200)] 
Refactor OpenSSL 'RSA' EVP_SIGNATURE to also include RSA+hash composites

(in the code, "sigalg" is used to refer to these composite algorithms,
which is a nod to libcrypto and libssl, where that term is commonly used
for composite algorithms)

To make this implementation possible, wrappers were added around the hash
function itself, allowing the use of existing hash implementations through
their respective OSSL_DISPATCH tables, but also retaining the dynamic fetch
of hash implementations when the digest_sign / digest_verify functionality
is used.  This wrapper allows implementing the RSA+hash composites through
simple initializer function and a custom OSSL_DISPATCH table for each.

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

11 months agoImplement functionality for direct use of composite signature algorithms
Richard Levitte [Thu, 18 Jan 2024 14:27:34 +0000 (15:27 +0100)] 
Implement functionality for direct use of composite signature algorithms

The following API groups are extended with a new init function, as well
as an update and final function, to allow the use of explicitly fetched
signature implementations for any composite signature algorithm, like
"sha1WithRSAEncryption":

- EVP_PKEY_sign
- EVP_PKEY_verify
- EVP_PKEY_verify_recover

To support this, providers are required to add a few new functions, not
the least one that declares what key types an signature implementation
supports.

While at this, the validity check in evp_signature_from_algorithm() is
also refactored; the SIGNATURE provider functionality is too complex for
counters.  It's better, or at least more readable, to check function
combinations.

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

11 months agoLink to the place where signature options are defined
Hubert Kario [Fri, 26 Jul 2024 14:25:42 +0000 (16:25 +0200)] 
Link to the place where signature options are defined

ca man page: link to section

Signed-off-by: Hubert Kario <hkario@redhat.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25011)

11 months agoWhen calling ASN1_item_i2d () check both returned length and allocated pointer
XZ-X [Mon, 22 Jul 2024 18:33:02 +0000 (14:33 -0400)] 
When calling ASN1_item_i2d () check both returned length and allocated pointer

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

11 months agoEnhance s_client Output
erbsland-dev [Wed, 17 Jul 2024 21:21:42 +0000 (23:21 +0200)] 
Enhance s_client Output

Fixes #8123: Clarify cipher and protocol version display
- Added a new line “Protocol:” to display the protocol version separately after the cipher line.

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

11 months agotest: add command line indicator option checking to fipsinstall
Pauli [Thu, 15 Aug 2024 00:58:25 +0000 (10:58 +1000)] 
test: add command line indicator option checking to fipsinstall

Validate that the relevant options are on when -pedantic is specified,
off when it isn't and can be given to enable the setting.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/25194)

11 months agoAdd FIPS self test updates
slontis [Fri, 16 Aug 2024 09:10:22 +0000 (19:10 +1000)] 
Add FIPS self test updates

After reviewing the FIPS 140-3 IG self tests requirements the following
were added:

- TDES Decryption (Not sure why this was missing)
- DH changed to use ffdhe2048 instead of P,Q,G params.
- Signature code has been changed to use a msg rather than a digest as input.
(Since some digests dont provide the one shot API, the EVP_DigestSignFinal and
EVP_DigestVerifyFinal needed to be exposed to the FIPS provider). The
code is now shared between ED and the other key types.

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

11 months agotest/hmactest: Add further tests for HMAC with multiple update calls
Ingo Franzki [Fri, 2 Feb 2024 13:55:32 +0000 (14:55 +0100)] 
test/hmactest: Add further tests for HMAC with multiple update calls

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