1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-03 06:45:37 -08:00
Commit Graph

42 Commits

Author SHA1 Message Date
beck
689a9b7ed5 Remove GOST and STREEBOG support from libssl.
This version of GOST is old and not anywhere close to compliant with
modern GOST standards. It is also very intrusive in libssl and
makes a mess everywhere.  Efforts to entice a suitably minded anyone
to care about it have been unsuccessful.

At this point it is probably best to remove this, and if someone
ever showed up who truly needed a working version, it should be
a clean implementation from scratch, and have it use something
closer to the typical API in libcrypto so it would integrate less
painfully here.

This removes it from libssl in preparation for it's removal from
libcrypto with a future major bump

ok tb@
2024-02-03 15:58:33 +00:00
tb
8afa8197cd Switch from EVP_CIPHER_type() to EVP_CIPHER_nid()
EVP_CIPHER_type() will never return NID_gost89_cnt since it has no
associated ASN1_OBJECT. Switching to EVP_CIPHER_nid() has a slight
chance of working. Do that before beck applies the flensing knife.

ok beck
2024-01-18 16:30:43 +00:00
beck
56f24513ef fix comment to unbreak things that care about warnings
ok tb@ krw@
2023-07-08 20:38:23 +00:00
beck
71e048498e Hide all public symbols in libssl
With the guentherizer 9000

ok tb@
2023-07-08 16:40:13 +00:00
tb
c9675a23de Make internal header file names consistent
Libcrypto currently has a mess of *_lcl.h, *_locl.h, and *_local.h names
used for internal headers. Move all these headers we inherited from
OpenSSL to *_local.h, reserving the name *_internal.h for our own code.
Similarly, move dtls_locl.h and ssl_locl.h to dtls_local and ssl_local.h.
constant_time_locl.h is moved to constant_time.h since it's special.

Adjust all .c files in libcrypto, libssl and regress.

The diff is mechanical with the exception of tls13_quic.c, where
#include <ssl_locl.h> was fixed manually.

discussed with jsing,
no objection bcook
2022-11-26 16:08:50 +00:00
jsing
ee4250f602 Convert the legacy TLS stack to tls_content.
This converts the legacy TLS stack to tls_content - records are now
opened into a tls_content structure, rather than being written back into
the same buffer that the sealed record was read into.

This will allow for further clean up of the legacy record layer.

ok tb@
2022-11-11 17:15:26 +00:00
tb
f9a06750c8 Convert the new record layers to opaque EVP_AEAD_CTX
ok jsing
2022-01-14 09:12:15 +00:00
jsing
a0f5591df7 Mop up enc_read_ctx and read_hash.
These are no longer public, so we can mop them up along with the machinery
needed to set/clear them.

ok beck@ tb@
2021-10-23 15:02:27 +00:00
jsing
44aae0c184 Replace DTLS r_epoch with the read epoch from the TLSv1.2 record layer.
ok inoguchi@ tb@
2021-08-30 19:12:25 +00:00
jsing
609ec8b1eb Move to an AEAD nonce allocated in the TLSv1.2 record layer.
There is little to gain by mallocing and freeing the AEAD nonce for each
record - move to an AEAD nonce allocated for the record layer, which
matches what we do for TLSv1.3.

ok inoguchi@ tb@
2021-08-30 19:00:49 +00:00
jsing
c8e2fc2ba4 Provide the ability to set the initial DTLS epoch value.
This allows for regress to test edge cases for epoch handling.

ok tb@
2021-06-19 16:52:47 +00:00
jsing
60ac916a50 Simplify nonce handling in the TLSv1.2 record layer.
Pass the CBS for the sequence number through, which also allows us to do
more sensible length checks. Also, add a missing length check while here.

ok inoguchi@ tb@
2021-06-14 14:22:52 +00:00
jsing
7b133c71d1 Absorb SSL_AEAD_CTX into struct tls12_record_protection.
The information contained in SSL_AEAD_CTX really belongs in the
tls12_record_protection struct. Absorb SSL_AEAD_CTX, using more appropriate
types in the process.

