openssl.git
2 years agotls_process_server_hello: Disallow repeated HRR
Tomas Mraz [Tue, 22 Mar 2022 11:34:07 +0000 (12:34 +0100)]
tls_process_server_hello: Disallow repeated HRR

Repeated HRR must be rejected.

Fixes #17934

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

2 years agosparse array: reduces the block size
Pauli [Mon, 28 Mar 2022 01:14:22 +0000 (12:14 +1100)]
sparse array: reduces the block size

This becomes a performance improvement in the ossl_sa_doall_arg function which
has started appearing on profile output.  The other ossl_sa_ functions don't
contribute significantly to profile output.

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

2 years agodocument the safe_div_round_up_TYPE functions
Pauli [Tue, 15 Mar 2022 03:35:30 +0000 (14:35 +1100)]
document the safe_div_round_up_TYPE functions

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

2 years agoUse safe math to computer sizes.
Pauli [Tue, 15 Mar 2022 03:28:07 +0000 (14:28 +1100)]
Use safe math to computer sizes.

The sizes are rounded via the expression: (cmpl + 7) / 8 which overflows if
cmpl is near to the type's maximum.  Instead we use the safe_math function to
computer this without any possibility of error.

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

2 years agoAdd a divide rounding up safe math function.
Pauli [Tue, 15 Mar 2022 03:19:07 +0000 (14:19 +1100)]
Add a divide rounding up safe math function.

This function takes arguments a & b and computes a / b rounding any
remainder up.

It is safe with respect to overflow and negative inputs.  It's only fast for
non-negative inputs.

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

2 years agoFix typo in manpage SSL_CONF_cmd(3)
Hugo Landau [Mon, 28 Mar 2022 11:10:06 +0000 (12:10 +0100)]
Fix typo in manpage SSL_CONF_cmd(3)

Fixes #17976.

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

2 years agoRemove statistics tracking from LHASH
Hugo Landau [Tue, 22 Mar 2022 10:59:36 +0000 (10:59 +0000)]
Remove statistics tracking from LHASH

Fixes #17928. Supercedes #17931.

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

2 years agoSize of random output is now a long, also added option to select chunk size
Kevin K Biju [Wed, 23 Mar 2022 05:10:50 +0000 (10:40 +0530)]
Size of random output is now a long, also added option to select chunk size

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

2 years agoFix Coverity 1503218: negative loop bound
Pauli [Thu, 24 Mar 2022 03:31:19 +0000 (14:31 +1100)]
Fix Coverity 1503218: negative loop bound

OPENSSL_sk_num returns an integer which can theoretically be negative.
Assigning this to a size_t and using it as a loop bound isn't ideal.

Rather than adding checked for NULL or negative returns, changing the loop
index and end to int is simpler.

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

2 years agoticket_lifetime_hint may exceed 1 week in TLSv1.3
Todd Short [Wed, 23 Mar 2022 22:55:10 +0000 (18:55 -0400)]
ticket_lifetime_hint may exceed 1 week in TLSv1.3

For TLSv1.3, limit ticket lifetime hint to 1 week per RFC8446

Fixes #17948

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

2 years agos390x: Hide internal cpuid symbol and function
Juergen Christ [Wed, 23 Mar 2022 12:26:13 +0000 (13:26 +0100)]
s390x: Hide internal cpuid symbol and function

The symbol OPENSSL_s390xcap_P and the OPENSSL_cpuid_setup function are not
exported by the version script of OpenSSL.  However, if someone uses the
static library without the version script, these symbols all of a sudden
become global symbols and their usage in assembler code does not correctly
reflect that for PIC.  Since these symbols should never be used outside of
OpenSSL, hide them inside the binary.

Signed-off-by: Juergen Christ <jchrist@linux.ibm.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17946)

2 years agoFix formatting of NOTES-WINDOWS.md and doc-nits failure
Tomas Mraz [Thu, 24 Mar 2022 15:18:33 +0000 (16:18 +0100)]
Fix formatting of NOTES-WINDOWS.md and doc-nits failure

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/17960)

2 years agoFix Coverity 1498612: integer overflow
Pauli [Wed, 16 Mar 2022 03:13:25 +0000 (14:13 +1100)]
Fix Coverity 1498612: integer overflow

The assert added cannot ever fail because (current & 0xFFFF) != 0 from the
while loop and the trailing zero bit count therefore cannot be as large as 32.

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

