From: Neil Horman Date: Tue, 7 Jan 2025 14:12:03 +0000 (-0500) Subject: Fix encryption level ordering X-Git-Tag: openssl-3.5.0-alpha1~762 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89e2c6f61ebbf2ee0b0b742eb66cba0583fc6813;p=thirdparty%2Fopenssl.git Fix encryption level ordering It was noticed recently that the enum for QUIC encryption levels doesn't match the ordering that is outlined in the RFC. RFC 9000 s. 12.2 and RFC 9002 s 14.4.1 indicate that encryption level ordering is INITIAL/0RTT/HANDSHAKE/1RTT, but our enum is in the order INITAL/HANDSHAKE/0RTT/1RTT. Our enum isn't a direct wire translation, so as long as the wire->enum mapping done in ossl_quic_pkt_type_to_enc_level is done consistently it ideally wouldn't matter, but because we do coalescing in ossl_quic_tx_packetiser_generate by iterating through all the values in the enum, its possible we may coalesce in the wrong order when we do start implementing 0RTT support. Fix it by adjusting the enum properly to match the RFC order. This also necessitates and adjustment to the archetypes array, which is a two dimensional array indexed by encryption level and frame archetype (PROBE/NORMAL/ACK ONLY). Moving the 0RTT enc level to index 1 requires moving the (formerly) index 2 0RTT array row to be at index 1. Fixes #26324 Reviewed-by: Matt Caswell Reviewed-by: Tomas Mraz Reviewed-by: Saša Nedvědický (Merged from https://github.com/openssl/openssl/pull/26334) --- diff --git a/include/internal/quic_types.h b/include/internal/quic_types.h index fa1ac81ca1e..93fb6fb7f5d 100644 --- a/include/internal/quic_types.h +++ b/include/internal/quic_types.h @@ -20,8 +20,8 @@ /* QUIC encryption levels. */ enum { QUIC_ENC_LEVEL_INITIAL = 0, - QUIC_ENC_LEVEL_HANDSHAKE, QUIC_ENC_LEVEL_0RTT, + QUIC_ENC_LEVEL_HANDSHAKE, QUIC_ENC_LEVEL_1RTT, QUIC_ENC_LEVEL_NUM /* Must be the ultimate entry */ }; diff --git a/ssl/quic/quic_txp.c b/ssl/quic/quic_txp.c index bbbb6a70452..b764de2e486 100644 --- a/ssl/quic/quic_txp.c +++ b/ssl/quic/quic_txp.c @@ -1000,51 +1000,51 @@ static const struct archetype_data archetypes[QUIC_ENC_LEVEL_NUM][TX_PACKETISER_ /*bypass_cc =*/ 1, }, }, - /* EL 1(HANDSHAKE) */ + /* EL 1(0RTT) */ { - /* EL 1(HANDSHAKE) - Archetype 0(NORMAL) */ + /* EL 1(0RTT) - Archetype 0(NORMAL) */ { - /*allow_ack =*/ 1, + /*allow_ack =*/ 0, /*allow_ping =*/ 1, - /*allow_crypto =*/ 1, + /*allow_crypto =*/ 0, /*allow_handshake_done =*/ 0, /*allow_path_challenge =*/ 0, /*allow_path_response =*/ 0, - /*allow_new_conn_id =*/ 0, - /*allow_retire_conn_id =*/ 0, - /*allow_stream_rel =*/ 0, - /*allow_conn_fc =*/ 0, + /*allow_new_conn_id =*/ 1, + /*allow_retire_conn_id =*/ 1, + /*allow_stream_rel =*/ 1, + /*allow_conn_fc =*/ 1, /*allow_conn_close =*/ 1, /*allow_cfq_other =*/ 0, /*allow_new_token =*/ 0, - /*allow_force_ack_eliciting =*/ 1, + /*allow_force_ack_eliciting =*/ 0, /*allow_padding =*/ 1, /*require_ack_eliciting =*/ 0, /*bypass_cc =*/ 0, }, - /* EL 1(HANDSHAKE) - Archetype 1(PROBE) */ + /* EL 1(0RTT) - Archetype 1(PROBE) */ { - /*allow_ack =*/ 1, + /*allow_ack =*/ 0, /*allow_ping =*/ 1, - /*allow_crypto =*/ 1, + /*allow_crypto =*/ 0, /*allow_handshake_done =*/ 0, /*allow_path_challenge =*/ 0, /*allow_path_response =*/ 0, - /*allow_new_conn_id =*/ 0, - /*allow_retire_conn_id =*/ 0, - /*allow_stream_rel =*/ 0, - /*allow_conn_fc =*/ 0, + /*allow_new_conn_id =*/ 1, + /*allow_retire_conn_id =*/ 1, + /*allow_stream_rel =*/ 1, + /*allow_conn_fc =*/ 1, /*allow_conn_close =*/ 1, /*allow_cfq_other =*/ 0, /*allow_new_token =*/ 0, - /*allow_force_ack_eliciting =*/ 1, + /*allow_force_ack_eliciting =*/ 0, /*allow_padding =*/ 1, /*require_ack_eliciting =*/ 1, /*bypass_cc =*/ 1, }, - /* EL 1(HANDSHAKE) - Archetype 2(ACK_ONLY) */ + /* EL 1(0RTT) - Archetype 2(ACK_ONLY) */ { - /*allow_ack =*/ 1, + /*allow_ack =*/ 0, /*allow_ping =*/ 0, /*allow_crypto =*/ 0, /*allow_handshake_done =*/ 0, @@ -1057,57 +1057,57 @@ static const struct archetype_data archetypes[QUIC_ENC_LEVEL_NUM][TX_PACKETISER_ /*allow_conn_close =*/ 0, /*allow_cfq_other =*/ 0, /*allow_new_token =*/ 0, - /*allow_force_ack_eliciting =*/ 1, + /*allow_force_ack_eliciting =*/ 0, /*allow_padding =*/ 0, /*require_ack_eliciting =*/ 0, /*bypass_cc =*/ 1, }, }, - /* EL 2(0RTT) */ + /* EL (HANDSHAKE) */ { - /* EL 2(0RTT) - Archetype 0(NORMAL) */ + /* EL 2(HANDSHAKE) - Archetype 0(NORMAL) */ { - /*allow_ack =*/ 0, + /*allow_ack =*/ 1, /*allow_ping =*/ 1, - /*allow_crypto =*/ 0, + /*allow_crypto =*/ 1, /*allow_handshake_done =*/ 0, /*allow_path_challenge =*/ 0, /*allow_path_response =*/ 0, - /*allow_new_conn_id =*/ 1, - /*allow_retire_conn_id =*/ 1, - /*allow_stream_rel =*/ 1, - /*allow_conn_fc =*/ 1, + /*allow_new_conn_id =*/ 0, + /*allow_retire_conn_id =*/ 0, + /*allow_stream_rel =*/ 0, + /*allow_conn_fc =*/ 0, /*allow_conn_close =*/ 1, /*allow_cfq_other =*/ 0, /*allow_new_token =*/ 0, - /*allow_force_ack_eliciting =*/ 0, + /*allow_force_ack_eliciting =*/ 1, /*allow_padding =*/ 1, /*require_ack_eliciting =*/ 0, /*bypass_cc =*/ 0, }, - /* EL 2(0RTT) - Archetype 1(PROBE) */ + /* EL 2(HANDSHAKE) - Archetype 1(PROBE) */ { - /*allow_ack =*/ 0, + /*allow_ack =*/ 1, /*allow_ping =*/ 1, - /*allow_crypto =*/ 0, + /*allow_crypto =*/ 1, /*allow_handshake_done =*/ 0, /*allow_path_challenge =*/ 0, /*allow_path_response =*/ 0, - /*allow_new_conn_id =*/ 1, - /*allow_retire_conn_id =*/ 1, - /*allow_stream_rel =*/ 1, - /*allow_conn_fc =*/ 1, + /*allow_new_conn_id =*/ 0, + /*allow_retire_conn_id =*/ 0, + /*allow_stream_rel =*/ 0, + /*allow_conn_fc =*/ 0, /*allow_conn_close =*/ 1, /*allow_cfq_other =*/ 0, /*allow_new_token =*/ 0, - /*allow_force_ack_eliciting =*/ 0, + /*allow_force_ack_eliciting =*/ 1, /*allow_padding =*/ 1, /*require_ack_eliciting =*/ 1, /*bypass_cc =*/ 1, }, - /* EL 2(0RTT) - Archetype 2(ACK_ONLY) */ + /* EL 2(HANDSHAKE) - Archetype 2(ACK_ONLY) */ { - /*allow_ack =*/ 0, + /*allow_ack =*/ 1, /*allow_ping =*/ 0, /*allow_crypto =*/ 0, /*allow_handshake_done =*/ 0, @@ -1120,7 +1120,7 @@ static const struct archetype_data archetypes[QUIC_ENC_LEVEL_NUM][TX_PACKETISER_ /*allow_conn_close =*/ 0, /*allow_cfq_other =*/ 0, /*allow_new_token =*/ 0, - /*allow_force_ack_eliciting =*/ 0, + /*allow_force_ack_eliciting =*/ 1, /*allow_padding =*/ 0, /*require_ack_eliciting =*/ 0, /*bypass_cc =*/ 1,