1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00
Commit Graph

247 Commits

Author SHA1 Message Date
jsing
8890443aec Pass the session ID down to the session/ticket handling code as a CBS.
Convert ssl_get_prev_session(), tls1_process_ticket() and
tls1_decrypt_ticket() to handle the session ID from the client hello
as a CBS. While here also swap the order of arguments for
tls1_decrypt_ticket() so that it is consistent with the other functions.

ok tb@
2019-04-22 15:12:20 +00:00
jsing
18e023dcb2 Inline and remove the tlsext_tick_md macro.
There is not much point having a tlsext_tick_md macro that replaces
EVP_sha256() in two places, when the cipher is just hardcoded.

ok tb@
2019-04-22 14:49:42 +00:00
jsing
e58f6cbccf Clean up the cipher/digest table mess.
The original implementation allows for libcrypto to be compiled without a
given algorithm and libssl then detects that ciphers or digests are
unavailable so that it can disable the associated cipher suites.

This is unnecessary since we do not compile out algorithms.

ok beck@, tb@ (a while back)
2019-04-04 16:44:24 +00:00
jsing
8903658485 Strip out all of the pkey to sigalg and sigalg to pkey linkages.
These are no longer used now that we defer signature algorithm selection.

ok beck@
2019-03-25 17:33:26 +00:00
jsing
0f039a7e23 tls1_process_sigalgs() is no longer needed.
ok beck@
2019-03-25 17:27:31 +00:00
jsing
96b13b4552 Defer sigalgs selection until the certificate is known.
Previously the signature algorithm was selected when the TLS extension was
parsed (or the client received a certificate request), however the actual
certificate to be used is not known at this stage. This leads to various
problems, including the selection of a signature algorithm that cannot be
used with the certificate key size (as found by jeremy@ via ruby regress).

Instead, store the signature algorithms list and only select a signature
algorithm when we're ready to do signature generation.

Joint work with beck@.
2019-03-25 17:21:18 +00:00
jsing
d80722782b Remove ssl_get_server_send_cert() which is now unused.
ok beck@ tb@
2019-03-25 16:37:52 +00:00
jsing
0f99faba20 Rework ssl3_output_cert_chain() to take a CERT_PKEY and consider chains.
We will now include the certificates in the chain in the certificate list,
or use the existing extra_certs if present. Failing that we fall back to
the automatic chain building if not disabled.

This also simplifies the code significantly.

ok beck@ tb@
2019-03-25 16:35:48 +00:00
jsing
eef9ac4d61 Add a chain member to CERT_PKEY and provide functions for manipulating it.
Note that this is not the full chain, as the leaf certificate currently
remains in the x509 member of CERT_PKEY. Unfortunately we've got to
contend with the fact that some OpenSSL *_chain_* APIs exclude the leaf
certificate while others include it...

ok beck@ tb@
2019-03-25 16:24:57 +00:00
tb
696c451cf6 revert "Move struct ssl_handshake_tls13_st definition", i.e., move
SSL_HANDSHAKE_TLS13 back to ssl_locl.h.

discussed with jsing and inoguchi
2019-02-25 19:40:05 +00:00
inoguchi
448f0a7a1c Move struct ssl_handshake_tls13_st definition
This solves build error on luna88k with gcc3.

ok aoyama@ jca@ jsing@ tb@
2019-02-25 14:36:25 +00:00
jsing
efee3f2f19 Provide a TLS 1.3 capable client method.
ok tb@
2019-02-14 17:50:07 +00:00
jsing
0984cefdae Preserve the transcript hash at specific stages of the TLSv1.3 handshake.
There are various points where we need the hash of all messages prior to
the current message. Support this by having the handshake code preserve
the transcript hash prior to recording the current message, which avoids
the need to sprinkle this throughout multiple handlers.

ok inoguchi@ tb@
2019-02-10 13:04:29 +00:00
jsing
df40b63ba2 Rename tls1_handshake_hash*() to tls1_transcript_hash*().
While handshake hash is correct (in as far as it is a hash of handshake
messages), using tls1_transcript_hash*() aligns them with the naming of the
tls1_transcript*() functions. Additionally, the TLSv1.3 specification uses
Transcript-Hash and "transcript hash", which this matches.

ok inoguchi@ tb@
2019-02-09 15:26:15 +00:00
beck
1a4ee2c663 Add server side of versions, keyshare, and client and server of cookie
extensions for tls1.3.
versions is currently defanged to ignore its result until tls13 server
side wired in full, so that server side code still works today when
we only support tls 1.2
ok bcook@ tb@ jsing@
2019-01-24 02:56:41 +00:00
beck
4c111e0031 move the extensions_seen into the handshake struct
ok jsing@
2019-01-24 01:50:41 +00:00
beck
3e29903be5 Modify sigalgs extension processing to accomodate TLS 1.3.
- Make a separate sigalgs list for TLS 1.3 including only modern
algorithm choices which we use when the handshake will not negotiate
TLS 1.2.
- Modify the legacy sigalgs for TLS 1.2 to include the RSA PSS algorithms as
mandated by RFC8446 when the handshake will permit negotiation of TLS 1.2
from a 1.3 handshake.
ok jsing@ tb@
2019-01-23 18:39:28 +00:00
beck
174eabd668 revert previous, accidentally contained another diff in addition
to the one I intended to commit
2019-01-23 18:24:40 +00:00
beck
fbffb3299c Modify sigalgs extension processing for TLS 1.3.
- Make a separate sigalgs list for TLS 1.3 including only modern
  algorithm choices which we use when the handshake will not negotiate
  TLS 1.2