2 years agoAdd build note for win-arm64
Gabor Kertesz [Tue, 22 Mar 2022 17:13:22 +0000 (18:13 +0100)]
Add build note for win-arm64

Windows on Arm is not officially supported by release, but with
x86 emulated Perl it can be built locally.
This method is added to Windows notes.
Locally all tests are passed on win-arm64.

CLA: trivial

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

2 years agoAdd support for mac-less password-base PKCS12 files to PKCS12_parse API.
Daniel Fiala [Sun, 13 Mar 2022 05:56:13 +0000 (06:56 +0100)]
Add support for mac-less password-base PKCS12 files to PKCS12_parse API.

Fixes openssl#17720.

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

2 years agoDisable the test_afalg on cross compile targets
Tomas Mraz [Tue, 22 Mar 2022 15:43:47 +0000 (16:43 +0100)]
Disable the test_afalg on cross compile targets

The afalg engine does not work when run through qemu.

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

2 years agoDecoder resolution performance optimizations
Hugo Landau [Thu, 17 Mar 2022 17:29:22 +0000 (17:29 +0000)]
Decoder resolution performance optimizations

This refactors decoder functionality to reduce calls to
OSSL_DECODER_is_a / EVP_KEYMGMT_is_a, which are substantial bottlenecks
in the performance of repeated decode operations (see #15199).

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

2 years agoutil/markdownlint.rb: Allow fenced code blocks
Richard Levitte [Mon, 21 Mar 2022 15:23:09 +0000 (16:23 +0100)]
util/markdownlint.rb: Allow fenced code blocks

We use both indented and fenced styles in diverse markdown files.
We try to do this consistently in each file, though.

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

2 years agoFix Coverity 1201763 uninitialised pointer read
Pauli [Wed, 16 Mar 2022 02:48:27 +0000 (13:48 +1100)]
Fix Coverity 1201763 uninitialised pointer read

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

2 years agoFix Coverity 1498613: resource leak
Pauli [Wed, 16 Mar 2022 03:07:45 +0000 (14:07 +1100)]
Fix Coverity 1498613: resource leak

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

2 years agoFix Coverity 1498611 & 1498608: uninitialised read
Pauli [Wed, 16 Mar 2022 03:21:01 +0000 (14:21 +1100)]
Fix Coverity 1498611 & 1498608: uninitialised read

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

2 years agoFix Coverity 1498610 & 1498609: uninitised value
Pauli [Wed, 16 Mar 2022 03:36:57 +0000 (14:36 +1100)]
Fix Coverity 1498610 & 1498609: uninitised value

Both are false positives, but better to be rid of them forever than ignoring
them and having repeats.

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

2 years agoConfigure: don't try to be clever when configuring afalgeng
Ross Burton [Thu, 27 Jan 2022 11:56:56 +0000 (11:56 +0000)]
Configure: don't try to be clever when configuring afalgeng

If the afalgeng is enabled then Configure tries to be clever but fails,
by only actually building afalgeng if it isn't being cross-compiled and
if the current kernel is 4.1+.

This means that everyone cross compiling, or whose builder machines are
running older kernels (not uncommon for build farms), can't enable
afalgeng.

Instead remove the cleverness and simply enable/disable as requested.

Fixes #7687

CLA: trivial

Signed-off-by: Ross Burton <ross.burton@arm.com>
Change-Id: I023b6cb535d5b5811823d4814fa939de3f304886

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

2 years agoMake `openssl check -rsa ...` to work for both RSA and RSA-PSS.
Daniel Fiala [Wed, 16 Mar 2022 19:30:38 +0000 (20:30 +0100)]
Make `openssl check -rsa ...` to work for both RSA and RSA-PSS.

Fixes openssl#17167

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

(cherry picked from commit 5d1f357a01f668f708c1abd7567175b4a0f18a38)

2 years agoFix incorrect comments in aes-gcm-armv8-unroll8_64.pl
XiaokangQian [Mon, 14 Mar 2022 08:59:54 +0000 (08:59 +0000)]
Fix incorrect comments in aes-gcm-armv8-unroll8_64.pl

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

2 years agoAdd EVP RSA key encode/decode demo
Hugo Landau [Mon, 7 Mar 2022 15:12:07 +0000 (15:12 +0000)]
Add EVP RSA key encode/decode demo

Fixes #14116.

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

2 years agoFix coverity 1498607: uninitialised value
Pauli [Wed, 16 Mar 2022 03:45:44 +0000 (14:45 +1100)]
Fix coverity 1498607: uninitialised value

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

2 years agoOSSL_CMP_CTX_new.pod: make references to private key consistent with OSSL_CMP_MSG_get...
Dr. David von Oheimb [Tue, 15 Mar 2022 17:40:32 +0000 (18:40 +0100)]
OSSL_CMP_CTX_new.pod: make references to private key consistent with OSSL_CMP_MSG_get0_header.pod

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

2 years agoOSSL_CMP_MSG_get0_header.pod: re-phrase two lenthy otherwise clauses as lists
Dr. David von Oheimb [Tue, 15 Mar 2022 17:39:13 +0000 (18:39 +0100)]
OSSL_CMP_MSG_get0_header.pod: re-phrase two lenthy otherwise clauses as lists

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

2 years agoSSL_CTX_set_verify.pod: move a note further down where it fits better
Dr. David von Oheimb [Tue, 15 Mar 2022 12:26:23 +0000 (13:26 +0100)]
SSL_CTX_set_verify.pod: move a note further down where it fits better

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

2 years agoprint SSL session, fix build warnings on OpenBSD.
David Carlier [Wed, 16 Mar 2022 23:21:58 +0000 (23:21 +0000)]
print SSL session, fix build warnings on OpenBSD.

time_t is a 64 bits type on this platform.

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

2 years agoeng_dyn: Avoid spurious errors when checking for 1.1.x engine
Tomas Mraz [Wed, 16 Mar 2022 11:14:16 +0000 (12:14 +0100)]
eng_dyn: Avoid spurious errors when checking for 1.1.x engine

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

2 years agoFix documentation for provider-signature
Hugo Landau [Wed, 16 Mar 2022 16:40:14 +0000 (16:40 +0000)]
Fix documentation for provider-signature

Fixes #17909.

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

2 years agoFix declaration inconsistency (Camellia)
Hugo Landau [Wed, 16 Mar 2022 16:32:08 +0000 (16:32 +0000)]
Fix declaration inconsistency (Camellia)

Fixes #17911.

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

2 years agoList missing operations in provider(7)
Hugo Landau [Wed, 16 Mar 2022 17:00:32 +0000 (17:00 +0000)]
List missing operations in provider(7)

Fixes #17910.

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

2 years agoFix typos in CCM test vector titles
Tobias Nießen [Wed, 16 Mar 2022 00:33:46 +0000 (01:33 +0100)]
Fix typos in CCM test vector titles

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

2 years agocheck return value of functions that call BIO_new()
tangyiqun [Wed, 9 Mar 2022 10:06:41 +0000 (18:06 +0800)]
check return value of functions that call BIO_new()

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

2 years agoUpdate CHANGES/NEWS for new release
Matt Caswell [Mon, 14 Mar 2022 16:39:43 +0000 (16:39 +0000)]
Update CHANGES/NEWS for new release

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
2 years agoAdd a negative testcase for BN_mod_sqrt
Tomas Mraz [Mon, 28 Feb 2022 17:26:35 +0000 (18:26 +0100)]
Add a negative testcase for BN_mod_sqrt

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
2 years agoAdd documentation of BN_mod_sqrt()
Tomas Mraz [Mon, 28 Feb 2022 17:26:30 +0000 (18:26 +0100)]
Add documentation of BN_mod_sqrt()

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
2 years agoFix possible infinite loop in BN_mod_sqrt()
Tomas Mraz [Mon, 28 Feb 2022 17:26:21 +0000 (18:26 +0100)]
Fix possible infinite loop in BN_mod_sqrt()

The calculation in some cases does not finish for non-prime p.

This fixes CVE-2022-0778.

Based on patch by David Benjamin <davidben@google.com>.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
2 years agoFix signed integer overflow in evp_enc
Hugo Landau [Fri, 11 Mar 2022 06:57:26 +0000 (06:57 +0000)]
Fix signed integer overflow in evp_enc

Fixes #17869.

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

2 years agoFixed typo in inner_evp_generic_fetch() error handling
Oliver Roberts [Sat, 12 Mar 2022 14:39:01 +0000 (14:39 +0000)]
Fixed typo in inner_evp_generic_fetch() error handling

Fixes #17876

CLA: trivial

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

2 years agoFix IV length caching in EVP encryption code
Hugo Landau [Thu, 10 Mar 2022 12:42:05 +0000 (12:42 +0000)]
Fix IV length caching in EVP encryption code

The IV length cache value was being invalidated excessively, causing IV
length caching to be ineffective.

Related to #17064.

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

2 years agoaes-gcm-avx512.pl: Fixed mingw64 build
Andrey Matyukov [Thu, 10 Mar 2022 21:27:33 +0000 (14:27 -0700)]
aes-gcm-avx512.pl: Fixed mingw64 build

Decoration prefix for some assembler labels in aes-gcm-avx512.pl was
fixed for mingw64 build.

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

2 years agoAdd EVP demo for SIPHASH
Hugo Landau [Wed, 2 Mar 2022 07:38:15 +0000 (07:38 +0000)]
Add EVP demo for SIPHASH

Fixes #14121.

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

2 years agoFix bug in scrypt KDF provider dup method
Hugo Landau [Fri, 11 Mar 2022 14:02:39 +0000 (14:02 +0000)]
Fix bug in scrypt KDF provider dup method

The scrypt KDF provider's dup method calls kdf_scrypt_new passing a
libctx, but a provider context is expected. Since the provider context
is passed as void *, this was not caught.

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

2 years agoevp_test: Add testcases for DH KEX with X9.42 KDF
Tomas Mraz [Thu, 10 Mar 2022 17:41:30 +0000 (18:41 +0100)]
evp_test: Add testcases for DH KEX with X9.42 KDF

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/17859)

