openssl.git
6 months agoLift BLAKE2B provider definition into a macro
наб [Wed, 18 Oct 2023 16:40:07 +0000 (18:40 +0200)]
Lift BLAKE2B provider definition into a macro

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

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

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

6 months agoquic http3 demo: minor updates
James Muir [Sun, 29 Oct 2023 19:24:08 +0000 (15:24 -0400)]
quic http3 demo: minor updates

-update run command to include LD_LIBRARY_PATH
-suggest installing libnghttp3-dev on Ubuntu
-drop "-f" from clean recipe (it is already included in $(RM))

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

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

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

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

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

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

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

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

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

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

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

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

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

6 months agoIntroduce libabigail checking in ci
Neil Horman [Wed, 1 Nov 2023 12:53:18 +0000 (08:53 -0400)]
Introduce libabigail checking in ci

It would be nice if we could monitor the consistency of our ABI from PR to PR,
to ensure there are no inadvertent changes to the library ABI.

Introduce a new CI job that runs the libabigail tools to build an ABI
representation of the PR-built library and compares it to a stored/expected
representation, reporting any discrepancies it finds.

Fixes #22571

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

6 months agoCorrectly track the original length when generating a stream frame
Matt Caswell [Thu, 2 Nov 2023 16:25:27 +0000 (16:25 +0000)]
Correctly track the original length when generating a stream frame

txp_generate_stream_frames() plans chunks of data to send via the
function txp_plan_stream_chunk(). That function may clamp the amount in
the chunk due to flow control, even though there is more available to send.

We should take this into account when deciding whether or not to try
serializing the next chunk.

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

6 months agotparam_on_enc_ext(): Remove dead code in cleanup
Tomas Mraz [Fri, 3 Nov 2023 07:57:21 +0000 (08:57 +0100)]
tparam_on_enc_ext(): Remove dead code in cleanup

Fixes Coverity 1548382

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

6 months agoossl_quic_new(): Avoid dereferencing NULL qc during cleanup
Tomas Mraz [Fri, 3 Nov 2023 07:52:43 +0000 (08:52 +0100)]
ossl_quic_new(): Avoid dereferencing NULL qc during cleanup

Fixes Coverity 1548383

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

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

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

Fixes #22381

CLA: trivial

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22614)

6 months agoossl_qrl_enc_level_set_provide_secret(): Avoid leaking keyslot in error condition
Tomas Mraz [Thu, 2 Nov 2023 16:19:38 +0000 (17:19 +0100)]
ossl_qrl_enc_level_set_provide_secret(): Avoid leaking keyslot in error condition

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

6 months agointernal/common.h: rename macro `(un)likely` to `ossl_(un)likely`
Matthias St. Pierre [Thu, 2 Nov 2023 19:51:52 +0000 (20:51 +0100)]
internal/common.h: rename macro `(un)likely` to `ossl_(un)likely`

The macro was introduced in commit ed6dfd1e3694 without an
openssl-specific prefix as mandated by the coding style.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/22603)

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

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

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

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

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

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

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

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

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

6 months agorand uniform: fix likely usage
Pauli [Thu, 2 Nov 2023 01:26:50 +0000 (12:26 +1100)]
rand uniform: fix likely usage

@mspncp noted that the condition should have been likely not unlikely.

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22593)

6 months agoAdd support for streams to the quic-client fuzzer
Matt Caswell [Wed, 1 Nov 2023 16:15:24 +0000 (16:15 +0000)]
Add support for streams to the quic-client fuzzer

Enable the quic-client fuzzer to accept and create new streams

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

6 months agoCall SSL_write() in the quic-client-fuzzer
Matt Caswell [Wed, 1 Nov 2023 15:25:24 +0000 (15:25 +0000)]
Call SSL_write() in the quic-client-fuzzer

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

6 months agoAdd additional internal HPKE hardening checks resulting from code audit.
Stephen Farrell [Mon, 16 Oct 2023 20:04:06 +0000 (21:04 +0100)]
Add additional internal HPKE hardening checks resulting from code audit.

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

6 months agoAdd design notes for XOF API.
slontis [Thu, 13 Jul 2023 04:32:02 +0000 (14:32 +1000)]
Add design notes for XOF API.

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

