openssl.git
20 months agocheck-format.pl: improve preprocessor directive handling; re-order state variables
Dr. David von Oheimb [Wed, 13 Jul 2022 17:37:30 +0000 (19:37 +0200)]
check-format.pl: improve preprocessor directive handling; re-order state variables

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

20 months agoPKCS7: add notes to pkcs7.h.in and minor code cleanup in crypto/{pkcs7,cms}/
Dr. David von Oheimb [Wed, 31 Aug 2022 08:27:42 +0000 (10:27 +0200)]
PKCS7: add notes to pkcs7.h.in and minor code cleanup in crypto/{pkcs7,cms}/

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

20 months agoFix many inconsistencies in doc of CMS_verify() and PKC7_verify() etc.
Dr. David von Oheimb [Fri, 29 Jul 2022 11:09:52 +0000 (13:09 +0200)]
Fix many inconsistencies in doc of CMS_verify() and PKC7_verify() etc.

Also change B< to I< in {CMS,PKCS7}_verify.pod, PKCS7_sign{,_add_signer}.pod

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

20 months agoTX key update support, RX time and PN reporting, general refactoring
Hugo Landau [Mon, 15 Aug 2022 15:13:28 +0000 (16:13 +0100)]
TX key update support, RX time and PN reporting, general refactoring

- Adds an RX time field to the OSSL_QRX_PKT structure.

- Adds a timekeeping argument to ossl_demux_new which is used to determine
  packet reception time.

- Adds a decoded PN field to the OSSL_QRX_PKT structure.
  This has to be decoded by the QRX anyway, and its omission was an oversight.

- Key update support for the TX side.

- Minor refactoring.

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

20 months agoQUIC Record Layer (Refactor and TX Side)
Hugo Landau [Thu, 11 Aug 2022 10:24:57 +0000 (11:24 +0100)]
QUIC Record Layer (Refactor and TX Side)

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

20 months agoQUIC Demuxer and Record Layer (RX Side)
Hugo Landau [Fri, 22 Jul 2022 12:08:38 +0000 (13:08 +0100)]
QUIC Demuxer and Record Layer (RX Side)

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

20 months agoDocument the return value of OSSL_LIB_CTX_load_config()
Tomas Mraz [Wed, 31 Aug 2022 06:50:42 +0000 (08:50 +0200)]
Document the return value of OSSL_LIB_CTX_load_config()

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

20 months agoFix documented max. length for info buffer in HKDF
Tobias Brunner [Mon, 29 Aug 2022 08:05:56 +0000 (10:05 +0200)]
Fix documented max. length for info buffer in HKDF