2 years agoFix documentation of parameters for DH and ECDH KEX
Tomas Mraz [Thu, 10 Mar 2022 12:13:40 +0000 (13:13 +0100)]
Fix documentation of parameters for DH and ECDH KEX

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/17859)

2 years agoDH: Make padding always on when X9.42 KDF is used
Tomas Mraz [Thu, 10 Mar 2022 12:11:21 +0000 (13:11 +0100)]
DH: Make padding always on when X9.42 KDF is used

Fixes #17834

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/17859)

2 years agoAdd manpages for SSL_get_certificate, SSL_get_private_key
Hugo Landau [Fri, 4 Mar 2022 12:53:50 +0000 (12:53 +0000)]
Add manpages for SSL_get_certificate, SSL_get_private_key

This is as I understand these functions from reading the code.

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

2 years agocrypto/pem/pem_lib.c: Add check for BIO_read
Jiasheng Jiang [Mon, 7 Mar 2022 09:51:25 +0000 (17:51 +0800)]
crypto/pem/pem_lib.c: Add check for BIO_read

As the potential failure of the BIO_read(),
it should be better to add the check and return
error if fails.
Also, in order to decrease the same code, using
'out_free' will be better.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17754)

2 years agoAdd EVP demo for RSA key generation
Hugo Landau [Mon, 7 Mar 2022 13:29:49 +0000 (13:29 +0000)]
Add EVP demo for RSA key generation