6 months agoTLS: Fix use of an uninitialized value
Hugo Landau [Thu, 26 Oct 2023 11:47:58 +0000 (12:47 +0100)]
TLS: Fix use of an uninitialized value

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

6 months agoQUIC: Test missing/malformed/duplicate/etc. transport parameters
Hugo Landau [Thu, 26 Oct 2023 10:39:06 +0000 (11:39 +0100)]
QUIC: Test missing/malformed/duplicate/etc. transport parameters

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

6 months agoQUIC QTEST_FAULT: Allow deleted TLS extension to be output
Hugo Landau [Thu, 26 Oct 2023 10:37:21 +0000 (11:37 +0100)]
QUIC QTEST_FAULT: Allow deleted TLS extension to be output

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

6 months agoQUIC WIRE: Refuse integer transport params with trailing body bytes
Hugo Landau [Thu, 26 Oct 2023 10:36:51 +0000 (11:36 +0100)]
QUIC WIRE: Refuse integer transport params with trailing body bytes

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

6 months agoQUIC CHANNEL: Set reason string for missing tparams extension
Hugo Landau [Thu, 26 Oct 2023 10:36:31 +0000 (11:36 +0100)]
QUIC CHANNEL: Set reason string for missing tparams extension

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

6 months agoossl_quic_new(): Fix a leak found by error injection
Tomas Mraz [Tue, 31 Oct 2023 14:11:30 +0000 (15:11 +0100)]
ossl_quic_new(): Fix a leak found by error injection

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

6 months agoFix quicserver binding when duplicate entries exist
Neil Horman [Mon, 30 Oct 2023 17:47:05 +0000 (13:47 -0400)]
Fix quicserver binding when duplicate entries exist

In testing the quic demos, I found that the quicserver refused to start for me,
indicating an inability to bind a socket to listen on

The problem turned out to be that getaddrinfo on my system was returning
multiple entries, due to the fact that /etc/host maps the localhost host name to
both ipv4 (127.0.0.1) and ipv6 (::1), but returns the latter as an ipv4 mapped
address (specifying family == AF_INET)

It seems like the proper fix would be to modify the /etc/hosts file to not make
that mapping, and indeed that works.  However, since several distribution ship
with this setup, it seems like it is worthwhile to manage it in the server code.

its also that some other application may be bound to a given address/port
leading to failure, which I think could be considered erroneous, as any failure
for the full addrinfo list in quicserver would lead to a complete failure

Fix this by modifying the create_dgram_bio function to count the number of
sockets is successfully binds/listens on, skipping any failures, and only exit
the application if the number of bound sockets is zero.

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

6 months agotag ossl_assert not failing as being 'likely' to improve optimisation
Pauli [Wed, 25 Oct 2023 23:58:11 +0000 (10:58 +1100)]
tag ossl_assert not failing as being 'likely' to improve optimisation

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22516)

6 months agoCHANGES.md: document BLAKE2b's "size"-setting support
наб [Tue, 31 Oct 2023 19:36:59 +0000 (20:36 +0100)]
CHANGES.md: document BLAKE2b's "size"-setting support

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

6 months agoQUIC SSTREAM: Fix bug in ossl_quic_sstream_is_totally_acked
Hugo Landau [Tue, 31 Oct 2023 16:47:55 +0000 (16:47 +0000)]
QUIC SSTREAM: Fix bug in ossl_quic_sstream_is_totally_acked

ossl_quic_sstream_is_totally_acked would return 0
if no data had been appended to the stream yet.
Fixed and added tests.

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

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

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

6 months agoUpdate the OpenSSL Guide tutorials with changes to the demos
Matt Caswell [Mon, 30 Oct 2023 12:39:37 +0000 (12:39 +0000)]
Update the OpenSSL Guide tutorials with changes to the demos

The demo code has changed to accept the hostname/port on the command line.
We update the tutorials to keep in sync with the demo code.

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

6 months agoUpdate the README with information about how to run the QUIC demos
Matt Caswell [Mon, 30 Oct 2023 12:17:30 +0000 (12:17 +0000)]
Update the README with information about how to run the QUIC demos

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