This limit was increased with 20c2876f24d0 ("Increase
HKDF_MAXBUF from 1024 to 2048").

CLA: trivial

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

20 months agoPKCS7_dataVerify(): fix missing use of CRLs in PKCS#7 message
Dr. David von Oheimb [Sat, 30 Jul 2022 18:53:44 +0000 (20:53 +0200)]
PKCS7_dataVerify(): fix missing use of CRLs in PKCS#7 message

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

20 months agoRemove unused dtls1_bitmap.c
Tomas Mraz [Mon, 29 Aug 2022 10:27:27 +0000 (12:27 +0200)]
Remove unused dtls1_bitmap.c

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

20 months agoBIO_dgram support for BIO_sendmmsg/BIO_recvmmsg
Hugo Landau [Mon, 9 May 2022 13:24:33 +0000 (14:24 +0100)]
BIO_dgram support for BIO_sendmmsg/BIO_recvmmsg

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

20 months agoImprove chacha20 perfomance on aarch64 by interleaving scalar with SVE/SVE2
Daniel Hu [Tue, 19 Jul 2022 17:43:28 +0000 (18:43 +0100)]
Improve chacha20 perfomance on aarch64 by interleaving scalar with SVE/SVE2

The patch will process one extra block by scalar in addition to
blocks by SVE/SVE2 in parallel. This is esp. helpful in the
scenario where we only have 128-bit vector length.

The actual uplift to performance is complicated, depending on the
vector length and input data size. SVE/SVE2 implementation don't
always perform better than  Neon, but it should prevail in most
cases

On a CPU with 256-bit SVE/SVE2, interleaved processing can
handle 9 blocks in parallel (8 blocks by SVE and 1 by Scalar).
on 128-bit SVE/SVE2 it is 5 blocks. Input size that is a multiple
of 9/5 blocks on respective CPU can be typically handled at
maximum speed.

Here are test data for 256-bit and 128-bit SVE/SVE2 by running
"openssl speed -evp chacha20 -bytes 576" (and other size)

----------------------------------+---------------------------------
                256-bit SVE       |        128-bit SVE2
----------------------------------|---------------------------------
Input  576 bytes     512 bytes    |  320 bytes        256 bytes
----------------------------------|---------------------------------
SVE    1716361.91k   1556699.18k  |  1615789.06k      1302864.40k
----------------------------------|---------------------------------
Neon   1262643.44k   1509044.05k  |  680075.67k       1060532.31k
----------------------------------+---------------------------------

If the input size gets very large, the advantage of SVE/SVE2 over
Neon will fade out.

Signed-off-by: Daniel Hu <Daniel.Hu@arm.com>
Change-Id: Ieedfcb767b9c08280d7c8c9a8648919c69728fab

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

20 months agoFix memory leak with TLS1.2 compression
Juergen Christ [Fri, 19 Aug 2022 15:10:29 +0000 (17:10 +0200)]
Fix memory leak with TLS1.2 compression

Leak sanitizer reports following leak for ssl-test-new subtest
4-tlsv1_2-both-compress:

==335733==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 17728 byte(s) in 1 object(s) allocated from:
    #0 0x3ff9fbba251 in malloc (/usr/lib64/libasan.so.8+0xba251)
    #1 0x3ff9f71744f in tls_do_uncompress ssl/record/methods/tls_common.c:868
    #2 0x3ff9f7175bd in tls_default_post_process_record ssl/record/methods/tls_common.c:896
    #3 0x3ff9f715ee7 in tls_get_more_records ssl/record/methods/tls_common.c:773
    #4 0x3ff9f712209 in tls_read_record ssl/record/methods/tls_common.c:958
    #5 0x3ff9f6ef73f in ssl3_read_bytes ssl/record/rec_layer_s3.c:1235
    #6 0x3ff9f776165 in tls_get_message_header ssl/statem/statem_lib.c:1198
    #7 0x3ff9f74709b in read_state_machine ssl/statem/statem.c:624
    #8 0x3ff9f74709b in state_machine ssl/statem/statem.c:478
    #9 0x3ff9f662e61 in SSL_do_handshake ssl/ssl_lib.c:4430
    #10 0x100c55d in do_handshake_step test/helpers/handshake.c:775
    #11 0x100c55d in do_connect_step test/helpers/handshake.c:1134
    #12 0x100e85b in do_handshake_internal test/helpers/handshake.c:1544
    #13 0x1011715 in do_handshake test/helpers/handshake.c:1738
    #14 0x101d1a7 in test_handshake test/ssl_test.c:543
    #15 0x1027875 in run_tests test/testutil/driver.c:370
    #16 0x1008393 in main test/testutil/main.c:30
    #17 0x3ff9cc2b871 in __libc_start_call_main (/usr/lib64/libc.so.6+0x2b871)
    #18 0x3ff9cc2b94f in __libc_start_main_alias_2 (/usr/lib64/libc.so.6+0x2b94f)
    #19 0x100864f  (/code/openssl/test/ssl_test+0x100864f)
Direct leak of 17728 byte(s) in 1 object(s) allocated from:
    #0 0x3ff9fbba251 in malloc (/usr/lib64/libasan.so.8+0xba251)
    #1 0x3ff9f71744f in tls_do_uncompress ssl/record/methods/tls_common.c:868
    #2 0x3ff9f7175bd in tls_default_post_process_record ssl/record/methods/tls_common.c:896
    #3 0x3ff9f715ee7 in tls_get_more_records ssl/record/methods/tls_common.c:773
    #4 0x3ff9f712209 in tls_read_record ssl/record/methods/tls_common.c:958
    #5 0x3ff9f6ef73f in ssl3_read_bytes ssl/record/rec_layer_s3.c:1235
    #6 0x3ff9f776165 in tls_get_message_header ssl/statem/statem_lib.c:1198
    #7 0x3ff9f74709b in read_state_machine ssl/statem/statem.c:624
    #8 0x3ff9f74709b in state_machine ssl/statem/statem.c:478
    #9 0x3ff9f662e61 in SSL_do_handshake ssl/ssl_lib.c:4430
    #10 0x100c55d in do_handshake_step test/helpers/handshake.c:775
    #11 0x100c55d in do_connect_step test/helpers/handshake.c:1134
    #12 0x1010b09 in do_handshake_internal test/helpers/handshake.c:1550
    #13 0x1011715 in do_handshake test/helpers/handshake.c:1738
    #14 0x101d1a7 in test_handshake test/ssl_test.c:543
    #15 0x1027875 in run_tests test/testutil/driver.c:370
    #16 0x1008393 in main test/testutil/main.c:30
    #17 0x3ff9cc2b871 in __libc_start_call_main (/usr/lib64/libc.so.6+0x2b871)
    #18 0x3ff9cc2b94f in __libc_start_main_alias_2 (/usr/lib64/libc.so.6+0x2b94f)
    #19 0x100864f  (/code/openssl/test/ssl_test+0x100864f)
SUMMARY: AddressSanitizer: 35456 byte(s) leaked in 2 allocation(s).

Fix this by freeing the SSL3_RECORD structure inside the OSSL_RECORD_LAYER.

Signed-off-by: Juergen Christ <jchrist@linux.ibm.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19030)