Fixes #14111.

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

2 years agoReplace handling of negative verification result with SSL_set_retry_verify()
Tomas Mraz [Mon, 7 Mar 2022 14:46:58 +0000 (15:46 +0100)]
Replace handling of negative verification result with SSL_set_retry_verify()

Provide a different mechanism to indicate that the application wants
to retry the verification. The negative result of the callback function
now indicates an error again.

Instead the SSL_set_retry_verify() can be called from the callback
to indicate that the handshake should be suspended.

Fixes #17568

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

2 years agoFixed conditional statement testing 64 and 256 bytes
Danny Tsen [Wed, 23 Feb 2022 19:18:35 +0000 (13:18 -0600)]
Fixed conditional statement testing 64 and 256 bytes

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

2 years agoEVP_MD performance fix (refcount cache contention)
Hugo Landau [Thu, 10 Mar 2022 09:38:09 +0000 (09:38 +0000)]
EVP_MD performance fix (refcount cache contention)

Partial fix for #17064. Avoid excessive writes to the cache line
containing the refcount for an EVP_MD object to avoid extreme
cache contention when using a single EVP_MD at high frequency on
multiple threads. This changes performance in 3.0 from being double
that of 1.1 to only slightly higher than that of 1.1.

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

2 years agoMake ossltest engine use in test/recipes/20-test_dgst.t platform agnostic
Richard Levitte [Thu, 10 Mar 2022 12:29:25 +0000 (13:29 +0100)]
Make ossltest engine use in test/recipes/20-test_dgst.t platform agnostic

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

2 years agoOSSL_CMP_CTX_setup_CRM(): Fix handling of defaults from CSR and refcert
Dr. David von Oheimb [Thu, 17 Feb 2022 18:40:29 +0000 (19:40 +0100)]
OSSL_CMP_CTX_setup_CRM(): Fix handling of defaults from CSR and refcert