6 months agoUpdate the QUIC demos to accept hostname/port on the command line
Matt Caswell [Mon, 30 Oct 2023 12:04:40 +0000 (12:04 +0000)]
Update the QUIC demos to accept hostname/port on the command line

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

6 months agoExtend the README to describe how to run the TLS demos
Matt Caswell [Mon, 30 Oct 2023 11:22:24 +0000 (11:22 +0000)]
Extend the README to describe how to run the TLS demos

We also supply some test certificates for use with the demos.

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

6 months agoAmend the TLS demos to accept hostname/port as an argument
Matt Caswell [Mon, 30 Oct 2023 11:22:00 +0000 (11:22 +0000)]
Amend the TLS demos to accept hostname/port as an argument

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

6 months agoQUIC MULTISTREAM TEST: Ensure frames are only injected into correct packet types
Hugo Landau [Tue, 31 Oct 2023 16:11:43 +0000 (16:11 +0000)]
QUIC MULTISTREAM TEST: Ensure frames are only injected into correct packet types

Although the previous commit is enough to fix the immediate cause of the
stochastic failure on Windows, this is a more resilient fix; make sure
we only inject a given frame into the correct packet type for our
various injection functions.

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

6 months agoQUIC MULTISTREAM TEST: Fix script 38 stochastic failure on Windows
Hugo Landau [Tue, 31 Oct 2023 15:58:21 +0000 (15:58 +0000)]
QUIC MULTISTREAM TEST: Fix script 38 stochastic failure on Windows

The QUIC fault injector frame injection functionality injects injected
frames on whatever EL we happen to be using to generate a packet in.
This means we sometimes inject the frame into a packet type it is not
allowed to be in, causing a different error code to be generated.

Fix this by making sure the connection is fully established before
trying to generate the frame in question.

Fixes #22348.

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

6 months agoDon't create an ack frame if one isn't wanted for this pn_space
Matt Caswell [Tue, 31 Oct 2023 16:24:44 +0000 (16:24 +0000)]
Don't create an ack frame if one isn't wanted for this pn_space

The txp->want_ack value has different bit values for different pn_space
values. Make sure we take that into account when we read it.

Fixes #22568

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

6 months agoCorrect comment in crypto/ec/curve448/ed448.h
Christian Schmidt [Tue, 31 Oct 2023 14:12:10 +0000 (15:12 +0100)]
Correct comment in crypto/ec/curve448/ed448.h

Obvious Copy&Paste&not edit error.

CLA: trivial

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

6 months agoquic ddd demos: update makefile and demo sources
James Muir [Thu, 26 Oct 2023 21:50:45 +0000 (17:50 -0400)]
quic ddd demos: update makefile and demo sources

Update makefile and fix some signedness issues in the demo sources.
Drop stray "\n" in the host-port format string that prevented ddd-01
from working (this was also noticed by Neil H). Also, determine the
length of the message we are sending and send that many bytes (rather
than send sizeof the buffer storing the message).

These changes are part of https://github.com/openssl/project/issues/253

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

6 months agoquic docs: update ddd README.md
James Muir [Fri, 27 Oct 2023 16:46:30 +0000 (12:46 -0400)]
quic docs: update ddd README.md

Minor edits (expand MVP acronym, suggest how to install "libuv")

These changes are part of
https://github.com/openssl/project/issues/253

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

6 months agoQUIC APL: Optimise write buffer sizes automatically
Hugo Landau [Mon, 30 Oct 2023 20:19:46 +0000 (20:19 +0000)]
QUIC APL: Optimise write buffer sizes automatically

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

6 months agoQUIC TXP: Fix drainage calculation
Hugo Landau [Mon, 30 Oct 2023 19:36:49 +0000 (19:36 +0000)]
QUIC TXP: Fix drainage calculation

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

6 months agoCreate a rudimentary symbol scanning script
Neil Horman [Mon, 23 Oct 2023 16:47:13 +0000 (12:47 -0400)]
Create a rudimentary symbol scanning script

We would like to be able to log and audit the symbols we use in openssl
so that we might catch when a new platform symbols is referecned