20 months agoapps/speed.c: Wait for generated children
Juergen Christ [Mon, 29 Aug 2022 14:54:02 +0000 (16:54 +0200)]
apps/speed.c: Wait for generated children

In multi-mode, speed fork()s off several children but does not wait for them.
On Linux, this leads to wrong accounting information of getrusage used by
tools to extract running time and page faults.

Wait for every children and check the return code and termination signal.

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

20 months agoFix man page to indicate SHA256 MAC for PKCS12
Stefanos Harhalakis [Sat, 27 Aug 2022 17:36:03 +0000 (18:36 +0100)]
Fix man page to indicate SHA256 MAC for PKCS12

CLA: trivial

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

20 months agoTest that we ignore a bad record version in a plaintext TLSv1.3 record
Matt Caswell [Wed, 24 Aug 2022 15:29:52 +0000 (16:29 +0100)]
Test that we ignore a bad record version in a plaintext TLSv1.3 record

The RFC requires us to ignore this field in plaintext records - so even
if it is set incorrectly we should tolerate it.

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

20 months agoTolerate a bad record version in TLSv1.3 plaintext records
Matt Caswell [Wed, 24 Aug 2022 15:02:23 +0000 (16:02 +0100)]
Tolerate a bad record version in TLSv1.3 plaintext records

When a server responds to a second TLSv1.3 ClientHello it is required to
set the legacy_record_version to 0x0303 (TLSv1.2). The client is required
to ignore that field even if it is wrong. The recent changes to the read
record layer in PR #18132 made the record layer stricter and it was
checking that the legacy_record_version was the correct value. This
caused connection failures when talking to buggy servers that set the
wrong legacy_record_version value.

We make us more tolerant again.

Fixes #19051

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

20 months agoAdd design requirements for QUIC packet demuxer
Tomas Mraz [Thu, 5 May 2022 06:59:27 +0000 (08:59 +0200)]
Add design requirements for QUIC packet demuxer

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

20 months agoERR: Make CRYPTO_malloc() and friends report ERR_R_MALLOC_FAILURE
Dr. David von Oheimb [Mon, 12 Apr 2021 08:01:51 +0000 (10:01 +0200)]
ERR: Make CRYPTO_malloc() and friends report ERR_R_MALLOC_FAILURE

Fixes #6251

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

20 months agoConvert serverinfo in SSL_CTX_use_serverinfo() to v2.
Daniel Fiala [Tue, 24 May 2022 13:11:58 +0000 (15:11 +0200)]
Convert serverinfo in SSL_CTX_use_serverinfo() to v2.

Fixes openssl#18183.

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

20 months agoAdd missing ')' to command help
Pauli [Wed, 24 Aug 2022 01:40:13 +0000 (11:40 +1000)]
Add missing ')' to command help

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

20 months agoDrop the optimisation level for ppc64le cross-compile
Matt Caswell [Wed, 24 Aug 2022 14:10:56 +0000 (15:10 +0100)]
Drop the optimisation level for ppc64le cross-compile

The default cross compiler (gcc 9.4.0) for ppc64le on Ubunut 20.04 seems
buggy and causes a seg fault in sslapitest. This doesn't impact any other
CI cross compile platforms and does not seem to impact the gcc 10.3.0 cross
compiler.

We just drop the optimisation level on that platform.

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

20 months agoUpdates for OSSL_TIME changes
Hugo Landau [Mon, 15 Aug 2022 15:45:17 +0000 (16:45 +0100)]
Updates for OSSL_TIME changes

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

20 months agoQUIC ACK Manager, Statistics Manager and Congestion Control API
Hugo Landau [Tue, 28 Jun 2022 12:52:48 +0000 (13:52 +0100)]
QUIC ACK Manager, Statistics Manager and Congestion Control API

This is the initial implementation of the ACK Manager for OpenSSL's QUIC
support, with supporting design documentation and tests.

Because the ACK Manager also depends on the Statistics Manager, it is
also implemented here. The Statistics Manager is quite simple, so this
does not amount to a large amount of extra code.