- Modify the legacy sigalgs for TLS 1.2 to include the RSA PSS algorithms as
  mandated by RFC8446 when the handshake will permit negotiation of TLS 1.2
ok jsing@ tb@
2019-01-23 16:46:04 +00:00
tb
a36841cf36 Add ssl_cipher_is_permitted(), an internal helper function that
will be used in a few places shortly, e.g. in
ssl_cipher_list_to_bytes().

ok jsing
2019-01-21 10:28:52 +00:00
jsing
8c6a3df3fe Move struct tls13_ctx into a header since other things need access to it.
While here, rename struct handshake to struct handshake_stage to avoid
potential ambiguity/conflict with the handshake data struct. Also add
forward and back pointers between SSL and struct tls13_ctx.

ok tb@
2019-01-21 06:58:44 +00:00
beck
8c287c711a Add client side of supported versions and keyshare extensions with basic regress
ok jsing@
2019-01-18 12:09:52 +00:00
jsing
372de723db Fix DTLS transcript handling for HelloVerifyRequest.
If DTLS sees a HelloVerifyRequest the transcript is reset - the previous
tls1_init_finished_mac() function could be called multiple times and would
discard any existing state. The replacement tls1_transcript_init() is more
strict and fails if a transcript already exists.

Provide an explicit tls1_transcript_reset() function and call it from the
appropriate places. This also lets us make DTLS less of a special snowflake
and call tls1_transcript_init() in the same place as used for TLS.

ok beck@ tb@
2018-11-21 15:13:29 +00:00
beck
fbe97c861d Stop keeping track of sigalgs by guessing it from digest and pkey,
just keep the sigalg around so we can remember what we actually
decided to use.
ok jsing@
2018-11-10 01:19:09 +00:00
beck
96b1ac03f6 Reimplement the sigalgs processing code into a new implementation
that will be usable with TLS 1.3 with less eye bleed.
ok jsing@ tb@
2018-11-09 00:34:55 +00:00
jsing
cef855dc92 Clean up and simplify the handshake transcript code.
This provides a cleaner, simpler and more readable API, with code that uses
a BUF_MEM instead of a BIO.

ok beck@ ("hurry up") and tb@.
2018-11-08 22:28:52 +00:00
jsing
ac64f7f4b8 Stop pretending that a cert member in a SSL and SSL_CTX can be NULL.
ok beck@ tb@
2018-11-08 20:55:18 +00:00
jsing
d3b2bb0df3 Add TLSv1.3 cipher suites (with appropriate guards).
ok beck@ tb@
2018-11-07 01:53:36 +00:00
jsing
2cdb2b1d3f Rename the TLS Supported Elliptic Curves extension to Supported Groups.
RFC 7919 renamed the Supported Elliptic Curves TLS extension to Supported
Groups and redefined it to include finite field DH (FFDH) in addition to
elliptic curve DH (ECDH). As such, rename the TLS extension and change the
associated code to refer to groups rather than curves.

ok beck@ tb@
2018-11-05 20:41:30 +00:00
jsing
6806c1e815 Clean up the code that checks if we can choose an EC cipher suite.
The tls1_check_ec_tmp_key() function is now rather misnamed, so just inline
the code. Also, rather than running tls1_get_shared_curve() once per EC
cipher suite, we can run it once at the start of the ssl3_choose_cipher()
function.

ok bluhm@ tb@
2018-11-05 06:55:37 +00:00
jsing
9bfb8abe8c Mop up ecdh_tmp, since it is no longer used.
ok bluhm@ tb@
2018-11-05 03:49:44 +00:00
jsing
75f9363729 Make more of libssl's record layer state internal.
In January 2017, we changed large amounts of libssl's data structures to
be non-visible/internal, however intentionally left things that the
software ecosystem was needing to use. The four or so applications that
reached into libssl for record layer related state now implement
alternative code. As such, make these data structures internal.

ok tb@
2018-10-24 18:04:50 +00:00
jsing
a51281f828 SSL_MAX_DIGEST is no longer needed. 2018-09-08 14:29:52 +00:00
jsing
4b5b5a86b0 Drop SSL_CIPHER_ALGORITHM2_AEAD flag.
All of our algorithm_mac == SSL_AEAD cipher suites use EVP_AEAD, so we can
condition on that rather than having a separate redundant flag.

ok tb@
2018-09-06 16:40:45 +00:00
jsing
f1abf68627 Correctly clear the current cipher state, when changing cipher state.
When a renegotiation results in a change of cipher suite, the renegotation
would fail if it switched from AEAD to non-AEAD or vice versa. This is due
to the fact that the previous EVP_AEAD or EVP_CIPHER state remained,
resulting in incorrect logic that caused MAC failures.