Also update and complete related documentation.

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

2 years agoDOC: TLS compression is disabled by default
Todd Short [Wed, 9 Mar 2022 22:05:45 +0000 (17:05 -0500)]
DOC: TLS compression is disabled by default

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/17854)

2 years agoREADME: add missing link to OpenSSL 3.0 manual pages
Dr. Matthias St. Pierre [Wed, 9 Mar 2022 22:58:02 +0000 (23:58 +0100)]
README: add missing link to OpenSSL 3.0 manual pages

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

2 years agoAdd TFO support to socket BIO and s_client/s_server
Todd Short [Wed, 8 Sep 2021 20:23:04 +0000 (16:23 -0400)]
Add TFO support to socket BIO and s_client/s_server

Supports Linux, MacOS and FreeBSD
Disabled by default, enabled via `enabled-tfo`
Some tests

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

2 years agoDrop ariacbc demo binary
Tomas Mraz [Wed, 9 Mar 2022 08:48:42 +0000 (09:48 +0100)]
Drop ariacbc demo binary

Reviewed-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17848)

2 years agoAllow to *just* print key and IV of unstreamable modes when no input files
EasySec [Wed, 9 Mar 2022 00:00:19 +0000 (01:00 +0100)]
Allow to *just* print key and IV of unstreamable modes when no input files

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

2 years agocheck the return of OPENSSL_sk_new_null
xkernel [Tue, 8 Mar 2022 11:48:54 +0000 (19:48 +0800)]
check the return of OPENSSL_sk_new_null

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Patrick Steuer <patrick.steuer@de.ibm.com>
(Merged from https://github.com/openssl/openssl/pull/17836)

2 years agoSet protocol in init_client()
Todd Short [Tue, 8 Mar 2022 14:36:43 +0000 (09:36 -0500)]
Set protocol in init_client()

If TCP is being used, protocol = 0 is passed to init_client(), then
protocol == IPPROTO_TCP fails when attempting to set BIO_SOCK_NODELAY.

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

2 years agoAvoid potential memory leak
Dmitry Belyavskiy [Mon, 7 Mar 2022 16:05:57 +0000 (17:05 +0100)]
Avoid potential memory leak

Resolves #17827

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

2 years agocheck the return value of BIO_new_file()
xkernel [Mon, 7 Mar 2022 07:43:16 +0000 (15:43 +0800)]
check the return value of BIO_new_file()

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

2 years agoasync_posix: Make ASYNC_set_mem_functions threadsafe
Arran Cudbard-Bell [Tue, 1 Mar 2022 20:10:47 +0000 (14:10 -0600)]
async_posix: Make ASYNC_set_mem_functions threadsafe

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

2 years agoasync_posix: Allow custom stack allocation functions to be specified for POSIX contexts
Arran Cudbard-Bell [Thu, 24 Feb 2022 18:13:25 +0000 (13:13 -0500)]
async_posix: Allow custom stack allocation functions to be specified for POSIX contexts

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

2 years agoasync_posix: raise a memory allocation error if we fail to allocate stack memory
Arran Cudbard-Bell [Wed, 23 Feb 2022 18:56:36 +0000 (13:56 -0500)]
async_posix: raise a memory allocation error if we fail to allocate stack memory

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

2 years agoREADME: add link to migration_guide manual page
Dr. Matthias St. Pierre [Tue, 8 Mar 2022 16:36:37 +0000 (17:36 +0100)]
README: add link to migration_guide manual page

which replaces the link to the  OpenSSL 3.0 Wiki.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17840)

2 years agoSome platforms don't have pthread_atfork
Matt Caswell [Tue, 8 Mar 2022 17:04:59 +0000 (17:04 +0000)]
Some platforms don't have pthread_atfork

We've had a report of a linker failure on some platforms (this one was
linux ARM) that apparently did not have pthread_atfork. It's strange that
this has not been reported before but the simplest solution is just to
remove this from the library since it isn't really used anyway.

Currently it is called to set up the fork handlers OPENSSL_fork_prepare,
OPENSSL_fork_parent and OPENSSL_fork_child. However all of those functions
are no-ops. This is a remnant from earlier code that got removed. We can
safely remove it now.

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

2 years agoandroid-x86 target: Add -latomic
Marcel Raad [Wed, 2 Mar 2022 18:57:24 +0000 (19:57 +0100)]
android-x86 target: Add -latomic