ok tb@
2021-05-16 15:49:01 +00:00
jsing
60497c21ae Zero the tls12_record_protection struct instead of individual fields.
In tls12_record_protection_clear(), rather than zeroing or NULLing
individual fields once a pointer has been freed, zero the entire struct once
the pointers have been dealt with.

ok tb@
2021-05-16 15:21:10 +00:00
jsing
2f4e7cfa05 Replace DTLS w_epoch with epoch from TLSv1.2 record layer.
ok inoguchi@ tb@
2021-05-05 19:52:00 +00:00
jsing
d7351ddfc5 Rewrite TLSv1.2 key block handling.
For TLSv1.2 a single key block is generated, then partitioned into
individual secrets for use as IVs and keys. The previous implementation
splits this across two functions tls1_setup_key_block() and
tls1_change_cipher_state(), which means that the IV and key sizes have to
be known in multiple places.

This implementation generates and partitions the key block in a single
step, meaning that the secrets are then simply handed out when requested.

ok inoguchi@ tb@
2021-05-05 10:05:27 +00:00
jsing
9576522bca Remove new_sym_enc and new_aead.
These can be replaced with accessors that allow this information to be
retrieved from the new record layer.

ok inoguchi@ tb@
2021-04-19 17:26:39 +00:00
jsing
e3ae3cd6c9 Move the TLSv1.2 record number increment into the new record layer.
This adds checks (based on the TLSv1.3 implementation) to ensure that the
TLS/DTLS sequence numbers do not wrap, as required by the respective RFCs.

ok inoguchi@ tb@
2021-03-29 16:19:15 +00:00
tb
27e46ee688 Fully initialize rrec in tls12_record_layer_open_record_protected
The CBC code path initializes rrec.padding_length in an indirect fashion
and later makes use of it for copying the MAC. This is confusing some
static analyzers as well as people investigating the whining. Avoid this
confusion and add a bit of robustness by clearing the stack variable up
front.

ok jsing
2021-03-21 19:08:22 +00:00
jsing
2261fe7933 Separate variable declaration and assignment.
Requested by tb@
2021-03-02 17:26:25 +00:00
jsing
23d98bd4bc Replace two handrolled tls12_record_protection_engaged().
Noted by tb@
2021-03-02 17:24:37 +00:00
jsing
ffd1a0d404 Move key/IV length checks closer to usage sites.
Also add explicit checks against EVP_CIPHER_iv_length() and
EVP_CIPHER_key_length().

Requested by tb@ during review.

ok tb@
2021-03-02 17:18:59 +00:00
jsing
747682f9eb Add tls12_record_protection_unused() and call from CCS functions.
This moves the check closer to where a leak could occur and checks all
pointers in the struct.

Suggested by tb@ during review.

ok tb@
2021-03-02 17:16:44 +00:00
jsing
2935b8f4e5 Move handling of cipher/hash based cipher suites into the new record layer.
ok tb@
2021-02-27 14:20:50 +00:00
jsing
fe0929e2b6 Identify DTLS based on the version major value.
This avoids the need to match specific DTLS version numbers.
2021-02-27 13:38:35 +00:00
jsing
6eb9eb18bb Remove direct assignment of aead_ctx.
Now that AEAD is handled internally, we should no longer be assigning
aead_ctx directly, as this will result in a leak. Missed during the
previous change.
2021-01-28 18:32:46 +00:00
jsing
c37fa200cd Move AEAD handling into the new TLSv1.2 record layer.
ok tb@
2021-01-28 17:00:38 +00:00
jsing
f2284ad0cd Move sequence numbers into the new TLSv1.2 record layer.
This allows for all of the DTLS sequence number save/restore code to be
removed.

ok inoguchi@ "whee!" tb@
2021-01-26 14:22:19 +00:00
tb
679f355aa8 Drop unneeded cast in seal_record_protected_cipher
eiv_len was changed from an int to a size_t in r1.10, so casting it
to a size_t is now a noop.

ok jsing
2021-01-20 07:05:25 +00:00
jsing
a802a16ada Add code to handle change of cipher state in the new TLSv1.2 record layer.
This provides the basic framework for handling change of cipher state in
the new TLSv1.2 record layer, creating new record protection. In the DTLS
case we retain the previous write record protection and can switch back to
it when retransmitting. This will allow the record layer to start owning
sequence numbers and encryption/decryption state.

