summaryrefslogtreecommitdiff
path: root/lib/libssl/d1_pkt.c
AgeCommit message (Collapse)Author
2021-02-08Use dtls1_retrieve_buffered_record() to load buffered application data.Joel Sing
Replace the current copy of dtls1_retrieve_buffered_record() with a call to it instead. ok tb@
2021-01-26Move sequence numbers into the new TLSv1.2 record layer.Joel Sing
This allows for all of the DTLS sequence number save/restore code to be removed. ok inoguchi@ "whee!" tb@
2021-01-19Add code to handle change of cipher state in the new TLSv1.2 record layer.Joel Sing
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-19Provide functions to determine if TLSv1.2 record protection is engaged.Joel Sing
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-13Clean up dtls1_reset_seq_numbers()Joel Sing
Inline/remove some variables and use sizeof with the correct variables. ok inoguchi@ tb@
2021-01-13Clean up read sequence handling in DTLS.Joel Sing
Pass the explicit DTLS read sequence number to dtls1_record_bitmap_update() and dtls1_record_replay_check(), rather than expecting it to be in S3I(s)->read_sequence. Also, store the read sequence number into S3I(s)->rrec.seq_num when we're processing the record header, rather than having dtls1_record_replay_check() be responsible for copying it. ok inoguchi@ tb@
2021-01-13Clean up sequence number handing in the new TLSv1.2 record layer.Joel Sing
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@
2020-10-03Reimplement the TLSv1.2 record handling for the read side.Joel Sing
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-03Make dtls1_copy_record() take a DTLS1_RECORD_DATA_INTERNAL *.Joel Sing
This removes the need for extra variables and casts. ok inoguchi@ tb@
2020-10-03Inline two macros that are only used in one place each.Joel Sing
This improves readability - while here also add a missing return value check (although it cannot currently fail). ok inoguchi@ tb@
2020-09-24Release read and write buffers using freezero().Joel Sing
Provide a ssl3_release_buffer() function that correctly frees a buffer and call it from the appropriate locations. While here also change ssl3_release_{read,write}_buffer() to void since they cannot fail and no callers check the return value currently. ok beck@ inoguchi@ tb@
2020-08-30Start replacing the existing TLSv1.2 record layer.Joel Sing
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-11Increment the epoch in the same place for both read and write.Joel Sing
ok inoguchi@ tb@
2020-08-11Use 0 instead of 0x00 for memset() calls.Joel Sing
ok inoguchi@ tb@
2020-08-09Use CBB more correctly when writing SSL3/DTLS records.Joel Sing
Previously we used CBB to build the record headers, but not the entire record. Use CBB_init_fixed() upfront, then build the record header and add space for the record content. However, in order to do this we need to determine the length of the record upfront. This simplifies the code, removes a number of manual bounds checks and makes way for further improvements. ok inoguchi@ tb@
2020-08-09Make the explicit IV length handling in DTLS the same as SSL3/TLS.Joel Sing
ok inoguchi@ tb@
2020-08-02Check the return value of tls1_enc() in the write path.Joel Sing
The write path can return a failure in the AEAD path and there is no reason not to check a return value. Spotted by tb@ during another review. ok tb@
2020-08-01Clean up/simplify more of the dtls1/ssl3 record writing code:Joel Sing
- Make the DTLS code much more consistent with the ssl3 code. - Avoid assigning wr->input and wr->length just so they can be used as arguments to memcpy(). - Remove the arc4random_buf() call for the explicit IV, since tls1_enc() already does this for us. ok tb@
2020-07-30Clean up and simplify some of the SSL3/DTLS1 record writing code.Joel Sing
This will allow for further changes to be made with less complexity and easier review. In particular, decide if we need an empty fragment early on and only do the alignment calculation once (rather than in two separate parts of the function. ok tb@ inoguchi@
2020-03-13Remove dtls1_enc().Joel Sing
Like much of the original DTLS code, dtls1_enc() is effectively a renamed copy of tls1_enc(). Since then tls1_enc() has been modified, however the non-AEAD code remains largely the same. As such, remove dtls1_enc() and instead call tls1_enc() from the DTLS code. The tls1_enc() AEAD code does not currently work correctly with DTLS, however this is a non-issue since we do not support AEAD cipher suites with DTLS currently. ok tb@
2020-03-12Stop overloading the record type for padding length.Joel Sing
Currently the CBC related code stuffs the padding length in the upper bits of the type field... stop doing that and add a padding_length field to the record struct instead. ok inoguchi@ tb@
2020-03-12Use internal versions of SSL3_BUFFER, SSL3_RECORD and DTLS1_RECORD_DATA.Joel Sing
SSL3_BUFFER, SSL3_RECORD and DTLS1_RECORD_DATA are currently still in public headers, even though their usage is internal. This moves to using _INTERNAL suffixed versions that are in internal headers, which then allows us to change them without any potential public API fallout. ok inoguchi@ tb@
2020-03-10Remove the enc function pointers.Joel Sing
The enc function pointers do not serve any purpose these days - remove a layer of indirection and call dtls1_enc()/tls1_enc() directly. ok inoguchi@ tb@
2020-02-21Convert the DTLS header creation code to CBB.Joel Sing
Also consolidate it into the one place, since there is no reason to write the epoch and sequence out later. ok inoguchi@ tb@
2020-02-21Remove some commented code, remove some pointless comments and move someJoel Sing
comments to their correct places. ok inoguchi@ tb@
2020-02-21Remove prefix_len, since it is always zero.Joel Sing
ok inoguchi@ tb@
2018-12-03Send SSL_AD_DECODE alerts in the case of a bad hello request or anTheo Buehler
invalid change cipher spec. Found due to dead assignment warnings by the Clang static analyzer. ok inoguchi (previous version), jsing
2018-10-24Make more of libssl's record layer state internal.Joel Sing
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-08-24unifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE.Joel Sing
This code has been rotting since 2006. ok bcook@ tb@
2017-05-07Move state from ssl->internal to the handshake structure.Bob Beck
while we are at it, convert SSLerror to use a function internally, so that we may later allocate the handshake structure and check for it ok jsing@
2017-02-07Change SSLerror() back to taking two args, with the first one being an SSL *.Bob Beck
Make a table of "function codes" which maps the internal state of the SSL * to something like a useful name so in a typical error in the connection you know in what sort of place in the handshake things happened. (instead of by arcane function name). Add SSLerrorx() for when we don't have an SSL * ok jsing@ after us both being prodded by bluhm@ to make it not terrible
2017-01-26Send the error function codes to rot in the depths of hell where they belongBob Beck
We leave a single funciton code (0xFFF) to say "SSL_internal" so the public API will not break, and we replace all internal use of the two argument SSL_err() with the internal only SSL_error() that only takes a reason code. ok jsing@
2017-01-26Remove most of SSL3_ENC_METHOD - we can just inline the function callsJoel Sing
and defines since they are the same everywhere. ok beck@
2017-01-25Provide ssl3_packet_read() and ssl3_packet_extend() functions that improveJoel Sing
the awkward API provided by ssl3_read_n(). Call these when we need to read or extend a packet. ok beck@
2017-01-23Move options and mode from SSL_CTX and SSL to internal, since these can beJoel Sing
set and cleared via existing functions.
2017-01-23Split most of SSL_METHOD out into an internal variant, which is opaque.Joel Sing
Discussed with beck@
2017-01-23send state and rstate from ssl_st into internal. There are accessorsBob Beck
so these should not be diddled with directly ok jsing@
2017-01-23move back read_hash and enc_read_ctx into ssl_st. wpa_supplicant andBob Beck
other perversions touches them sickly and unnaturally.
2017-01-23Move a large part of ssl_st into internal, so we can see what squeals.Bob Beck
ok jsing@
2017-01-23move the callbacks from ssl_st to internalBob Beck
ok jsing@
2017-01-23Move callback function pointers and argument pointers from SSL_CTX toJoel Sing
internal. ok beck@
2017-01-22Move most of the SSL3_STATE fields to internal - the ones that remain areJoel Sing
known to be used by ports. ok beck@
2017-01-22Move most of DTLS1_STATE to internal.Bob Beck
ok jsing@
2016-11-04Make do_dtls1_write() static to d1_pkt.c and delete declarations forPhilip Guenther
three functions that were removed a while ago ok jsing@
2015-09-11Rename functions that moved to t1_enc.c, with a tls1_ prefix instead of aJoel Sing
ssl3_ prefix. ok beck@
2015-09-10Remove support for DTLS_BAD_VER. We do not support non-standard andJoel Sing
incomplete implementations just so that we can interoperate with products from vendors who have not bothered to fix things in the last ~10 years. ok bcook@ miod@
2015-07-19Assign p to CBS_data since it is used later.Doug Hogan
The p initialization was hiding this bug but Coverity 126279 saw it. ok miod@ bcook@ beck@
2015-07-18Convert dtls1_get_message_header to CBS and change to int.Doug Hogan
Changed return value from void to int. It should never return an error given that the input length is not checked yet. ok miod@
2015-07-18Convert dtls1_get_record to CBS.Doug Hogan
ok miod@, input + ok jsing@
2015-07-18Remove repeated code in dtls1_get_record.Doug Hogan
The "if" is a bit ugly, but this does remove a lot of repetitive code. This will be converted to CBS later as well. ok miod@ jsing@ roughly ok with it after seeing the CBS version