Because the ACK Manager depends on a congestion controller, it adds a
no-op congestion controller, which uses the previously workshopped
congestion control API.

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

20 months agoCMP: correct handling of fallback subject in OSSL_CMP_CTX_setup_CRM() and its doc
Dr. David von Oheimb [Mon, 1 Aug 2022 18:34:19 +0000 (20:34 +0200)]
CMP: correct handling of fallback subject in OSSL_CMP_CTX_setup_CRM() and its doc

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/18929)

20 months agoCMP: fix crash in check_transactionID_or_nonce() on 'actual' being NULL
Dr. David von Oheimb [Mon, 1 Aug 2022 18:18:09 +0000 (20:18 +0200)]
CMP: fix crash in check_transactionID_or_nonce() on 'actual' being NULL

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/18929)

20 months agoCRMF: make create_popo_signature() check that pubkey and pkey match
Dr. David von Oheimb [Mon, 1 Aug 2022 16:54:06 +0000 (18:54 +0200)]
CRMF: make create_popo_signature() check that pubkey and pkey match

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/18930)

20 months agoadd missing CRMF API function OSSL_CRMF_CERTTEMPLATE_get0_publicKey()
Dr. David von Oheimb [Mon, 1 Aug 2022 14:47:04 +0000 (16:47 +0200)]
add missing CRMF API function OSSL_CRMF_CERTTEMPLATE_get0_publicKey()

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/18930)

20 months agoX509: clean up doc and implementation of X509{,_REQ}_check_private_key()
Dr. David von Oheimb [Mon, 1 Aug 2022 15:43:00 +0000 (17:43 +0200)]
X509: clean up doc and implementation of X509{,_REQ}_check_private_key()

Also constify X509_REQ_get0_pubkey() and X509_REQ_check_private_key().

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/18930)

20 months agox509_att.c: improve error checking and reporting and coding style
Dr. David von Oheimb [Mon, 1 Aug 2022 14:33:35 +0000 (16:33 +0200)]
x509_att.c: improve error checking and reporting and coding style

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/18931)

20 months agoadd missing doc of X509_REQ_get_extensions() and X509_REQ_add_extensions{,_nid}()
Dr. David von Oheimb [Mon, 1 Aug 2022 14:35:42 +0000 (16:35 +0200)]
add missing doc of X509_REQ_get_extensions() and X509_REQ_add_extensions{,_nid}()

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/18931)

20 months agoX509_REQ_get_extensions: add error queue entry on ill-formed extensions attribute
Dr. David von Oheimb [Mon, 1 Aug 2022 13:06:35 +0000 (15:06 +0200)]
X509_REQ_get_extensions: add error queue entry on ill-formed extensions attribute

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/18931)

20 months agoutil/wrap.pl.in: If the subprocess died with a signal, let's re-signal it
Richard Levitte [Mon, 22 Aug 2022 16:40:54 +0000 (18:40 +0200)]
util/wrap.pl.in: If the subprocess died with a signal, let's re-signal it

A simple 'kill' of the same signal on our own process should do it.
This will allow the shell that this is running under to catch it
properly, and output something if it usually does that.

Fixes #19041

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

20 months agoFix the return type for the rlayer_skip_early_data callback
Matt Caswell [Tue, 23 Aug 2022 13:45:32 +0000 (14:45 +0100)]
Fix the return type for the rlayer_skip_early_data callback

There was a copy & paste error in the definition of the
rlayer_skip_early_data callback. The return type is supposed to
be "int" but it was defined as a pointer type. This was causing
test failures on some platforms.

Fixes #19037

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

20 months agorl->enc_ctx must be non-NULL and cipher must be set
Tomas Mraz [Fri, 19 Aug 2022 10:28:42 +0000 (12:28 +0200)]
rl->enc_ctx must be non-NULL and cipher must be set

Otherwise ssl3_cipher() cannot work properly.

Fixes Coverity CID 1509401

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

20 months agoDo not use RLAYERfatal on NULL RLAYER
Tomas Mraz [Fri, 19 Aug 2022 10:19:55 +0000 (12:19 +0200)]
Do not use RLAYERfatal on NULL RLAYER

or on record layer that is to be freed anyway.

Fixes Coverity CID 15094021509403

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

20 months agoCoverity 1508532: out of bounds access
Pauli [Mon, 22 Aug 2022 01:06:57 +0000 (11:06 +1000)]
Coverity 1508532: out of bounds access

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

20 months agoOSSL_HTTP_REQ_CTX_nbio: add support for partial content-type string matching
Dr. David von Oheimb [Tue, 28 Jun 2022 15:23:45 +0000 (17:23 +0200)]
OSSL_HTTP_REQ_CTX_nbio: add support for partial content-type string matching

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