Add such a script (just on unix platforms for now) that gathers the used
symbols not belonging to libcrypto or libssl, and compare it to a prior
known set of used symbols.  Error out if a new symbol is found

Add this script to the ci workflow in CI to capture newly
introduced platform symbols

Fixes #22330

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

6 months agoCI: add Clang 17
Sam James [Tue, 31 Oct 2023 11:30:32 +0000 (11:30 +0000)]
CI: add Clang 17

Signed-off-by: Sam James <sam@gentoo.org>
Reviewed-by: Hugo Landau <hlandau@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/22570)

6 months agoStop the quicserver if the handshake or receiving the request fails
Matt Caswell [Mon, 30 Oct 2023 16:30:35 +0000 (16:30 +0000)]
Stop the quicserver if the handshake or receiving the request fails

Previously we entered an infinite loop if these things failed.

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

6 months agorand uniform: add comments outlining the algorithm
Pauli [Tue, 31 Oct 2023 21:52:00 +0000 (08:52 +1100)]
rand uniform: add comments outlining the algorithm

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
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/22499)

6 months agoAdd test case for uniform random generators
Pauli [Sat, 28 Oct 2023 09:49:08 +0000 (20:49 +1100)]
Add test case for uniform random generators

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
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/22499)

6 months agorand: implement an unbiased random integer from a range
Pauli [Wed, 25 Oct 2023 06:48:43 +0000 (17:48 +1100)]
rand: implement an unbiased random integer from a range

Refer: https://github.com/apple/swift/pull/39143 for a description
of the algorithm.

It is optimal in the sense of having:

* no divisions
* minimal number of blocks of random bits from the generator

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
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/22499)

6 months agoDon't error if s_client receives exactly BUFSIZZ data
Matt Caswell [Mon, 30 Oct 2023 16:53:30 +0000 (16:53 +0000)]
Don't error if s_client receives exactly BUFSIZZ data

We should accept that many bytes without failing

Fixes #22551

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

6 months agoremove setup-perl actiond from windows jobs
Dmitry Misharov [Mon, 30 Oct 2023 15:55:01 +0000 (16:55 +0100)]
remove setup-perl actiond from windows jobs

Windows runner have Perl preinstalled.
https://github.com/actions/runner-images/blob/main/images/win/Windows2022-Readme.md

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

6 months agoCheck for NULL when freeing the QUIC_TLS object
Matt Caswell [Fri, 27 Oct 2023 11:22:11 +0000 (12:22 +0100)]
Check for NULL when freeing the QUIC_TLS object

Free functions are expected to be tolerant of a NULL pointer being passed.

Fixes the problem in
https://github.com/openssl/openssl/pull/21668#issuecomment-1782718328

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

6 months agoevp_test.c: There are now 3 parameters possible for digests
Tomas Mraz [Thu, 26 Oct 2023 07:59:22 +0000 (09:59 +0200)]
evp_test.c: There are now 3 parameters possible for digests

In digest_test_run() there are now 3 parameters possible plus
the sentinel value. In reality we will never use all three
at once but Coverity rightfully complains that it is possible
to overflow the params array.

Fixes Coverity 1548054

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

6 months agoQUIC CHANNEL: Make ping deadline and idle deadline calculation consistent
Hugo Landau [Fri, 27 Oct 2023 09:21:46 +0000 (10:21 +0100)]
QUIC CHANNEL: Make ping deadline and idle deadline calculation consistent

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

6 months agoIf the loss detection timer has fired we may not have lost packets
Matt Caswell [Fri, 27 Oct 2023 15:11:57 +0000 (16:11 +0100)]
If the loss detection timer has fired we may not have lost packets

We calculate the delay from the point that a packet arrives until it will
be counted as lost based on rtt info. Looking at all the packets we can
then calculate the earliest time that a packet will be counted as lost.
When that timer fires the latest rtt info may have changed and therefore
the packet may no longer be counted as lost yet.

We should not assume that just because the ackm timeout has fired that
there will definitely be lost packets.

Fixes #22538

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

6 months agoCreate a fuzz introspector exclude config file
Kurt Roeckx [Fri, 27 Oct 2023 08:31:00 +0000 (10:31 +0200)]
Create a fuzz introspector exclude config file

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

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

