Commit Graph

110 Commits

Author SHA1 Message Date
Jacob Rothstein d28be0f31d tls13: Immediate key update 2023-02-10 10:38:25 +01:00
Joseph Birr-Pixton 8a29ee4d33 Stop processing when we send a fatal alert
In this edge case (not specified by RFC8446) we send a fatal
invalid_parameter alert, but then keep processing incoming messages.

This led to a debug assert failure when a later message also sent
an alert.
2023-01-27 11:19:29 +00:00
Joseph Birr-Pixton 88ea3966b7 Remove string content from `PeerMisbehavedError` 2023-01-23 15:16:31 +00:00
Dirkjan Ochtman 961f71e650 tls13: let key schedule handle decrypter updates 2023-01-18 17:49:40 +01:00
Dirkjan Ochtman 1acd7a7139 deframer: join handshake messages in deframer buffer 2023-01-17 21:17:13 +01:00
Dirkjan Ochtman c3a84dedae deframer: derive Default implementation 2023-01-17 21:17:13 +01:00
Dirkjan Ochtman 6555b9f630 deframer: move decryption into deframer 2023-01-17 21:17:13 +01:00
Dirkjan Ochtman a5cbe93f26 record_layer: strengthen decrypt abstraction 2023-01-17 21:17:13 +01:00
Brian Smith 6dfa67809d Replace `doc(hidden)` with `pub(crate)` where those semantics are intended.
I think these uses of `doc(hidden)` are trying to implement `pub(crate)`
semantics. Perhaps it was done this way a long time ago when `pub(crate)`
wasn't a think.

This change causes an `unreachable_pub` warning for `PlaintextSink`, so
make that `pub(crate)` too.

