hannestschofenig / mbedtls

An open source, portable, easy to use, readable and flexible SSL library
https://tls.mbed.org
Apache License 2.0
15 stars 8 forks source link

[0-RTT] Use trial decryption if server rejects client 0-RTT attempt #386

Open jesiegel1 opened 2 years ago

jesiegel1 commented 2 years ago

Description

This PR adds server support for handling trial decryption in order to make test output accessible for the early data rejected case by using ssl_server2.c. Without trial decryption logic, early data rejected tests that use ssl_server2.c will fail due to decryption errors caused by the client sending early data before receiving and parsing the server's extensions.

RFC 8446: Ignore the extension and return a regular 1-RTT response. The server then skips past early data by attempting to deprotect received records using the handshake traffic key, discarding records which fail deprotection (up to the configured max_early_data_size). Once a record is deprotected successfully, it is treated as the start of the client's second flight and the server proceeds as with an ordinary 1-RTT handshake.

Status

READY

Requires Backporting

NO

Additional comments

The need for the skip_failed_decryption flag is to ensure we no longer drop records which fail deprotection once a record is deprotected successfully with the 1-RTT keys. The motivation was taken from Fizz, but I'd like to know if (1) there's a more appropriate place than mbedtls_ssl_read_record() to disable the flag, and (2) if there's other existing state we can leverage to avoid using an additional flag.

Todos

Steps to test or reproduce