When successful, ossl_X509_ALGOR_from_nid() returns a pointer to an
X509_ALGOR object.  Inside ossl_X509_ALGOR_from_nid(),
X509_ALGOR_set0() is called, and this passes ownership of the ASN1
object "los" (label octet string) to the X509_ALGOR object.  When
ossl_X509_ALGOR_from_nid() fails, ownership has not been passed on and
we need to free "los".

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

Fixes #22336

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

6 months agoUpdate to latest fuzz corpora
Kurt Roeckx [Fri, 27 Oct 2023 08:17:02 +0000 (10:17 +0200)]
Update to latest fuzz corpora

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

6 months agoAdd a separate README for the guide demos
Matt Caswell [Wed, 25 Oct 2023 12:10:59 +0000 (13:10 +0100)]
Add a separate README for the guide demos

Point users at the actual guide, and also explain about LD_LIBRARY_PATH

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

6 months agoAdd a reference for HTTP/3
Matt Caswell [Wed, 25 Oct 2023 11:57:12 +0000 (12:57 +0100)]
Add a reference for HTTP/3

We also add reference for ALPN ids

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

6 months agoAdd a reference to the demos subfolder
Matt Caswell [Wed, 25 Oct 2023 11:48:31 +0000 (12:48 +0100)]
Add a reference to the demos subfolder

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

6 months agoUpdate to the demos README file
Matt Caswell [Wed, 25 Oct 2023 11:46:33 +0000 (12:46 +0100)]
Update to the demos README file

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

6 months agoUpdate README-QUIC.md
Matt Caswell [Wed, 25 Oct 2023 11:31:19 +0000 (12:31 +0100)]
Update README-QUIC.md

We move some of the "why QUIC" content into the guide and just provide a
summary in README-QUIC.md.

We also clarify how to use s_client with QUIC.

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

6 months agoRefresh the README.md file
Matt Caswell [Wed, 25 Oct 2023 10:10:51 +0000 (11:10 +0100)]
Refresh the README.md file

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

6 months agoPrepare for 3.3
Richard Levitte [Thu, 26 Oct 2023 14:45:43 +0000 (16:45 +0200)]
Prepare for 3.3

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

6 months agoEVP_PKEY_get_size.pod and provider-keymgmt.pod: document their relation
Dr. David von Oheimb [Sat, 21 Oct 2023 07:57:09 +0000 (09:57 +0200)]
EVP_PKEY_get_size.pod and provider-keymgmt.pod: document their relation

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

6 months agoEVP_PKEY_get_{bits,security_bits,size}(): add missing error queue entry on failure
Dr. David von Oheimb [Fri, 20 Oct 2023 18:51:17 +0000 (20:51 +0200)]
EVP_PKEY_get_{bits,security_bits,size}(): add missing error queue entry on failure

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

6 months agoCMS and PKCS7: fix handlling of EVP_PKEY_get_size() failure
Dr. David von Oheimb [Fri, 20 Oct 2023 19:00:10 +0000 (21:00 +0200)]
CMS and PKCS7: fix handlling of EVP_PKEY_get_size() failure

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

6 months agoProvide additional AES-ECB test patterns to enhance test coverage.
Phoebe Chen [Mon, 25 Sep 2023 03:09:12 +0000 (20:09 -0700)]
Provide additional AES-ECB test patterns to enhance test coverage.

To enhance test coverage for AES-ECB mode, we provided longer additional
testing patterns for AES-128/192/256-ECB.

Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoriscv: Provide vector crypto implementation of AES-ECB mode.
Phoebe Chen [Mon, 25 Sep 2023 03:07:48 +0000 (20:07 -0700)]
riscv: Provide vector crypto implementation of AES-ECB mode.

This patch provides stream and multi-block implementations for
AES-128-ECB, AES-192-ECB, and AES-256-ECB to accelerate AES-ECB.
Also, refactor functions to share the same variable
declaration in aes-riscv64-zvkned.pl.

Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoriscv: Support sm3 on platforms with vlen >= 128.
Jerry Shih [Mon, 11 Sep 2023 03:30:52 +0000 (11:30 +0800)]
riscv: Support sm3 on platforms with vlen >= 128.