20 months agoapp_http_tls_cb() and tls_error_hint(): code cleanup
Dr. David von Oheimb [Tue, 28 Jun 2022 10:10:49 +0000 (12:10 +0200)]
app_http_tls_cb() and tls_error_hint(): code cleanup

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

20 months agoMakefile: Generate crypto objects only as far as needed
Dr. David von Oheimb [Tue, 11 May 2021 13:35:43 +0000 (15:35 +0200)]
Makefile: Generate crypto objects only as far as needed

Reviewed-by: Richard Levitte <levitte@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/15224)

20 months agoMakefile: Call mknum.pl on 'make ordinals' only if needed
Dr. David von Oheimb [Tue, 11 May 2021 10:59:03 +0000 (12:59 +0200)]
Makefile: Call mknum.pl on 'make ordinals' only if needed

Reviewed-by: Richard Levitte <levitte@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/15224)

20 months agoSupport decode SM2 parameters
K1 [Mon, 18 Jul 2022 17:18:12 +0000 (01:18 +0800)]
Support decode SM2 parameters

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

20 months agoMoving notify check after the no time check
Ryan Kelley [Tue, 16 Aug 2022 05:28:50 +0000 (05:28 +0000)]
Moving notify check after the no time check

CLA: trivial

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

20 months agoopenssl speed fails in FIPS mode
Dmitry Belyavskiy [Tue, 21 Dec 2021 15:52:25 +0000 (16:52 +0100)]
openssl speed fails in FIPS mode

...because it uses md5 for HMAC tests. Skip md5 in case of its
unavailability.

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

20 months agoFix typo in migration guide
Tobias Nießen [Sat, 20 Aug 2022 16:56:21 +0000 (18:56 +0200)]
Fix typo in migration guide

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

20 months agoAlways automatically add -DPEDANTIC with enable-ubsan
Tomas Mraz [Fri, 19 Aug 2022 13:48:34 +0000 (15:48 +0200)]
Always automatically add -DPEDANTIC with enable-ubsan

To avoid reports like: #19028

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

20 months agoFix doc-nits
Todd Short [Mon, 22 Aug 2022 18:12:50 +0000 (14:12 -0400)]
Fix doc-nits

PR #19031 updated options that that were listed as commands, these
options were already in openssl-list.pod.in, so they are redundant
in openssl.pod.

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

20 months agoevp: Use functions instead of direct structure field references
Tianjia Zhang [Mon, 30 Aug 2021 07:34:06 +0000 (15:34 +0800)]
evp: Use functions instead of direct structure field references

AES and chacha20poly1305 also have some codes that directly reference
the fields in the EVP_CIPHER_CTX structure, such as 'ctx->buf' and
'ctx->encrypt', in order to make the code style uniform, use the
corresponding interface API instead of direct field references.

Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16465)

20 months agoevp: Simplify ARIA aead cipher definition
Tianjia Zhang [Mon, 30 Aug 2021 06:28:07 +0000 (14:28 +0800)]
evp: Simplify ARIA aead cipher definition

Remove fixed macro variables, only keep the cipher mode name and
key length.

Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16465)

20 months agoAdd BSD-armv4 target based on linux-armv4
Piotr Kubaj [Fri, 29 Jul 2022 10:47:29 +0000 (12:47 +0200)]
Add BSD-armv4 target based on linux-armv4

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

20 months agoClarify dashes are required for openssl list command
Jeff Croxell [Fri, 19 Aug 2022 02:30:20 +0000 (21:30 -0500)]
Clarify dashes are required for openssl list command

Fixes #19013

CLA: trivial

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

20 months agoUpdate gitignore
Todd Short [Thu, 18 Aug 2022 15:05:43 +0000 (11:05 -0400)]
Update gitignore

Add test/timing_load_creds

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

20 months agoBIO_sendmmsg/BIO_recvmmsg (API only)
Hugo Landau [Mon, 1 Aug 2022 09:33:00 +0000 (10:33 +0100)]
BIO_sendmmsg/BIO_recvmmsg (API only)

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

20 months agoLimit the size of various MAXCHUNK definitions
Pauli [Mon, 15 Aug 2022 04:49:17 +0000 (14:49 +1000)]
Limit the size of various MAXCHUNK definitions

The current code has issues when sizeof(long) <> sizeof(size_t).  The two
types are assumed to be interchangeable and them being different will
cause crashes and endless loops.

This fix limits the maximum chunk size for many of the symmetric ciphers
to 2^30 bytes.  This chunk size limits the amount of data that will
be encrypted/decrypted in one lump.  The code internally handles block
of data later than the chunk limit, so this will present no difference
to the caller.  Any loss of efficiency due to limiting the chunking to
1Gbyte rather than more should be insignificant.