Fixes https://github.com/openssl/openssl/issues/14083 again after being
broken by https://github.com/openssl/openssl/pull/15640.

CLA: trivial

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

2 years agoAdd external testing with oqsprovider
Michael Baentsch [Tue, 8 Mar 2022 06:46:05 +0000 (07:46 +0100)]
Add external testing with oqsprovider

Including running the oqsprovider external test in the
CI external test build.

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

2 years agoUse Perl to generate bsaes-armv8.S
Tom Cosgrove [Thu, 17 Jun 2021 11:21:23 +0000 (12:21 +0100)]
Use Perl to generate bsaes-armv8.S

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

2 years agoARM assembly pack: translate bit-sliced AES implementation to AArch64
Ben Avison [Wed, 10 Mar 2021 15:54:44 +0000 (15:54 +0000)]
ARM assembly pack: translate bit-sliced AES implementation to AArch64

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

2 years agoFix test failure when testing with Test::Harness
Hugo Landau [Mon, 7 Mar 2022 10:48:13 +0000 (10:48 +0000)]
Fix test failure when testing with Test::Harness

Fixes an issue where, when the test suite was being run with the older
Test::Harness package, the test suite would not complete correctly due
to evaluation of $harness->runtests()->has_errors, which is only
available for the newer TAP::Parser::Aggregator code path.

Fixes #17818.

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

2 years agoAdd EVP demos for RSA-PSS signing and verification
Hugo Landau [Wed, 2 Mar 2022 17:39:28 +0000 (17:39 +0000)]
Add EVP demos for RSA-PSS signing and verification

Two demos are provided: one using RSA-PSS directly in which a digest
must be provided, and one using RSA-PSS with the EVP_DigestSign APIs
which performs the hashing for you.

Fixes #14113.

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

2 years agoAdd EVP demo for Poly1305 demonstrating Poly1305-AES
Hugo Landau [Wed, 2 Mar 2022 09:50:41 +0000 (09:50 +0000)]
Add EVP demo for Poly1305 demonstrating Poly1305-AES

Fixes #14122.

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

2 years agoFurther acceleration for SM4-GCM on ARM
Daniel Hu [Wed, 2 Mar 2022 12:55:39 +0000 (12:55 +0000)]
Further acceleration for SM4-GCM on ARM

This patch will allow the SM4-GCM function to leverage the SM4
high-performance CTR crypto interface already implemented for ARM,
which is faster than current single block cipher routine used
for GCM

It does not address the acceleration of GHASH function of GCM,
which can be a future task, still we can see immediate uplift of
performance (up to 4X)

Before this patch:
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
SM4-GCM         186432.92k   394234.05k   587916.46k   639365.12k   648486.91k   652924.25k

After the patch:
SM4-GCM         193924.87k   860940.35k  1696083.71k  2302548.31k  2580411.73k  2607398.91k

Signed-off-by: Daniel Hu <Daniel.Hu@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17814)

2 years agoAdd demo for ARIA-256-CBC.
Daniel [Mon, 28 Feb 2022 20:57:06 +0000 (20:57 +0000)]
Add demo for ARIA-256-CBC.

Fixes #14104

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

2 years agoEVP demo for XOF digest using SHAKE256
Hugo Landau [Thu, 3 Mar 2022 08:20:05 +0000 (08:20 +0000)]
EVP demo for XOF digest using SHAKE256

This demo optionally accepts a single command line argument, allowing
the output length to be specified.

Fixes #14106.

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

2 years agoapps: several return value checks for BIO_new()
xkernel [Wed, 5 Jan 2022 07:54:10 +0000 (15:54 +0800)]
apps: several return value checks for BIO_new()

Also check return value of functions that call BIO_new() internally
such as dup_bio_out().

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

2 years agoRework dependencies between config files and build files
Richard Levitte [Wed, 23 Feb 2022 10:00:39 +0000 (11:00 +0100)]
Rework dependencies between config files and build files

Before PR #15310, which reworked how build files (Makefile, ...) were
generated, everything was done when configuring, so configdata.pm
could depend on build file templates and we'd get away with it.

However, since building configdata.pm is now independent of the build
file templates, that dependency is unnecessary, and would lead to
surprises of the build file template is updated, with an unexpected
full reconfiguration as a result, when all that's needed is to run
configdata.pm with no flags to get the build file re-generated.

This change is therefore a completion of what was forgotten in #15310.

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