This patch updates the OSSSL_HWSM3_block_data_order_zvksh and enables
SM3 on platforms with VLEN >= 128.

Signed-off-by: Jerry Shih <jerry.shih@sifive.com>
Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoProvide additional AES-XTS test patterns to enhance test coverage.
Phoebe Chen [Thu, 14 Sep 2023 04:07:27 +0000 (21:07 -0700)]
Provide additional AES-XTS test patterns to enhance test coverage.

To enhance test coverage for AES-XTS mode, we provided longer additional
testing patterns from BoringSSL for AES-XTS testing.

Signed-off-by: Jerry Shih <jerry.shih@sifive.com>
Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoriscv: Provide vector crypto implementation of AES-128/256-XTS mode.
Jerry Shih [Mon, 25 Sep 2023 00:45:55 +0000 (08:45 +0800)]
riscv: Provide vector crypto implementation of AES-128/256-XTS mode.

To accelerate the performance of the AES-XTS mode, in this patch, we
have the specialized multi-block implementation for AES-128-XTS and
AES-256-XTS.

Signed-off-by: Jerry Shih <jerry.shih@sifive.com>
Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoFix the aes-xts key-length checking condition and hw declaration.
Jerry Shih [Mon, 25 Sep 2023 00:42:23 +0000 (08:42 +0800)]
Fix the aes-xts key-length checking condition and hw declaration.

The argument `key-length` includes 2 sets of keys.

All declarations should under `PROV_CIPHER_HW_declare_xts()` macro.

Signed-off-by: Jerry Shih <jerry.shih@sifive.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoProvide additional AES-GCM test patterns to enhance test coverage.
Phoebe Chen [Thu, 14 Sep 2023 03:43:25 +0000 (20:43 -0700)]
Provide additional AES-GCM test patterns to enhance test coverage.

To enhance test coverage for AES-GCM mode, we provided longer additional
testing patterns for AES-GCM testing.

Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
Signed-off-by: Jerry Shih <jerry.shih@sifive.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoriscv: Provide vector crypto implementation of AES-GCM mode.
Jerry Shih [Mon, 25 Sep 2023 01:14:48 +0000 (09:14 +0800)]
riscv: Provide vector crypto implementation of AES-GCM mode.

To accelerate the performance of the AES-GCM mode, in this patch, we
have the specialized multi-block implementations for AES-128-GCM,
AES-192-GCM and AES-256-GCM.

Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
Signed-off-by: Jerry Shih <jerry.shih@sifive.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoMinor changes of the GCM-related code.
Jerry Shih [Mon, 25 Sep 2023 01:13:07 +0000 (09:13 +0800)]
Minor changes of the GCM-related code.

Unify the return value for `CRYPTO_gcm128_decrypt` as `CRYPTO_gcm128_encrypt`.

Signed-off-by: Jerry Shih <jerry.shih@sifive.com>
Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoriscv: Provide vector crypto implementation of AES-CTR mode.
Phoebe Chen [Tue, 12 Sep 2023 14:02:30 +0000 (07:02 -0700)]
riscv: Provide vector crypto implementation of AES-CTR mode.

Support zvbb-zvkned based rvv AES-128/192/256-CTR encryption.

Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoriscv: Support SHA-512 family on platforms with vlen >= 128.
Phoebe Chen [Thu, 7 Sep 2023 14:08:29 +0000 (07:08 -0700)]
riscv: Support SHA-512 family on platforms with vlen >= 128.

This patch supports SHA-512, SHA-512/224, SHA-512/256 on platforms with
vlen greater than 128,

Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoriscv: Code optimization for SHA-256.
Phoebe Chen [Thu, 7 Sep 2023 14:03:56 +0000 (07:03 -0700)]
riscv: Code optimization for SHA-256.

Keep SHA-256 constant values in registers to save the loading time.

Move the constant loading for sha256 into a separate subroutine.
By creating a dedicated sub routine for loading sha256 constants, the
code can be made more modular and easier to modify in the future.

Relaxing the SHA256 constraint, zvknhb also supports SHA256.