Fixes Coverity issues:
    15084981508500 - 15085051508507 - 15085271508529 - 1508533,
    1508535 - 150853715085391508541 - 15085491508551 - 1508569 &
    1508571 - 1508582.

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

20 months agoCoverity: misuses of time_t
Pauli [Tue, 16 Aug 2022 01:05:02 +0000 (11:05 +1000)]
Coverity: misuses of time_t

Coverity 1508506:

    Fixes a bug in the cookie code which would have caused problems for
    ten minutes before and after the lower 32 bits of time_t rolled over.

Coverity 1508534 & 1508540:

    Avoid problems when the lower 32 bits of time_t roll over by delaying
    the cast to integer until after the time delta has been computed.

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19004)

21 months agoCheck record layer callbacks are non-null
Matt Caswell [Tue, 9 Aug 2022 14:52:27 +0000 (15:52 +0100)]
Check record layer callbacks are non-null

The current libssl code always ensures that the callbacks are non-null.
However, the record layer itself wasn't checkthing this. We ensure it does.

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

21 months agoFormatting cleanups
Matt Caswell [Wed, 27 Jul 2022 13:20:23 +0000 (14:20 +0100)]
Formatting cleanups

Some minor formatting cleanups and other minor tweaks.

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

21 months agoRemove redefinition of macros
Matt Caswell [Wed, 27 Jul 2022 15:44:01 +0000 (16:44 +0100)]
Remove redefinition of macros

Some macros were redefined in ssl3_cbc.c. We remove the redefinitions

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

21 months agoRemove redefinition of SSL_AD_NO_ALERT
Matt Caswell [Wed, 27 Jul 2022 13:54:48 +0000 (14:54 +0100)]
Remove redefinition of SSL_AD_NO_ALERT

The SSL_AD_NO_ALERT value was defined in two places. We centralise its
definition.

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

21 months agoEnsure the rrl object is set to NULL after it is freed
Matt Caswell [Wed, 27 Jul 2022 13:52:13 +0000 (14:52 +0100)]
Ensure the rrl object is set to NULL after it is freed

Once we free the rrl object we should NULL it to prevent a dangling ref
to it. Otherwise we could get a double free.

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

21 months agoRename some functions to be more consistent
Matt Caswell [Wed, 27 Jul 2022 13:50:16 +0000 (14:50 +0100)]
Rename some functions to be more consistent

Some functions in the record layer were called rlayer_*, but most were
called tls_*. We standardise on the latter.

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

21 months agoRename DTLS1_BITMAP to DTLS_BITMAP
Matt Caswell [Wed, 27 Jul 2022 13:44:28 +0000 (14:44 +0100)]
Rename DTLS1_BITMAP to DTLS_BITMAP

The 1 in DTLS1 is confusing and is removed. We also tweak the structure
to always be able to track 64 packets regardless of whether we are on a
32 bit or 64 bit system.

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

21 months agoRemove ssl/record/README.md
Matt Caswell [Wed, 27 Jul 2022 13:40:16 +0000 (14:40 +0100)]
Remove ssl/record/README.md

This file contains design details for the old record layer and is no
longer relevant for the new design.

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

21 months agoStandardise type for epoch
Matt Caswell [Wed, 27 Jul 2022 13:37:27 +0000 (14:37 +0100)]
Standardise type for epoch

The value for epoch was being represented internally via various types:
uint16_t, unsigned short, unsigned int, unsigned long

We standardise on uint16_t

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

21 months agoRemove the SSL3_RECORD read field
Matt Caswell [Wed, 27 Jul 2022 13:28:36 +0000 (14:28 +0100)]
Remove the SSL3_RECORD read field

The read field is no longer used and can be safely removed.

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

21 months agoAdd a CHANGES.md entry for the record layer changes
Matt Caswell [Tue, 26 Jul 2022 15:41:55 +0000 (16:41 +0100)]
Add a CHANGES.md entry for the record layer changes

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

21 months agoClean up some SCTP releated issues
Matt Caswell [Tue, 26 Jul 2022 14:25:03 +0000 (15:25 +0100)]
Clean up some SCTP releated issues

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

21 months agoEnsure various record layer options can be updated
Matt Caswell [Tue, 26 Jul 2022 13:34:38 +0000 (14:34 +0100)]
Ensure various record layer options can be updated

We would like the capability for the options/mode/read_ahead settings
to be updateable after the record layer object has been instantiated.

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