2 years agoFix build issue with aes-gcm-armv8-unroll8_64.S on older aarch64 assemblers
XiaokangQian [Wed, 2 Mar 2022 03:27:43 +0000 (03:27 +0000)]
Fix build issue with aes-gcm-armv8-unroll8_64.S on older aarch64 assemblers

The EOR3 instruction is implemented with .inst, and the code here is enabled
using run-time detection of the CPU capabilities, so no need to explicitly
ask for the sha3 extension.

Fixes #17773

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17795)

2 years agoAdd EVP demo for X25519 key exchange
Hugo Landau [Wed, 2 Mar 2022 13:08:53 +0000 (13:08 +0000)]
Add EVP demo for X25519 key exchange

This offers both a known answer test with fixed keys and also
demonstrates a more realistic usage with random keys.

Fixes #14118.

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

2 years agoFix typo in EVP_MD-BLAKE2(7)
Hugo Landau [Tue, 1 Mar 2022 17:48:11 +0000 (17:48 +0000)]
Fix typo in EVP_MD-BLAKE2(7)

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

2 years agos_server: Do not use SSL_sendfile when KTLS is not being used
Hugo Landau [Tue, 1 Mar 2022 16:47:03 +0000 (16:47 +0000)]
s_server: Do not use SSL_sendfile when KTLS is not being used

Fix a bug in `openssl s_server -WWW` where it would attempt to invoke
`SSL_sendfile` if `-ktls -sendfile` was passed on the command line, even
if KTLS has not actually been enabled, for example because it is not
supported by the host. Since `SSL_sendfile` is only supported when KTLS
is actually being used, this resulted in a failure to serve requests.

Fixes #17503.

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

2 years agoPerturb the malloc output during tests
Matt Caswell [Thu, 24 Feb 2022 16:20:14 +0000 (16:20 +0000)]
Perturb the malloc output during tests

Set the environment variable MALLOC_PERTURB_ during tests to perturb the
output from OPENSSL_malloc() calls (see the mallopt man page for details
about this environment variable). This could be a low cost way of spotting
uninit reads in "make test" runs in some situations.

In tests I have found it to be a little unreliable (sometimes it seemed to
not perturb the output for inexplicable reasons) - but since this is easy
to implement I think it is worthwhile.

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

2 years agoasn1_string_to_time_t: Use timegm on FreeBSD.
John Baldwin [Thu, 24 Feb 2022 01:18:22 +0000 (17:18 -0800)]
asn1_string_to_time_t: Use timegm on FreeBSD.

FreeBSD does not provide a global timezone variable containing the
offset to UTC.  Instead, FreeBSD's libc includes a legacy timezone
function dating back to Version 7 AT&T UNIX.  As a result,
asn1_string_to_time_t currently fails to compile on FreeBSD as it
subtracts a function from a time_t value:

../crypto/asn1/a_time.c:625:37: error: invalid operands to binary expression ('time_t' (aka 'long') and 'char *(int, int)')
    timestamp_utc = timestamp_local - timezone;
                    ~~~~~~~~~~~~~~~ ^ ~~~~~~~~
1 error generated.

However, FreeBSD's libc does include a non-standard (but widely
available) timegm function which converts a struct tm directly to a
UTC time_t value.  Use this on FreeBSD instead of mktime.

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

2 years agoAdd testing of OBJ_find_sigid_by_algs()
Michael Baentsch [Wed, 2 Mar 2022 07:48:46 +0000 (08:48 +0100)]
Add testing of OBJ_find_sigid_by_algs()

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

2 years agoenable CMS sign/verify for provider-implemented PKEYs
Michael Baentsch [Fri, 18 Feb 2022 13:10:04 +0000 (14:10 +0100)]
enable CMS sign/verify for provider-implemented PKEYs

We need to handle signatures with and without digest algs
and we generalize the ossl_cms_ecdsa_dsa_sign() function
to other algorithms that are handled in the same way.

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

2 years agoSM4 optimization for non-asm mode
zhangzhilei [Thu, 24 Feb 2022 04:26:57 +0000 (12:26 +0800)]
SM4 optimization for non-asm mode

This patch use table-lookup borrow from aes in crypto/aes/aes_core.c.

Test on my PC(AMD Ryzen Threadripper 3990X 64-Core Processor),

before and after optimization:

debug mode:

Before:
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
SM4-CBC          40101.14k    41453.80k    42073.86k    42174.81k    42216.11k    42227.03k
SM4-ECB          41222.60k    42074.88k    42673.66k    42868.05k    42896.04k    42844.16k
SM4-CTR          35867.22k    36874.47k    37004.97k    37083.82k    37052.42k    37076.99k

After:
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
SM4-CBC          47273.51k    48957.40k    49665.19k    49810.77k    49859.24k    49834.67k
SM4-ECB          48100.01k    49323.34k    50224.04k    50273.28k    50533.72k    50730.12k
SM4-CTR          41352.64k    42621.29k    42971.22k    43061.59k    43089.92k    43100.84k

non-debug mode:

Before:
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
SM4-CBC         141596.59k   145102.93k   146794.50k   146540.89k   146650.45k   146877.10k
SM4-ECB         144774.71k   155106.28k   158166.36k   158279.00k   158520.66k   159280.97k
SM4-CTR         138021.10k   141577.60k   142493.53k   142736.38k   142852.10k   143125.16k

After:
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
SM4-CBC         142016.95k   150068.48k   152238.25k   152773.97k   153094.83k   152027.14k
SM4-ECB         148842.94k   159919.87k   163628.37k   164515.84k   164697.43k   164790.27k
SM4-CTR         141774.23k   146206.89k   147470.25k   147816.28k   146770.60k   148346.20k

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

2 years agoFix NULL pointer dereference for BN_mod_exp2_mont
Hugo Landau [Tue, 1 Mar 2022 14:08:12 +0000 (14:08 +0000)]
Fix NULL pointer dereference for BN_mod_exp2_mont

This fixes a bug whereby BN_mod_exp2_mont can dereference a NULL pointer
if BIGNUM argument m represents zero.

Regression test added. Fixes #17648.

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

2 years agoEnable openssl req -x509 to create certificates from CSRs
Hugo Landau [Tue, 1 Mar 2022 12:55:03 +0000 (12:55 +0000)]
Enable openssl req -x509 to create certificates from CSRs

`openssl req -x509` has code allowing it to generate certificates from CSRs
as a replacement for `openssl x509`, but a bug prevents it from working
properly. -CA and -CAkey can now be passed to generate a CA-signed
certificate as documented in openssl-req(1).

Regression testing has been added to `openssl req`.

Fixes #17736.

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

2 years agoImprove documentation of BIO_FLAGS_BASE64_NO_NL flag.
Daniel [Mon, 21 Feb 2022 12:25:25 +0000 (13:25 +0100)]
Improve documentation of BIO_FLAGS_BASE64_NO_NL flag.

Fixes #12491.

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

2 years ago[ssl] Add tests for Perfect Forward Secrecy criteria on SECLEVEL >= 3
Nicola Tuveri [Wed, 23 Feb 2022 21:05:22 +0000 (23:05 +0200)]
[ssl] Add tests for Perfect Forward Secrecy criteria on SECLEVEL >= 3

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

2 years ago[ssl] Add SSL_kDHEPSK and SSL_kECDHEPSK as PFS ciphersuites for SECLEVEL >= 3
Nicola Tuveri [Tue, 22 Feb 2022 14:26:26 +0000 (16:26 +0200)]
[ssl] Add SSL_kDHEPSK and SSL_kECDHEPSK as PFS ciphersuites for SECLEVEL >= 3

Fixes #17743

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

2 years ago[ssl] Prefer SSL_k(EC)?DHE to the SSL_kE(EC)?DH alias
Nicola Tuveri [Tue, 22 Feb 2022 12:47:11 +0000 (14:47 +0200)]
[ssl] Prefer SSL_k(EC)?DHE to the SSL_kE(EC)?DH alias

`SSL_kECDHE` and `SSL_kEECDH`, and `SSL_kDHE` and `SSL_kEDH` are already
marked as aliases of each other in the headers.
This commit, for each pair, replaces the leftover uses of the latter
synonym with the first one, which is considered more common.

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

2 years agoaarch64: Fix async_fibre_swapcontext() on clang BTI builds
Tom Cosgrove [Mon, 14 Feb 2022 11:23:57 +0000 (11:23 +0000)]
aarch64: Fix async_fibre_swapcontext() on clang BTI builds

Reverting to using swapcontext() when compiling with clang on BTI-enabled
builds fixes the BTI setjmp() failure seen when running asynctest.

The issue with setjmp/longjmp is a known clang bug: see
https://github.com/llvm/llvm-project/issues/48888

Change-Id: I6eeaaa2e15f402789f1b3e742038f84bef846e29

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