diff options
author | Hugo Landau <hlandau@openssl.org> | 2023-05-23 12:23:06 +0100 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2023-06-16 09:26:28 +1000 |
commit | 16f3b542f89dbdd6029400c740a55d49d4af8e53 (patch) | |
tree | 2f1f53ad1742e5b308321d3b085c9af73cee99ee /ssl | |
parent | 48120ea5e3648a581ec8011594641178d85b17c4 (diff) |
QUIC: Add internal APIs for white-box testing of key update
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21029)
Diffstat (limited to 'ssl')
-rw-r--r-- | ssl/quic/quic_channel.c | 25 | ||||
-rw-r--r-- | ssl/quic/quic_channel_local.h | 8 | ||||
-rw-r--r-- | ssl/quic/quic_impl.c | 15 | ||||
-rw-r--r-- | ssl/quic/quic_record_tx.c | 11 |
4 files changed, 57 insertions, 2 deletions
diff --git a/ssl/quic/quic_channel.c b/ssl/quic/quic_channel.c index 386da88d02..c4dfa58bc1 100644 --- a/ssl/quic/quic_channel.c +++ b/ssl/quic/quic_channel.c @@ -296,6 +296,7 @@ static int ch_init(QUIC_CHANNEL *ch) ch->max_idle_timeout = QUIC_DEFAULT_IDLE_TIMEOUT; ch->tx_enc_level = QUIC_ENC_LEVEL_INITIAL; ch->rx_enc_level = QUIC_ENC_LEVEL_INITIAL; + ch->txku_threshold_override = UINT64_MAX; /* * Determine the QUIC Transport Parameters and serialize the transport @@ -595,14 +596,18 @@ static int txku_recommendable(QUIC_CHANNEL *ch) QUIC_NEEDS_LOCK static int txku_desirable(QUIC_CHANNEL *ch) { - uint64_t cur_pkt_count, max_pkt_count; + uint64_t cur_pkt_count, max_pkt_count, thresh_pkt_count; const uint32_t enc_level = QUIC_ENC_LEVEL_1RTT; /* Check AEAD limit to determine if we should perform a spontaneous TXKU. */ cur_pkt_count = ossl_qtx_get_cur_epoch_pkt_count(ch->qtx, enc_level); max_pkt_count = ossl_qtx_get_max_epoch_pkt_count(ch->qtx, enc_level); - return cur_pkt_count >= max_pkt_count / 2; + thresh_pkt_count = max_pkt_count / 2; + if (ch->txku_threshold_override != UINT64_MAX) + thresh_pkt_count = ch->txku_threshold_override; + + return cur_pkt_count >= thresh_pkt_count; } QUIC_NEEDS_LOCK @@ -2858,3 +2863,19 @@ void ossl_quic_channel_set_msg_callback_arg(QUIC_CHANNEL *ch, ossl_quic_tx_packetiser_set_msg_callback_arg(ch->txp, msg_callback_arg); ossl_qrx_set_msg_callback_arg(ch->qrx, msg_callback_arg); } + +void ossl_quic_channel_set_txku_threshold_override(QUIC_CHANNEL *ch, + uint64_t tx_pkt_threshold) +{ + ch->txku_threshold_override = tx_pkt_threshold; +} + +uint64_t ossl_quic_channel_get_tx_key_epoch(QUIC_CHANNEL *ch) +{ + return ossl_qtx_get_key_epoch(ch->qtx); +} + +uint64_t ossl_quic_channel_get_rx_key_epoch(QUIC_CHANNEL *ch) +{ + return ossl_qrx_get_key_epoch(ch->qrx); +} diff --git a/ssl/quic/quic_channel_local.h b/ssl/quic/quic_channel_local.h index 607f109119..f2c84c450c 100644 --- a/ssl/quic/quic_channel_local.h +++ b/ssl/quic/quic_channel_local.h @@ -193,6 +193,14 @@ struct quic_channel_st { */ uint64_t incoming_stream_auto_reject_aec; + /* + * Override packet count threshold at which we do a spontaneous TXKU. + * Usually UINT64_MAX in which case a suitable value is chosen based on AEAD + * limit advice from the QRL utility functions. This is intended for testing + * use only. Usually set to UINT64_MAX. + */ + uint64_t txku_threshold_override; + /* Valid if we are in the TERMINATING or TERMINATED states. */ QUIC_TERMINATE_CAUSE terminate_cause; diff --git a/ssl/quic/quic_impl.c b/ssl/quic/quic_impl.c index 9cfc253bdc..548fcbc89e 100644 --- a/ssl/quic/quic_impl.c +++ b/ssl/quic/quic_impl.c @@ -2746,3 +2746,18 @@ const SSL_CIPHER *ossl_quic_get_cipher(unsigned int u) { return NULL; } + +/* + * Internal Testing APIs + * ===================== + */ + +QUIC_CHANNEL *ossl_quic_conn_get_channel(SSL *s) +{ + QCTX ctx; + + if (!expect_quic_conn_only(s, &ctx)) + return NULL; + + return ctx.qc->ch; +} diff --git a/ssl/quic/quic_record_tx.c b/ssl/quic/quic_record_tx.c index 69a5ebea54..243f8a4dd8 100644 --- a/ssl/quic/quic_record_tx.c +++ b/ssl/quic/quic_record_tx.c @@ -1014,3 +1014,14 @@ void ossl_qtx_set_msg_callback_arg(OSSL_QTX *qtx, void *msg_callback_arg) { qtx->msg_callback_arg = msg_callback_arg; } + +uint64_t ossl_qtx_get_key_epoch(OSSL_QTX *qtx) +{ + OSSL_QRL_ENC_LEVEL *el; + + el = ossl_qrl_enc_level_set_get(&qtx->el_set, QUIC_ENC_LEVEL_1RTT, 1); + if (el == NULL) + return 0; + + return el->key_epoch; +} |