Simplify the H and mask initialization flows.

Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoriscv: Provide a vector implementation of CHACHA20 cipher.
Jerry Shih [Tue, 11 Jul 2023 07:49:28 +0000 (15:49 +0800)]
riscv: Provide a vector implementation of CHACHA20 cipher.

Use rvv and zvbb extensions for CHACHA20 cipher.

Signed-off-by: Jerry Shih <jerry.shih@sifive.com>
Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoProvide additional AES-CBC test patterns to enhance test coverage.
Phoebe Chen [Fri, 2 Jun 2023 02:51:10 +0000 (19:51 -0700)]
Provide additional AES-CBC test patterns to enhance test coverage.

To enhance test coverage for AES-CBC mode, we provided longer additional
test patterns for AES-CBC testing.

Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoriscv: Use the optimized rvv AES-128/192/256-CBC.
Phoebe Chen [Thu, 1 Jun 2023 12:11:37 +0000 (05:11 -0700)]
riscv: Use the optimized rvv AES-128/192/256-CBC.

Replace old CBC implementation with optimized AES-128/192/256-CBC in
this patch.

Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoriscv: Provide vector crypto implementation of AES-CBC mode.
Phoebe Chen [Tue, 12 Sep 2023 13:44:05 +0000 (06:44 -0700)]
riscv: Provide vector crypto implementation of AES-CBC mode.

To accelerate the performance of the AES-128/192/256-CBC block cipher
encryption, we used the vaesz, vaesem and vaesef instructions, which
implement a single round of AES encryption.

Similarly, to optimize the performance of AES-128/192/256-CBC block
cipher decryption, we have utilized the vaesz, vaesdm, and vaesdf
instructions, which facilitate a single round of AES decryption.

Furthermore, we optimize the key and initialization vector (IV) step by
keeping the rounding key in vector registers.

Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoUpdate for Zvkb extension.
Jerry Shih [Thu, 28 Sep 2023 05:51:17 +0000 (13:51 +0800)]
Update for Zvkb extension.

https://github.com/riscv/riscv-crypto/blob/c8ddeb7e64a3444dda0438316af1238aeed72041/doc/vector/riscv-crypto-vector-zvkb.adoc
Create `RISCV_HAS_ZVKB()` macro.
Use zvkb for SM4 instead of zvbb.
Use zvkb for ghash instead of zvbb.
We could just use the zvbb's subset `zvkb` for flexibility.

Signed-off-by: Jerry Shih <jerry.shih@sifive.com>
Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoriscv: Further optimization for single block aes-zvkned decryption.
Phoebe Chen [Wed, 4 Oct 2023 08:44:46 +0000 (01:44 -0700)]
riscv: Further optimization for single block aes-zvkned decryption.

Interleave key loading and aes decrypt computing for single block aes.

Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoriscv: Further optimization for single block aes-zvkned encryption.
Phoebe Chen [Wed, 4 Oct 2023 08:42:10 +0000 (01:42 -0700)]
riscv: Further optimization for single block aes-zvkned encryption.

Interleave key loading and aes encrypt computing for single block aes.

Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoriscv: Add RISC-V Vector opcode in riscv.pm
Phoebe Chen [Tue, 29 Aug 2023 08:49:45 +0000 (01:49 -0700)]
riscv: Add RISC-V Vector opcode in riscv.pm

Added helper functions and opcode encoding functions
in riscv.pm perl module to avoid pointless code duplication.

Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoFix typo in ghash-riscv64*.pl
Phoebe Chen [Thu, 28 Sep 2023 17:01:52 +0000 (10:01 -0700)]
Fix typo in ghash-riscv64*.pl

Changed "mutiple" to "multiple" for improved clarity and correctness.

Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoriscv: Implement AES-192
Ard Biesheuvel [Mon, 24 Jul 2023 14:41:17 +0000 (16:41 +0200)]
riscv: Implement AES-192

Even though the RISC-V vector instructions only support AES-128 and
AES-256 for key generation, the round instructions themselves can
easily be used to implement AES-192 too - we just need to fallback to
the generic key generation routines in this case.