ok inoguchi@ tb@
2021-01-19 19:07:39 +00:00
jsing
1365e68c83 Provide functions to determine if TLSv1.2 record protection is engaged.
Call these functions from code that needs to know if we've changed cipher
state and enabled record protection, rather than inconsistently checking
various pointers from other places in the code base. This also fixes a
minor bug where the wrong pointers are checked if we're operating with
AEAD.

ok inoguchi@ tb@
2021-01-19 18:57:09 +00:00
jsing
9123ae000a Provide record layer overhead for DTLS.
Rather than manually calculating the maximum record layer overhead in the
DTLS code, have the record layer provide this information. This also makes
it work correctly with AEAD ciphersuites.

ok inoguchi@ tb@
2021-01-19 18:51:08 +00:00
jsing
1c1840fbfd Factor out code for explicit IV length, block size and MAC length.
Pull this code up into the record protection struct, which means we only
need the length checks in one place. This code will soon be used for
additional purposes.

ok inoguchi@ tb@
2021-01-19 18:34:02 +00:00
jsing
108b1a0f10 Clean up sequence number handing in the new TLSv1.2 record layer.
Handle protocol specific (DTLS vs TLS) sequence number differences in the
open/seal record functions and propagate the sequence number through to
the called functions. This means that DTLS specific knowledge is limited
to two functions and also avoids building sequence numbers multiple times
over. As a result, the DTLS explicit sequence number is now extracted from
the record header and passed through for processing, which makes the read
epoch handling redundant.

ok inoguchi@ tb@
2021-01-13 18:20:54 +00:00
jsing
a13669d20d Split the record protection from the TLSv1.2 record layer.
When changing cipher state, DTLS requires that the previous write
protection state remain available so that messages can be retransmitted.
Currently, this is done by DTLS saving and restoring various pointers,
along with special casing to not free the cipher and hash where it would
normally be freed for TLS (and requiring DTLS to free things at the
appropriate times).

This can be handled in a much cleaner manner by splitting the record
protection from the record layer. This allows for the previous write state
to be retained and restored by swapping a single pointer. Additionally,
it also results in more readable and manageable code.

This diff simply splits the record protection from the record layer -
future changes will add support for maintaining and switching between
write states.

ok inoguchi@ tb@
2021-01-12 17:47:20 +00:00
jsing
3e9ce141db Make tls12_record_layer_free() NULL safe.
This is not an issue currently, but avoids future surprises.

Noted by tb@
2021-01-07 15:37:19 +00:00
jsing
b77c9477f4 Move the read MAC key into the TLSv1.2 record layer.
ok inoguchi@ tb@
2021-01-07 15:32:59 +00:00
jsing
40038cb828 Reimplement the TLSv1.2 record handling for the read side.
This is the next step in replacing the TLSv1.2 record layer.

The existing record handling code does decryption and processing in
place, which is not ideal for various reasons, however it is retained
for now as other code depends on this behaviour. Additionally, CBC
requires special handling to avoid timing oracles - for now the
existing timing safe code is largely retained.

ok beck@ inoguchi@ tb@
2020-10-03 17:35:16 +00:00
jsing
de70c6e8e3 Group seal record functions together.
No functional change.
2020-09-16 17:15:01 +00:00
jsing
89dfa477b7 Split the tls12_record_layer_write_mac() function.
Split the existing tls12_record_layer_write_mac() function so that we can
soon reuse part of it for the read side.

No functional change.

ok tb@
2020-09-15 16:07:17 +00:00
jsing
11d1e10cf9 Correct a failure case in tls12_record_layer_seal_record_protected()
This should be a 'goto err' rather than returning.
2020-09-15 15:11:58 +00:00
jsing
acef91a04b Start replacing the existing TLSv1.2 record layer.
This takes the same design/approach used in TLSv1.3 and provides an
opaque struct that is self contained and cannot reach back into other
layers. For now this just implements/replaces the writing of records
for DTLSv1/TLSv1.0/TLSv1.1/TLSv1.2. In doing so we stop copying the
plaintext into the same buffer that is used to transmit to the wire.

ok inoguchi@ tb@
2020-08-30 15:40:19 +00:00