Rename ssl_clear_cipher_ctx() to ssl_clear_cipher_state() and split it
into separate read/write components, then call these functions from the
appropriate places when a ChangeCipherSpec message is being processed.
Also, remove the separate ssl_clear_hash_ctx() calls and fold these into
the ssl_clear_cipher_{read,write}_state() functions.

Issue reported by Bernard Spil, who also tested this diff.

ok tb@
2018-09-05 16:48:11 +00:00
jsing
364ba4a4e8 Nuke ssl_pending/ssl_shutdown function pointers.
ssl3_pending() is used for all protocols and dtls1_shutdown() just calls
ssl3_shutdown(), so just call the appropriate function directly instead.

ok beck@ inoguchi@ tb@
2018-08-30 16:56:16 +00:00
jsing
d55bfe34f5 n2s and l2n3 finally bite the dust! 2018-08-27 17:11:32 +00:00
jsing
12fe7be032 Simplify new session ticket encoding/generation.
The original code did a crazy encode/malloc/encode/decode/modify/encode
dance, in order to encode a session in the form needed to encrypt then add
to a session ticket. By modifying the encoding functions slightly, we can
do this entire dance as a single encode.

Inspired by similar changes in BoringSSL.

ok inoguchi@ tb@
2018-08-27 16:42:48 +00:00
jsing
307759ee4c Simplify session ticket parsing/handling.
The original implementation is rather crazy and means that we effectively
have two lots of code that parse a ClientHello and two lots of code that
parse TLS extensions. Partially simplify this by passing a CBS containing
the extension block through to the session handling functions, removing the
need to reimplement the ClientHello parsing.

While here standarise on naming for session_id and session_id_len.

ok inoguchi@ tb@
2018-08-24 18:10:25 +00:00
jsing
312b4b1422 Clean up handshake message start/finish functions.
Now that all handshake messages are created using CBB, remove the non-CBB
ssl3_handshake_msg_start()/ssl3_handshake_msg_finish() functions. Rename
the CBB variants by dropping the _cbb suffix.

ok bcook@ inoguchi@ tb@
2018-08-24 17:30:32 +00:00
jsing
481c1145e4 Rename and collapse tls12_get_sigandhash_cbb().
Now that all callers of tls12_get_sigandhash() have been converted to CBB,
collapse tls12_get_sigandhash() and tls12_get_sigandhash_cbb() into a
single function. Rename it to tls12_gethashandsig() to be representative
of the actual order of the sigalgs parameters, and perform some other
clean up.

ok inoguchi@ tb@
2018-08-19 15:38:03 +00:00
jsing
29dfe98457 Convert ssl3_send_server_key_exchange() to CBB.
ok inoguchi@ tb@
2018-08-16 17:49:48 +00:00
tb
0a4fabb92f OpenSSL started adding const to functions all over the place. Make all
our libssl functions match theirs wrt const, except for BIO_f_ssl(3)
which will be fixed in a later step.

this went through a i386 bulk by sthen
ok jsing
2018-04-25 07:10:39 +00:00
jsing
825249298c Remove function pointers for ssl_{read,write,peek}.
Now that everything goes through the same code path, we can remove a layer
of indirection and just call ssl3_{read,write,peek} directly.

ok beck@ inoguchi@
2018-04-07 17:02:34 +00:00
jsing
91265d5804 Nuke SSL3_FLAGS_DELAY_CLIENT_FINISHED and SSL3_FLAGS_POP_BUFFER.
These flags enabled experimental behaviour in the write path, which nothing
uses. Removing this code greatly simplifies ssl3_write().

ok beck@ inoguchi@ sthen@ tb@
2018-04-07 16:55:13 +00:00
jsing
fd8e9d0d2a Complete the TLS extension handling rewrite for the server-side.
This removes ssl_parse_clienthello_tlsext() and allows the CBS to be
passed all the way through from ssl3_get_client_hello(). The renegotation
check gets pulled up into ssl3_get_client_hello() which is where other
such checks exist.

The TLS extension parsing now also ensures that we do not get duplicates
of any known extensions (the old pre-rewrite code only did this for some
extensions).

ok inoguchi@
2018-01-27 15:30:05 +00:00
jsing
e39acaa983 Rename ssl3_client_hello() to ssl3_send_client_hello() for consistency. 2017-10-12 16:06:32 +00:00
jsing
b04c66583e Fold dtls1_accept() into ssl_accept(), removing a lot of duplicated code.
With review/feedback from inoguchi@
2017-10-12 15:52:50 +00:00
jsing
aecd16cd50 Drop prototypes for ssl23_*() functions, which no longer exist. 2017-10-12 15:44:18 +00:00
jsing
f63b027d1b Convert ssl3_client_hello() to CBB.
As part of this, change ssl_cipher_list_to_bytes() to take a CBB argument,
rather than a pointer/length. Some additional clean up/renames while here.

Based on a diff from doug@
2017-10-11 17:35:00 +00:00