Some external users might be using these even though they probably shouldn't
be, so this is technically a breaking change.
2023-01-16 10:32:14 +01:00
Dirkjan Ochtman e4ac86f279 Make Side public and use it for quic::Keys::initial() 2023-01-15 16:27:26 +01:00
Dirkjan Ochtman 6e6baa91e7 Upgrade to 2021 edition 2023-01-13 12:11:26 +01:00
Dirkjan Ochtman 9e657be6b9 hsjoiner: simplify awkward message type checking API 2023-01-05 08:41:51 +01:00
Dirkjan Ochtman 279f88fb26 hsjoiner: lazily parse messages from the handshake joiner 2023-01-05 08:41:51 +01:00
Dirkjan Ochtman 3356e3c705 hsjoiner: abstract over implementation details 2023-01-05 08:41:51 +01:00
Dirkjan Ochtman dbbb4eafc0 hsjoiner: clarify the return type for take_message() 2023-01-05 08:41:51 +01:00
Dirkjan Ochtman ad61765e7e Exert backpressure when the received_plaintext buffer is full 2022-11-16 13:28:39 +01:00
Dirkjan Ochtman 66ce7f5634 Clarify/update documentation for ConnectionCommon::read_tls() 2022-11-16 13:28:39 +01:00
Dirkjan Ochtman 54354c66ab deframer: abstract over internal state 2022-10-23 10:58:48 +02:00
amos a981f0914e
extract_secrets feature for kTLS support (owned) (#1112) 2022-10-15 13:53:08 +02:00
Xuanwo bc85a0145a feat: impl Debug for all public structs
Signed-off-by: Xuanwo <github@xuanwo.io>
2022-10-14 15:44:09 +02:00
Josh Aas 217ef36c66
Fix code depending on updated ReadBuf API (#1098) 2022-09-02 06:40:51 +02:00
Jacob Hoffman-Andrews a94a0055e1
MessageFragmenter: return an iterator (#1050)
This avoids a couple of unnecessary allocations: the individual Payloads of the
fragmented messages were allocating and filling a Vec, and the call sites were
allocating a VecDeque to be filled with messages.

Instead, always return an iterator of BorrowedPlainMessage, which the caller can
iterate over.
2022-06-13 10:30:45 +02:00
Joseph Birr-Pixton 8ce174fed3 Fix use_self warnings
It seems clippy is getting better at enforcing our deny(clippy::use_self)
2022-06-10 12:43:35 +02:00
Jacob Hoffman-Andrews 2854a0dbe2 Move some enums that are part of the public API.
Move ProtocolVersion, CipherSuite, and SignatureScheme from src/msgs/enums.rs
to src/enums.rs
2022-05-30 10:28:01 +02:00
Jacob Hoffman-Andrews d2ff075457 impl Default for Acceptor 2022-05-30 10:20:36 +02:00
Jacob Hoffman-Andrews dde28baec1 Replace MessageFragmenter::new with impl Default
Previously there were two paths that would check that a max_fragment_size was in
the acceptable range. Now there's just one path: calling set_max_fragment_size.

This provides a way to construct a MessageFragmenter with the default fragment
size that is error-free.
2022-05-30 10:20:36 +02:00
Jacob Hoffman-Andrews 07ae6f45fb Derive Eq wherever PartialEq is derived.
Fixes a clippy lint on nightly.
2022-05-29 22:41:33 +02:00
Dirkjan Ochtman 2f154643e5 Revert #1016 (attach location context to corrupt message errors)
This is a breaking change in the Error type.
2022-05-18 09:52:33 +02:00
Dirkjan Ochtman 86f4695c8c Use original handshake encoding for transcript hash
Stores the parsed data for a handshake message payload alongside
the encoded version to avoid having to re-encode the message when
updating the transcript hash. Also avoids encoding outgoing handshake
message payloads twice.
2022-05-12 20:46:16 +02:00
randsoy 9b83dcfe71
[tls handshaked] fix:Interrupted system call (os error 4) (#1031)
Dynamically load the FFI Library of trust using flutter in Android system.  `Connection Failed: tls connection init failed: Interrupted system call (os error 4)`.
2022-05-12 11:28:47 +02:00
ComplexSpaces c42c53e13d Attach location context to corrupt message errors 2022-03-31 10:23:46 +02:00
Joseph Birr-Pixton ec8a71b332 cargo fmt & cargo clippy fixes 2022-02-13 14:49:18 +00:00
Joseph Birr-Pixton 4c87c4af68 Reject malformed change_cipher_specs in TLS1.3 2022-02-13 14:29:48 +00:00
Brian Smith 85809b1e43 Make `cargo {check,build,test} --all-features` work on Rust Stable.
Make the `read_buf` feature do nothing on non-Nightly Rust.

This makes it easier for people not depending on that feature to
build/test Rustls, as demonstrated by the CI/CD changes here.

Use `rustversion` instead of `rustc_version`; `rustc_version` has more
dependencies.
2022-01-23 23:30:52 +01:00
Brian Smith 5835681bbf CommonState::process_main_protocol: Remove misleading comments.
The comments are out of date. In particular, `check_message` isn't
used, but also the other comments are misleading. Just remove them.
2022-01-22 10:54:58 +01:00
Brian Smith 3e466251eb Clarify when `may_receive_application_data` is set.
`start_incoming_traffic()` doesn't need to exist as a `pub(crate)`
function, or at all, because it is only used by the function right
below it. Inline it into that function to make it clearer when
`may_receive_application_data` is set.
2022-01-21 23:29:06 +01:00
Dirkjan Ochtman be5b3972a0 tls12: inline downgrade marker handling
Avoids duplicating the client/server state in the ConnectionRandoms,
which was unused if TLS 1.2 was disabled.
2022-01-21 21:06:44 +01:00
Dirkjan Ochtman 9a4307f7a7 Explicitly pass side to make_cipher_pair() 2022-01-21 21:06:44 +01:00
Dirkjan Ochtman 3405c4fc77 Implement enum for client/server distinctions 2022-01-21 21:06:44 +01:00
Joseph Birr-Pixton 725870a480 Enable server support for 0-RTT data
This previously existed, but only for QUIC.

There are some unfortunate shortcomings with the protocol design here:

Because the client must send 0-RTT data whether or not the server
accepts it or even the client hello, there must be several
disjoint methods for identifying and skipping these messages.  One
of these is in the record_layer.rs, and works by trial decryption.
Another happens if the server rejects the client's hello altogether,
and skips encrypted messages between the two client hellos.

The amount of data to skip is limited but -- because the design
appears to be defective -- the quantity is expressed (in
`max_early_data_size` provided with a ticket) in units of plaintext
bytes, but skipping data requires it in units of padded, tagged
ciphertext bytes.  The server cannot compute one from the other,
so we're interpretting `max_early_data_size` as both at the same time.
2022-01-15 12:12:16 +00:00
Joseph Birr-Pixton b0c29c2468 Allow two ChangeCipherSpecs in TLS1.3 middlebox mode
The server receives two of these if the client attempts
early_data but is rebuffed by the server with a HelloRetryRequest.
2022-01-15 12:12:16 +00:00
Joseph Birr-Pixton 7c30826398 Support 0.5RTT server->client traffic
This means the server can send application data in its first
flight.  We only do this, though, if no client auth is in play
(as otherwise we'd be sending data to an unauthenticated peer,
and that would be exceedingly bad.)

This is useful for server-speaks-first protocols, as well as
replying to a 0-RTT request in a client-speaks-first one.

In terms of code changes, this splits start_traffic() into
start_incoming_traffic() and start_outgoing_traffic().
2022-01-15 12:12:16 +00:00
Dirkjan Ochtman 76e4ede2d3 Avoid cloning ConnectionRandoms 2021-12-28 08:50:45 +01:00
David Cook a90415dc43 Add feature to use read_buf nightly feature flag 2021-12-18 11:29:23 +00:00
Jonas Schäfer d7f75173c2 Fix typo in docs 2021-12-08 19:51:23 +01:00
Dirkjan Ochtman d23b3fbbd3 Implement Acceptor API 2021-09-12 22:27:28 +02:00
Dirkjan Ochtman fa60a4a71b Redefine Connection as an enum 2021-09-12 17:46:51 +02:00
Dirkjan Ochtman dca648aabb Move Connection::negotiated_cipher_suite() into CommonState 2021-08-08 14:53:16 +02:00
Dirkjan Ochtman 8046b5bef1 Inline trivial getter method 2021-08-08 14:53:16 +02:00
Dirkjan Ochtman 40247363c0 Delegate shared state methods to CommonState 2021-08-08 14:53:16 +02:00