Lines Matching refs:qrx

178     OSSL_QRX *qrx;  in ossl_qrx_new()  local
184 qrx = OPENSSL_zalloc(sizeof(OSSL_QRX)); in ossl_qrx_new()
185 if (qrx == NULL) in ossl_qrx_new()
188 for (i = 0; i < OSSL_NELEM(qrx->largest_pn); ++i) in ossl_qrx_new()
189 qrx->largest_pn[i] = args->init_largest_pn[i]; in ossl_qrx_new()
191 qrx->libctx = args->libctx; in ossl_qrx_new()
192 qrx->propq = args->propq; in ossl_qrx_new()
193 qrx->demux = args->demux; in ossl_qrx_new()
194 qrx->short_conn_id_len = args->short_conn_id_len; in ossl_qrx_new()
195 qrx->init_key_phase_bit = args->init_key_phase_bit; in ossl_qrx_new()
196 qrx->max_deferred = args->max_deferred; in ossl_qrx_new()
197 return qrx; in ossl_qrx_new()
211 static void qrx_cleanup_urxl(OSSL_QRX *qrx, QUIC_URXE_LIST *l) in qrx_cleanup_urxl() argument
218 ossl_quic_demux_release_urxe(qrx->demux, e); in qrx_cleanup_urxl()
222 void ossl_qrx_free(OSSL_QRX *qrx) in ossl_qrx_free() argument
226 if (qrx == NULL) in ossl_qrx_free()
230 qrx_cleanup_rxl(&qrx->rx_free); in ossl_qrx_free()
231 qrx_cleanup_rxl(&qrx->rx_pending); in ossl_qrx_free()
232 qrx_cleanup_urxl(qrx, &qrx->urx_pending); in ossl_qrx_free()
233 qrx_cleanup_urxl(qrx, &qrx->urx_deferred); in ossl_qrx_free()
237 ossl_qrl_enc_level_set_discard(&qrx->el_set, i); in ossl_qrx_free()
239 OPENSSL_free(qrx); in ossl_qrx_free()
242 void ossl_qrx_inject_urxe(OSSL_QRX *qrx, QUIC_URXE *urxe) in ossl_qrx_inject_urxe() argument
248 ossl_list_urxe_insert_tail(&qrx->urx_pending, urxe); in ossl_qrx_inject_urxe()
250 if (qrx->msg_callback != NULL) in ossl_qrx_inject_urxe()
251 qrx->msg_callback(0, OSSL_QUIC1_VERSION, SSL3_RT_QUIC_DATAGRAM, urxe + 1, in ossl_qrx_inject_urxe()
252 urxe->data_len, qrx->msg_callback_ssl, in ossl_qrx_inject_urxe()
253 qrx->msg_callback_arg); in ossl_qrx_inject_urxe()
256 static void qrx_requeue_deferred(OSSL_QRX *qrx) in qrx_requeue_deferred() argument
260 while ((e = ossl_list_urxe_head(&qrx->urx_deferred)) != NULL) { in qrx_requeue_deferred()
261 ossl_list_urxe_remove(&qrx->urx_deferred, e); in qrx_requeue_deferred()
262 ossl_list_urxe_insert_tail(&qrx->urx_pending, e); in qrx_requeue_deferred()
266 int ossl_qrx_provide_secret(OSSL_QRX *qrx, uint32_t enc_level, in ossl_qrx_provide_secret() argument
273 if (!ossl_qrl_enc_level_set_provide_secret(&qrx->el_set, in ossl_qrx_provide_secret()
274 qrx->libctx, in ossl_qrx_provide_secret()
275 qrx->propq, in ossl_qrx_provide_secret()
281 qrx->init_key_phase_bit, in ossl_qrx_provide_secret()
290 qrx_requeue_deferred(qrx); in ossl_qrx_provide_secret()
294 int ossl_qrx_discard_enc_level(OSSL_QRX *qrx, uint32_t enc_level) in ossl_qrx_discard_enc_level() argument
299 ossl_qrl_enc_level_set_discard(&qrx->el_set, enc_level); in ossl_qrx_discard_enc_level()
304 int ossl_qrx_processed_read_pending(OSSL_QRX *qrx) in ossl_qrx_processed_read_pending() argument
306 return !ossl_list_rxe_is_empty(&qrx->rx_pending); in ossl_qrx_processed_read_pending()
310 int ossl_qrx_unprocessed_read_pending(OSSL_QRX *qrx) in ossl_qrx_unprocessed_read_pending() argument
312 return !ossl_list_urxe_is_empty(&qrx->urx_pending) in ossl_qrx_unprocessed_read_pending()
313 || !ossl_list_urxe_is_empty(&qrx->urx_deferred); in ossl_qrx_unprocessed_read_pending()
317 static RXE *qrx_pop_pending_rxe(OSSL_QRX *qrx) in qrx_pop_pending_rxe() argument
319 RXE *rxe = ossl_list_rxe_head(&qrx->rx_pending); in qrx_pop_pending_rxe()
324 ossl_list_rxe_remove(&qrx->rx_pending, rxe); in qrx_pop_pending_rxe()
354 static RXE *qrx_ensure_free_rxe(OSSL_QRX *qrx, size_t alloc_len) in qrx_ensure_free_rxe() argument
358 if (ossl_list_rxe_head(&qrx->rx_free) != NULL) in qrx_ensure_free_rxe()
359 return ossl_list_rxe_head(&qrx->rx_free); in qrx_ensure_free_rxe()
365 ossl_list_rxe_insert_tail(&qrx->rx_free, rxe); in qrx_ensure_free_rxe()
430 static void qrx_recycle_rxe(OSSL_QRX *qrx, RXE *rxe) in qrx_recycle_rxe() argument
437 ossl_list_rxe_insert_tail(&qrx->rx_free, rxe); in qrx_recycle_rxe()
447 static int qrx_relocate_buffer(OSSL_QRX *qrx, RXE **prxe, size_t *pi, in qrx_relocate_buffer() argument
456 if ((rxe = qrx_reserve_rxe(&qrx->rx_free, *prxe, *pi + buf_len)) == NULL) in qrx_relocate_buffer()
496 static int qrx_validate_hdr_early(OSSL_QRX *qrx, RXE *rxe, in qrx_validate_hdr_early() argument
527 static int qrx_validate_hdr(OSSL_QRX *qrx, RXE *rxe) in qrx_validate_hdr() argument
532 qrx->largest_pn[pn_space], in qrx_validate_hdr()
540 static int qrx_validate_hdr_late(OSSL_QRX *qrx, RXE *rxe) in qrx_validate_hdr_late() argument
548 if (qrx->validation_cb != NULL in qrx_validate_hdr_late()
549 && !qrx->validation_cb(rxe->pn, pn_space, qrx->validation_cb_arg)) in qrx_validate_hdr_late()
559 static size_t qrx_get_cipher_ctx_idx(OSSL_QRX *qrx, OSSL_QRL_ENC_LEVEL *el, in qrx_get_cipher_ctx_idx() argument
659 static int qrx_decrypt_pkt_body(OSSL_QRX *qrx, unsigned char *dst, in qrx_decrypt_pkt_body() argument
670 OSSL_QRL_ENC_LEVEL *el = ossl_qrl_enc_level_set_get(&qrx->el_set, in qrx_decrypt_pkt_body()
688 if (qrx->forged_pkt_count >= ossl_qrl_get_suite_max_forged_pkt(el->suite_id)) in qrx_decrypt_pkt_body()
691 cctx_idx = qrx_get_cipher_ctx_idx(qrx, el, enc_level, key_phase_bit, in qrx_decrypt_pkt_body()
696 if (is_old_key && pn >= qrx->cur_epoch_start_pn) in qrx_decrypt_pkt_body()
754 ++qrx->forged_pkt_count; in qrx_decrypt_pkt_body()
768 static void qrx_key_update_initiated(OSSL_QRX *qrx, QUIC_PN pn) in qrx_key_update_initiated() argument
770 if (!ossl_qrl_enc_level_set_key_update(&qrx->el_set, QUIC_ENC_LEVEL_1RTT)) in qrx_key_update_initiated()
774 qrx->cur_epoch_start_pn = pn; in qrx_key_update_initiated()
776 if (qrx->key_update_cb != NULL) in qrx_key_update_initiated()
777 qrx->key_update_cb(pn, qrx->key_update_cb_arg); in qrx_key_update_initiated()
781 static int qrx_process_pkt(OSSL_QRX *qrx, QUIC_URXE *urxe, in qrx_process_pkt() argument
802 rxe = qrx_ensure_free_rxe(qrx, PACKET_remaining(pkt)); in qrx_process_pkt()
817 qrx->short_conn_id_len, in qrx_process_pkt()
839 || !qrx_validate_hdr_early(qrx, rxe, pkt_idx == 0 ? NULL : first_dcid)) in qrx_process_pkt()
854 if ((rxe = qrx_reserve_rxe(&qrx->rx_free, rxe, rxe->hdr.len)) == NULL) in qrx_process_pkt()
877 ossl_list_rxe_remove(&qrx->rx_free, rxe); in qrx_process_pkt()
878 ossl_list_rxe_insert_tail(&qrx->rx_pending, rxe); in qrx_process_pkt()
886 switch (ossl_qrl_enc_level_set_have_el(&qrx->el_set, enc_level)) { in qrx_process_pkt()
889 if (enc_level == QUIC_ENC_LEVEL_1RTT && !qrx->allow_1rtt) in qrx_process_pkt()
930 if (!qrx_relocate_buffer(qrx, &rxe, &i, &token, rxe->hdr.token_len)) in qrx_process_pkt()
939 el = ossl_qrl_enc_level_set_get(&qrx->el_set, enc_level, 1); in qrx_process_pkt()
953 if (ossl_quic_wire_decode_pkt_hdr(pkt, qrx->short_conn_id_len, in qrx_process_pkt()
959 if (!qrx_validate_hdr(qrx, rxe)) in qrx_process_pkt()
962 if (qrx->msg_callback != NULL) in qrx_process_pkt()
963 qrx->msg_callback(0, OSSL_QUIC1_VERSION, SSL3_RT_QUIC_PACKET, sop, in qrx_process_pkt()
964 eop - sop - rxe->hdr.len, qrx->msg_callback_ssl, in qrx_process_pkt()
965 qrx->msg_callback_arg); in qrx_process_pkt()
975 if ((rxe = qrx_reserve_rxe(&qrx->rx_free, rxe, rxe->hdr.len + i)) == NULL) { in qrx_process_pkt()
999 if (!qrx_decrypt_pkt_body(qrx, dst, rxe->hdr.data, rxe->hdr.len, in qrx_process_pkt()
1015 if (!qrx_validate_hdr_late(qrx, rxe)) in qrx_process_pkt()
1021 qrx_key_update_initiated(qrx, rxe->pn); in qrx_process_pkt()
1052 if (rxe->pn > qrx->largest_pn[pn_space]) in qrx_process_pkt()
1053 qrx->largest_pn[pn_space] = rxe->pn; in qrx_process_pkt()
1062 ossl_list_rxe_remove(&qrx->rx_free, rxe); in qrx_process_pkt()
1063 ossl_list_rxe_insert_tail(&qrx->rx_pending, rxe); in qrx_process_pkt()
1112 static int qrx_process_datagram(OSSL_QRX *qrx, QUIC_URXE *e, in qrx_process_datagram() argument
1121 qrx->bytes_received += data_len; in qrx_process_datagram()
1149 if (qrx_process_pkt(qrx, e, &pkt, pkt_idx, &first_dcid, data_len)) in qrx_process_datagram()
1158 static int qrx_process_one_urxe(OSSL_QRX *qrx, QUIC_URXE *e) in qrx_process_one_urxe() argument
1163 if (!ossl_assert(e == ossl_list_urxe_head(&qrx->urx_pending))) in qrx_process_one_urxe()
1172 was_deferred = qrx_process_datagram(qrx, e, ossl_quic_urxe_data(e), in qrx_process_one_urxe()
1179 ossl_list_urxe_remove(&qrx->urx_pending, e); in qrx_process_one_urxe()
1181 (e->deferred || qrx->num_deferred < qrx->max_deferred)) { in qrx_process_one_urxe()
1182 ossl_list_urxe_insert_tail(&qrx->urx_deferred, e); in qrx_process_one_urxe()
1185 ++qrx->num_deferred; in qrx_process_one_urxe()
1190 --qrx->num_deferred; in qrx_process_one_urxe()
1192 ossl_quic_demux_release_urxe(qrx->demux, e); in qrx_process_one_urxe()
1199 static int qrx_process_pending_urxl(OSSL_QRX *qrx) in qrx_process_pending_urxl() argument
1203 while ((e = ossl_list_urxe_head(&qrx->urx_pending)) != NULL) in qrx_process_pending_urxl()
1204 if (!qrx_process_one_urxe(qrx, e)) in qrx_process_pending_urxl()
1210 int ossl_qrx_read_pkt(OSSL_QRX *qrx, OSSL_QRX_PKT **ppkt) in ossl_qrx_read_pkt() argument
1214 if (!ossl_qrx_processed_read_pending(qrx)) { in ossl_qrx_read_pkt()
1215 if (!qrx_process_pending_urxl(qrx)) in ossl_qrx_read_pkt()
1218 if (!ossl_qrx_processed_read_pending(qrx)) in ossl_qrx_read_pkt()
1222 rxe = qrx_pop_pending_rxe(qrx); in ossl_qrx_read_pkt()
1239 rxe->pkt.qrx = qrx; in ossl_qrx_read_pkt()
1255 qrx_recycle_rxe(pkt->qrx, rxe); in ossl_qrx_pkt_release()
1266 uint64_t ossl_qrx_get_bytes_received(OSSL_QRX *qrx, int clear) in ossl_qrx_get_bytes_received() argument
1268 uint64_t v = qrx->bytes_received; in ossl_qrx_get_bytes_received()
1271 qrx->bytes_received = 0; in ossl_qrx_get_bytes_received()
1276 int ossl_qrx_set_late_validation_cb(OSSL_QRX *qrx, in ossl_qrx_set_late_validation_cb() argument
1280 qrx->validation_cb = cb; in ossl_qrx_set_late_validation_cb()
1281 qrx->validation_cb_arg = cb_arg; in ossl_qrx_set_late_validation_cb()
1285 int ossl_qrx_set_key_update_cb(OSSL_QRX *qrx, in ossl_qrx_set_key_update_cb() argument
1289 qrx->key_update_cb = cb; in ossl_qrx_set_key_update_cb()
1290 qrx->key_update_cb_arg = cb_arg; in ossl_qrx_set_key_update_cb()
1294 uint64_t ossl_qrx_get_key_epoch(OSSL_QRX *qrx) in ossl_qrx_get_key_epoch() argument
1296 OSSL_QRL_ENC_LEVEL *el = ossl_qrl_enc_level_set_get(&qrx->el_set, in ossl_qrx_get_key_epoch()
1302 int ossl_qrx_key_update_timeout(OSSL_QRX *qrx, int normal) in ossl_qrx_key_update_timeout() argument
1304 OSSL_QRL_ENC_LEVEL *el = ossl_qrl_enc_level_set_get(&qrx->el_set, in ossl_qrx_key_update_timeout()
1311 && !ossl_qrl_enc_level_set_key_update_done(&qrx->el_set, in ossl_qrx_key_update_timeout()
1316 && !ossl_qrl_enc_level_set_key_cooldown_done(&qrx->el_set, in ossl_qrx_key_update_timeout()
1323 uint64_t ossl_qrx_get_cur_forged_pkt_count(OSSL_QRX *qrx) in ossl_qrx_get_cur_forged_pkt_count() argument
1325 return qrx->forged_pkt_count; in ossl_qrx_get_cur_forged_pkt_count()
1328 uint64_t ossl_qrx_get_max_forged_pkt_count(OSSL_QRX *qrx, in ossl_qrx_get_max_forged_pkt_count() argument
1331 OSSL_QRL_ENC_LEVEL *el = ossl_qrl_enc_level_set_get(&qrx->el_set, in ossl_qrx_get_max_forged_pkt_count()
1338 void ossl_qrx_allow_1rtt_processing(OSSL_QRX *qrx) in ossl_qrx_allow_1rtt_processing() argument
1340 if (qrx->allow_1rtt) in ossl_qrx_allow_1rtt_processing()
1343 qrx->allow_1rtt = 1; in ossl_qrx_allow_1rtt_processing()
1344 qrx_requeue_deferred(qrx); in ossl_qrx_allow_1rtt_processing()
1347 void ossl_qrx_set_msg_callback(OSSL_QRX *qrx, ossl_msg_cb msg_callback, in ossl_qrx_set_msg_callback() argument
1350 qrx->msg_callback = msg_callback; in ossl_qrx_set_msg_callback()
1351 qrx->msg_callback_ssl = msg_callback_ssl; in ossl_qrx_set_msg_callback()
1354 void ossl_qrx_set_msg_callback_arg(OSSL_QRX *qrx, void *msg_callback_arg) in ossl_qrx_set_msg_callback_arg() argument
1356 qrx->msg_callback_arg = msg_callback_arg; in ossl_qrx_set_msg_callback_arg()