Note that the vector instructions use the encryption key schedule (but
in reverse order) so we need to generate the encryption key schedule
even when doing decryption using the vector instructions.

Signed-off-by: Ard Biesheuvel <ardb@google.com>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoriscv: SM3: Provide a Zvksh-based implementation
Charalampos Mitrodimas [Fri, 27 Jan 2023 15:47:41 +0000 (16:47 +0100)]
riscv: SM3: Provide a Zvksh-based implementation

The upcoming RISC-V vector crypto extensions feature
a Zvksh extension, that provides SM3-specific istructions.
This patch provides an implementation that utilizes this
extension if available.

Tested on QEMU and no regressions observed.

Signed-off-by: Charalampos Mitrodimas <charalampos.mitrodimas@vrull.eu>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoriscv: SM4: Provide a Zvksed-based implementation
Christoph Müllner [Wed, 18 Jan 2023 19:58:12 +0000 (20:58 +0100)]
riscv: SM4: Provide a Zvksed-based implementation

The upcoming RISC-V vector crypto extensions feature
a Zvksed extension, that provides SM4-specific instructions.
This patch provides an implementation that utilizes this
extension if available.

Tested on QEMU and no regressions observed.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoriscv: sha512: Provide a Zvknhb-based implementation
Charalampos Mitrodimas [Thu, 26 Jan 2023 16:26:51 +0000 (17:26 +0100)]
riscv: sha512: Provide a Zvknhb-based implementation

The upcoming RISC-V vector crypto extensions feature
a Zvknhb extension, that provides sha512-specific istructions.
This patch provides an implementation that utilizes this
extension if available.

Tested on QEMU and no regressions observed.

Signed-off-by: Charalampos Mitrodimas <charalampos.mitrodimas@vrull.eu>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agocrypto: sha512: Add mechanism to keep C code as fallback for SHA512_ASM
Charalampos Mitrodimas [Thu, 26 Jan 2023 15:32:47 +0000 (16:32 +0100)]
crypto: sha512: Add mechanism to keep C code as fallback for SHA512_ASM

Currently, architectures have to decide if they want the C code or an
arch-specific implementation. Let's add a macro, that allows to keep the C
code even if SHA512_ASM is defined (but rename it from sha512_block_data_order
to sha512_block_data_order_c). The macro INCLUDE_C_SHA512 can be used by
architectures, that want the C code as fallback code.

Signed-off-by: Charalampos Mitrodimas <charalampos.mitrodimas@vrull.eu>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoriscv: sha256: Provide a Zvknha-based implementation
Charalampos Mitrodimas [Thu, 26 Jan 2023 13:58:30 +0000 (14:58 +0100)]
riscv: sha256: Provide a Zvknha-based implementation

The upcoming RISC-V vector crypto extensions feature
a Zvknha extension, that provides sha256-specific instructions.
This patch provides an implementation that utilizes this
extension if available.

Tested on QEMU and no regressions observed.

Signed-off-by: Charalampos Mitrodimas <charalampos.mitrodimas@vrull.eu>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agocrypto: sha256: Add mechanism to keep C code as fallback for SHA256_ASM
Charalampos Mitrodimas [Thu, 26 Jan 2023 13:01:42 +0000 (14:01 +0100)]
crypto: sha256: Add mechanism to keep C code as fallback for SHA256_ASM

Currently, architectures have to decide if they want the C code or an
arch-specific implementation. Let's add a macro, that allows to keep the C
code even if SHA256_ASM is defined (but rename it from sha256_block_data_order
to sha256_block_data_order_c). The macro INCLUDE_C_SHA256 can be used by
architectures, that want the C code as fallback code.

Signed-off-by: Charalampos Mitrodimas <charalampos.mitrodimas@vrull.eu>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

6 months agoriscv: AES: Provide a Zvkned-based implementation
Christoph Müllner [Thu, 26 Jan 2023 16:34:05 +0000 (17:34 +0100)]
riscv: AES: Provide a Zvkned-based implementation

The upcoming RISC-V vector crypto extensions provide
the Zvkned extension, that provides a AES-specific instructions.
This patch provides an implementation that utilizes this
extension if available.

Tested on QEMU and no regressions observed.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)