Method SSL.Connection()->send_packet_1_3()

class SSL.Connection

Method send_packet_1_3

void send_packet_1_3(Packet packet, int|void priority)

Description

TLS 1.3 and later: queue packet for sending, like send_packet(), but additionally bind it (via Packet.bound_write_state) to whatever current_write_state is *right now*.

This matters because send_packet() only queues a packet -- the actual encrypt_packet() call happens later, whenever to_write() drains the queue. TLS 1.3 rekeys by directly reassigning current_write_state at fixed protocol points (see new_traffic_state()), potentially several times while a flight of messages for *different* keys is still sitting in the queue (eg ServerHello in the clear, then EncryptedExtensions.. Finished under the handshake traffic secret, all queued before anything is actually drained) -- encrypting everything with whatever current_write_state happens to be when to_write() is eventually called would encrypt all of them with only the last one. Binding the state at queue time fixes that.