21 months agoRemove some redundant code
Matt Caswell [Tue, 26 Jul 2022 11:44:09 +0000 (12:44 +0100)]
Remove some redundant code

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

21 months agoUpdate the tls13encryptiontest for new read record layer
Matt Caswell [Tue, 26 Jul 2022 11:44:28 +0000 (12:44 +0100)]
Update the tls13encryptiontest for new read record layer

The tls13encryption is an internal test that reaches inside libssl
to test encryption/decryption of records. It needs to be amended for the
new code structure so that it is testing the equivalent things as before.

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

21 months agoImplement a human readable state function for the record layer
Matt Caswell [Fri, 22 Jul 2022 14:38:26 +0000 (15:38 +0100)]
Implement a human readable state function for the record layer

This allows querying of the record layer to get a human readable state
string out. This resolves two outstanding TODO comments and enables us
to remove the rstate variable from s->rlayer.

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

21 months agoCorrect some formatting errors in tls1_meth.c
Matt Caswell [Fri, 22 Jul 2022 14:04:07 +0000 (15:04 +0100)]
Correct some formatting errors in tls1_meth.c

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

21 months agoMove SSL_MODE_RELEASE_BUFFERS into the read record layer
Matt Caswell [Fri, 22 Jul 2022 13:30:53 +0000 (14:30 +0100)]
Move SSL_MODE_RELEASE_BUFFERS into the read record layer

This resolves an outstanding "TODO" item.

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

21 months agoRemove a redundant TODO
Matt Caswell [Fri, 22 Jul 2022 13:23:25 +0000 (14:23 +0100)]
Remove a redundant TODO

If read_ahead data is left over when a record layer closes down, there is
already code present to push into the "next" BIO. So the TODO removed here
is no longer relevant.

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

21 months agoCleanse the SSLv3 MAC secret when we clean up the read record layer
Matt Caswell [Fri, 22 Jul 2022 13:16:33 +0000 (14:16 +0100)]
Cleanse the SSLv3 MAC secret when we clean up the read record layer

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

21 months agoMove some fields out of the SSL object and into the record layer object
Matt Caswell [Fri, 22 Jul 2022 11:39:24 +0000 (12:39 +0100)]
Move some fields out of the SSL object and into the record layer object

Fields such as rrlmethod and rrl are entirely related to the record layer,
and so should be in that object.

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

21 months agoRemove an unnecessary setup of the read buffer
Matt Caswell [Thu, 21 Jul 2022 16:17:05 +0000 (17:17 +0100)]
Remove an unnecessary setup of the read buffer

Now everything has been moved to the record layer the additional check
for setting up the read buffer is not needed and can be removed.

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

21 months agoClear away some unused fields and cruft in the record layer
Matt Caswell [Thu, 21 Jul 2022 16:01:54 +0000 (17:01 +0100)]
Clear away some unused fields and cruft in the record layer

Now that the read record layer has moved to the new architecture we can
clear some of the old stuff away.

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

21 months agoRemove some references to rlayer.rstate
Matt Caswell [Thu, 21 Jul 2022 14:39:39 +0000 (15:39 +0100)]
Remove some references to rlayer.rstate

This also fixes ssl3_pending while we are at it

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

21 months agoEnsure we use a dgram mem BIO for the DTLS record layer
Matt Caswell [Thu, 21 Jul 2022 14:13:46 +0000 (15:13 +0100)]
Ensure we use a dgram mem BIO for the DTLS record layer

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

21 months agoRemove some more redundant TODO(RECLAYER) comments
Matt Caswell [Wed, 20 Jul 2022 14:22:41 +0000 (15:22 +0100)]
Remove some more redundant TODO(RECLAYER) comments

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

21 months agoResolve a TODO(RECLAYER) in the SSLv3 code
Matt Caswell [Wed, 20 Jul 2022 14:15:32 +0000 (15:15 +0100)]
Resolve a TODO(RECLAYER) in the SSLv3 code

We remove some code outside of the record layer which is no longer
relevant since its functions are now performed by the new record layer
code. This removes a TODO(RECLAYER) as a result.

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

21 months agoRemove some TODO(RECLAYER) comments
Matt Caswell [Wed, 20 Jul 2022 13:49:53 +0000 (14:49 +0100)]
Remove some TODO(RECLAYER) comments

Some TODO(RECLAYER) comments are no longer necessary and can be removed.

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

21 months agoRemove some unnecessary function pointers from OSSL_RECORD_METHOD
Matt Caswell [Tue, 19 Jul 2022 14:49:51 +0000 (15:49 +0100)]
Remove some unnecessary function pointers from OSSL_RECORD_METHOD

We had some temporary function pointers in OSSL_RECORD_METHOD which were
only necessary during the process of refactoring the read record layer.
These are no longer required so can be removed.

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

21 months agoStandardise some DTLS record layer naming
Matt Caswell [Mon, 27 Jun 2022 16:10:59 +0000 (17:10 +0100)]
Standardise some DTLS record layer naming

Remove references to dtls1_* and just use dtls_*

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

21 months agoRemove some remaining SSL object references from DTLS record layer
Matt Caswell [Fri, 24 Jun 2022 15:45:14 +0000 (16:45 +0100)]
Remove some remaining SSL object references from DTLS record layer

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

21 months agoPush unprocessed DTLS records from one record layer object to next
Matt Caswell [Fri, 24 Jun 2022 15:32:06 +0000 (16:32 +0100)]
Push unprocessed DTLS records from one record layer object to next

We add unprocessed DTLS records to the unprocessed record queue. When
the record layer closes down we write the unprocessed records to the
next record layer object.

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

21 months agoRemove reliance on the SSL object from the DTLS read record layer code
Matt Caswell [Wed, 8 Jun 2022 13:52:44 +0000 (14:52 +0100)]
Remove reliance on the SSL object from the DTLS read record layer code

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

21 months agoMove some DTLS read code into the read record layer
Matt Caswell [Thu, 2 Jun 2022 15:29:04 +0000 (16:29 +0100)]
Move some DTLS read code into the read record layer

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

21 months agoRemove some final references to the SSL object in the record layer
Matt Caswell [Wed, 25 May 2022 16:30:33 +0000 (17:30 +0100)]
Remove some final references to the SSL object in the record layer

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

21 months agoRemove the separation betweeen enc_read_ctx and enc_write_ctx
Matt Caswell [Wed, 25 May 2022 16:19:33 +0000 (17:19 +0100)]
Remove the separation betweeen enc_read_ctx and enc_write_ctx

Similarly with read_hash and write_hash. In the new model we have a
separate record layer object for reading and writing. Therefore we don't
need to distinguish between reading and writing inside the record layer
object in the encryption and md ctxs.

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

21 months agoEnable the record layer to call the ssl_security callback
Matt Caswell [Wed, 25 May 2022 16:10:38 +0000 (17:10 +0100)]
Enable the record layer to call the ssl_security callback

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

21 months agoUse a record layer specific message callback
Matt Caswell [Wed, 25 May 2022 15:41:30 +0000 (16:41 +0100)]
Use a record layer specific message callback

Don't use the message callback from the SSL object. Instead we use a
wrapper callback so that the record layer does not need to be aware of the
SSL object.

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

21 months agoMove early data counting out of the SSL object and into the record layer
Matt Caswell [Wed, 25 May 2022 14:16:48 +0000 (15:16 +0100)]
Move early data counting out of the SSL object and into the record layer

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

21 months agoMove the sequence number into the OSSL_RECORD_LAYER object
Matt Caswell [Tue, 24 May 2022 15:00:50 +0000 (16:00 +0100)]
Move the sequence number into the OSSL_RECORD_LAYER object

This removes some references to the SSL object from the record layer.

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

21 months agoRemove use of SSL object for fragment length checking in record layer
Matt Caswell [Mon, 23 May 2022 10:31:53 +0000 (11:31 +0100)]
Remove use of SSL object for fragment length checking in record layer

Pass the max fragment length to the record layer when it is applicable
to avoid the need to go through the SSL object.

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

21 months agoRemove use of ossl_statem_in_error() from the record layer
Matt Caswell [Fri, 20 May 2022 15:58:51 +0000 (16:58 +0100)]
Remove use of ossl_statem_in_error() from the record layer

We remove the dependency on the SSL object. Instead we check if the
record layer has already set an alert code.

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

21 months agoMake the record layer directly aware of EtM
Matt Caswell [Fri, 20 May 2022 15:54:12 +0000 (16:54 +0100)]
Make the record layer directly aware of EtM

We no longer have to go through the SSL object to discover whether EtM has
been negotiated.

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

21 months agoRemove SSL_USE_EXPLICT_IV() from the record layer methods
Matt Caswell [Thu, 19 May 2022 16:11:13 +0000 (17:11 +0100)]
Remove SSL_USE_EXPLICT_IV() from the record layer methods

Instead we introduce RLAYER_USE_EXPLICIT_IV(). This removes a dependency
on the SSL object.

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

21 months agoRemove some use of SSL object from record layer
Matt Caswell [Thu, 19 May 2022 15:58:45 +0000 (16:58 +0100)]
Remove some use of SSL object from record layer

Remove SSL_IS_TLS13() and hello_retry_request

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