Lines Matching +full:a +full:- +full:h
2 * Copyright 2023-2025 The OpenSSL Project Authors. All Rights Reserved.
5 * this file except in compliance with the License. You can obtain a copy
9 #include <openssl/ssl.h>
10 #include <openssl/quic.h>
11 #include <openssl/bio.h>
12 #include <openssl/lhash.h>
13 #include <openssl/rand.h>
14 #include "internal/quic_tserver.h"
15 #include "internal/quic_ssl.h"
16 #include "internal/quic_error.h"
17 #include "internal/quic_stream_map.h"
18 #include "internal/quic_engine.h"
19 #include "testutil.h"
20 #include "helpers/quictestlib.h"
22 # include "internal/thread_arch.h"
24 #include "internal/numbers.h" /* UINT64_C */
40 struct helper *h; member
70 * When doing a blocking mode test run, s_priv always points to the TSERVER
92 * This is a duration recording the amount of time we have skipped forwards
94 * a quantity of time to this every time we skip some time.
104 int (*qtf_packet_plain_cb)(struct helper *h, QUIC_PKT_HDR *hdr,
106 int (*qtf_handshake_cb)(struct helper *h,
108 int (*qtf_datagram_cb)(struct helper *h,
124 struct helper *h; member
135 int (*check_func)(struct helper *h, struct helper_local *hl);
138 int (*qtf_packet_plain_cb)(struct helper *h, QUIC_PKT_HDR *hdr,
140 int (*qtf_handshake_cb)(struct helper *h,
142 int (*qtf_datagram_cb)(struct helper *h,
352 struct helper *h = arg; in get_time() local
355 if (!TEST_true(CRYPTO_THREAD_read_lock(h->time_lock))) in get_time()
358 t = ossl_time_add(ossl_time_now(), h->time_slip); in get_time()
360 CRYPTO_THREAD_unlock(h->time_lock); in get_time()
364 static int skip_time_ms(struct helper *h, struct helper_local *hl) in skip_time_ms() argument
366 if (!TEST_true(CRYPTO_THREAD_write_lock(h->time_lock))) in skip_time_ms()
369 h->time_slip = ossl_time_add(h->time_slip, ossl_ms2time(hl->check_op->arg2)); in skip_time_ms()
371 CRYPTO_THREAD_unlock(h->time_lock); in skip_time_ms()
375 static QUIC_TSERVER *s_lock(struct helper *h, struct helper_local *hl);
376 static void s_unlock(struct helper *h, struct helper_local *hl);
378 #define ACQUIRE_S() s_lock(h, hl)
379 #define ACQUIRE_S_NOHL() s_lock(h, NULL)
381 static int check_rejected(struct helper *h, struct helper_local *hl) in check_rejected() argument
383 uint64_t stream_id = hl->check_op->arg2; in check_rejected()
387 h->check_spin_again = 1; in check_rejected()
394 static int check_stream_reset(struct helper *h, struct helper_local *hl) in check_stream_reset() argument
396 uint64_t stream_id = hl->check_op->arg2, aec = 0; in check_stream_reset()
399 h->check_spin_again = 1; in check_stream_reset()
406 static int check_stream_stopped(struct helper *h, struct helper_local *hl) in check_stream_stopped() argument
408 uint64_t stream_id = hl->check_op->arg2; in check_stream_stopped()
411 h->check_spin_again = 1; in check_stream_stopped()
418 static int override_key_update(struct helper *h, struct helper_local *hl) in override_key_update() argument
420 QUIC_CHANNEL *ch = ossl_quic_conn_get_channel(h->c_conn); in override_key_update()
422 ossl_quic_channel_set_txku_threshold_override(ch, hl->check_op->arg2); in override_key_update()
426 static int trigger_key_update(struct helper *h, struct helper_local *hl) in trigger_key_update() argument
428 if (!TEST_true(SSL_key_update(h->c_conn, SSL_KEY_UPDATE_REQUESTED))) in trigger_key_update()
434 static int check_key_update_ge(struct helper *h, struct helper_local *hl) in check_key_update_ge() argument
436 QUIC_CHANNEL *ch = ossl_quic_conn_get_channel(h->c_conn); in check_key_update_ge()
439 int64_t diff = txke - rxke; in check_key_update_ge()
448 /* Caller specifies a minimum number of RXKEs which must have happened. */ in check_key_update_ge()
449 if (!TEST_uint64_t_ge((uint64_t)rxke, hl->check_op->arg2)) in check_key_update_ge()
455 static int check_key_update_lt(struct helper *h, struct helper_local *hl) in check_key_update_lt() argument
457 QUIC_CHANNEL *ch = ossl_quic_conn_get_channel(h->c_conn); in check_key_update_lt()
460 /* Caller specifies a maximum number of TXKEs which must have happened. */ in check_key_update_lt()
461 if (!TEST_uint64_t_lt(txke, hl->check_op->arg2)) in check_key_update_lt()
469 return OPENSSL_LH_strhash(info->name); in stream_info_hash()
472 static int stream_info_cmp(const STREAM_INFO *a, const STREAM_INFO *b) in stream_info_cmp() argument
474 return strcmp(a->name, b->name); in stream_info_cmp()
479 SSL_free(info->c_stream); in cleanup_stream()
520 static int join_server_thread(struct helper *h) in join_server_thread() argument
524 if (h->server_thread.t == NULL) in join_server_thread()
527 ossl_crypto_mutex_lock(h->server_thread.m); in join_server_thread()
528 h->server_thread.stop = 1; in join_server_thread()
529 ossl_crypto_condvar_signal(h->server_thread.c); in join_server_thread()
530 ossl_crypto_mutex_unlock(h->server_thread.m); in join_server_thread()
532 ossl_crypto_thread_native_join(h->server_thread.t, &rv); in join_server_thread()
533 ossl_crypto_thread_native_clean(h->server_thread.t); in join_server_thread()
534 h->server_thread.t = NULL; in join_server_thread()
538 /* Ensure the server-state lock is currently held. Idempotent. */
539 static int *s_checked_out_p(struct helper *h, int thread_idx) in s_checked_out_p() argument
541 return (thread_idx < 0) ? &h->s_checked_out in s_checked_out_p()
542 : &h->threads[thread_idx].s_checked_out; in s_checked_out_p()
545 static QUIC_TSERVER *s_lock(struct helper *h, struct helper_local *hl) in s_lock() argument
547 int *p_checked_out = s_checked_out_p(h, hl == NULL ? -1 : hl->thread_idx); in s_lock()
549 if (h->server_thread.m == NULL || *p_checked_out) in s_lock()
550 return h->s; in s_lock()
552 ossl_crypto_mutex_lock(h->server_thread.m); in s_lock()
553 h->s = h->s_priv; in s_lock()
555 return h->s; in s_lock()
558 /* Ensure the server-state lock is currently not held. Idempotent. */
559 static void s_unlock(struct helper *h, struct helper_local *hl) in s_unlock() argument
561 int *p_checked_out = s_checked_out_p(h, hl->thread_idx); in s_unlock()
563 if (h->server_thread.m == NULL || !*p_checked_out) in s_unlock()
567 h->s = NULL; in s_unlock()
568 ossl_crypto_mutex_unlock(h->server_thread.m); in s_unlock()
573 struct helper *h = arg; in server_helper_thread() local
575 ossl_crypto_mutex_lock(h->server_thread.m); in server_helper_thread()
580 ready = h->server_thread.ready; in server_helper_thread()
581 stop = h->server_thread.stop; in server_helper_thread()
587 ossl_crypto_condvar_wait(h->server_thread.c, h->server_thread.m); in server_helper_thread()
591 ossl_quic_tserver_tick(h->s_priv); in server_helper_thread()
592 ossl_crypto_mutex_unlock(h->server_thread.m); in server_helper_thread()
598 ossl_crypto_mutex_lock(h->server_thread.m); in server_helper_thread()
601 ossl_crypto_mutex_unlock(h->server_thread.m); in server_helper_thread()
607 static QUIC_TSERVER *s_lock(struct helper *h, struct helper_local *hl) in s_lock() argument
609 return h->s; in s_lock()
612 static void s_unlock(struct helper *h, struct helper_local *hl) in s_unlock() argument
617 static void helper_cleanup(struct helper *h) in helper_cleanup() argument
620 join_threads(h->threads, h->num_threads); in helper_cleanup()
621 join_server_thread(h); in helper_cleanup()
622 OPENSSL_free(h->threads); in helper_cleanup()
623 h->threads = NULL; in helper_cleanup()
624 h->num_threads = 0; in helper_cleanup()
627 if (h->free_order == 0) { in helper_cleanup()
629 helper_cleanup_streams(&h->c_streams); in helper_cleanup()
631 SSL_free(h->c_conn); in helper_cleanup()
632 h->c_conn = NULL; in helper_cleanup()
635 SSL_free(h->c_conn); in helper_cleanup()
636 h->c_conn = NULL; in helper_cleanup()
638 helper_cleanup_streams(&h->c_streams); in helper_cleanup()
641 helper_cleanup_streams(&h->s_streams); in helper_cleanup()
642 ossl_quic_tserver_free(h->s_priv); in helper_cleanup()
643 h->s_priv = h->s = NULL; in helper_cleanup()
645 BIO_free(h->s_net_bio_own); in helper_cleanup()
646 h->s_net_bio_own = NULL; in helper_cleanup()
648 BIO_free(h->c_net_bio_own); in helper_cleanup()
649 h->c_net_bio_own = NULL; in helper_cleanup()
651 BIO_free(h->s_qtf_wbio_own); in helper_cleanup()
652 h->s_qtf_wbio_own = NULL; in helper_cleanup()
654 qtest_fault_free(h->qtf); in helper_cleanup()
655 h->qtf = NULL; in helper_cleanup()
657 if (h->s_fd >= 0) { in helper_cleanup()
658 BIO_closesocket(h->s_fd); in helper_cleanup()
659 h->s_fd = -1; in helper_cleanup()
662 if (h->c_fd >= 0) { in helper_cleanup()
663 BIO_closesocket(h->c_fd); in helper_cleanup()
664 h->c_fd = -1; in helper_cleanup()
667 BIO_ADDR_free(h->s_net_bio_addr); in helper_cleanup()
668 h->s_net_bio_addr = NULL; in helper_cleanup()
669 BIO_ADDR_free(h->s_net_bio_orig_addr); in helper_cleanup()
670 h->s_net_bio_orig_addr = NULL; in helper_cleanup()
672 SSL_CTX_free(h->c_ctx); in helper_cleanup()
673 h->c_ctx = NULL; in helper_cleanup()
675 CRYPTO_THREAD_lock_free(h->time_lock); in helper_cleanup()
676 h->time_lock = NULL; in helper_cleanup()
679 ossl_crypto_mutex_free(&h->misc_m); in helper_cleanup()
680 ossl_crypto_condvar_free(&h->misc_cv); in helper_cleanup()
681 ossl_crypto_mutex_free(&h->server_thread.m); in helper_cleanup()
682 ossl_crypto_condvar_free(&h->server_thread.c); in helper_cleanup()
686 static int helper_init(struct helper *h, const char *script_name, in helper_init() argument
696 memset(h, 0, sizeof(*h)); in helper_init()
697 h->c_fd = -1; in helper_init()
698 h->s_fd = -1; in helper_init()
699 h->free_order = free_order; in helper_init()
700 h->blocking = blocking; in helper_init()
701 h->need_injector = need_injector; in helper_init()
702 h->time_slip = ossl_time_zero(); in helper_init()
708 if (!TEST_ptr(h->time_lock = CRYPTO_THREAD_lock_new())) in helper_init()
711 if (!TEST_ptr(h->s_streams = lh_STREAM_INFO_new(stream_info_hash, in helper_init()
715 if (!TEST_ptr(h->c_streams = lh_STREAM_INFO_new(stream_info_hash, in helper_init()
721 h->s_fd = BIO_socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP, 0); in helper_init()
722 if (!TEST_int_ge(h->s_fd, 0)) in helper_init()
725 if (!TEST_true(BIO_socket_nbio(h->s_fd, 1))) in helper_init()
728 if (!TEST_ptr(h->s_net_bio_orig_addr = BIO_ADDR_new()) in helper_init()
729 || !TEST_ptr(h->s_net_bio_addr = BIO_ADDR_new())) in helper_init()
732 if (!TEST_true(BIO_ADDR_rawmake(h->s_net_bio_orig_addr, AF_INET, in helper_init()
736 if (!TEST_true(BIO_bind(h->s_fd, h->s_net_bio_orig_addr, 0))) in helper_init()
739 info.addr = h->s_net_bio_addr; in helper_init()
740 if (!TEST_true(BIO_sock_info(h->s_fd, BIO_SOCK_INFO_ADDRESS, &info))) in helper_init()
743 if (!TEST_int_gt(BIO_ADDR_rawport(h->s_net_bio_addr), 0)) in helper_init()
746 if (!TEST_ptr(h->s_net_bio = h->s_net_bio_own = BIO_new_dgram(h->s_fd, 0))) in helper_init()
749 if (!BIO_up_ref(h->s_net_bio)) in helper_init()
753 h->s_qtf_wbio = h->s_qtf_wbio_own = BIO_new(qtest_get_bio_method()); in helper_init()
754 if (!TEST_ptr(h->s_qtf_wbio)) in helper_init()
757 if (!TEST_ptr(BIO_push(h->s_qtf_wbio, h->s_net_bio))) in helper_init()
760 s_args.net_wbio = h->s_qtf_wbio; in helper_init()
762 s_args.net_wbio = h->s_net_bio; in helper_init()
765 s_args.net_rbio = h->s_net_bio; in helper_init()
768 s_args.now_cb_arg = h; in helper_init()
771 if (!TEST_ptr(h->s_priv = ossl_quic_tserver_new(&s_args, certfile, keyfile))) in helper_init()
775 h->s = h->s_priv; in helper_init()
778 h->qtf = qtest_create_injector(h->s_priv); in helper_init()
779 if (!TEST_ptr(h->qtf)) in helper_init()
781 bdata->fault = h->qtf; in helper_init()
782 BIO_set_data(h->s_qtf_wbio, bdata); in helper_init()
785 h->s_net_bio_own = NULL; in helper_init()
786 h->s_qtf_wbio_own = NULL; in helper_init()
788 h->c_fd = BIO_socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP, 0); in helper_init()
789 if (!TEST_int_ge(h->c_fd, 0)) in helper_init()
792 if (!TEST_true(BIO_socket_nbio(h->c_fd, 1))) in helper_init()
795 if (!TEST_ptr(h->c_net_bio = h->c_net_bio_own = BIO_new_dgram(h->c_fd, 0))) in helper_init()
798 if (!TEST_true(BIO_dgram_set_peer(h->c_net_bio, h->s_net_bio_addr))) in helper_init()
801 if (!TEST_ptr(h->c_ctx = SSL_CTX_new(OSSL_QUIC_client_method()))) in helper_init()
806 if (!TEST_true(ossl_quic_set_diag_title(h->c_ctx, title))) in helper_init()
809 if (!TEST_ptr(h->c_conn = SSL_new(h->c_ctx))) in helper_init()
813 if (!TEST_true(ossl_quic_set_override_now_cb(h->c_conn, get_time, h))) in helper_init()
817 SSL_set0_rbio(h->c_conn, h->c_net_bio); in helper_init()
818 h->c_net_bio_own = NULL; in helper_init()
820 if (!TEST_true(BIO_up_ref(h->c_net_bio))) in helper_init()
823 SSL_set0_wbio(h->c_conn, h->c_net_bio); in helper_init()
825 if (!TEST_true(SSL_set_blocking_mode(h->c_conn, h->blocking))) in helper_init()
829 if (!TEST_ptr(h->misc_m = ossl_crypto_mutex_new())) in helper_init()
831 if (!TEST_ptr(h->misc_cv = ossl_crypto_condvar_new())) in helper_init()
835 if (h->blocking) { in helper_init()
837 if (!TEST_ptr(h->server_thread.m = ossl_crypto_mutex_new())) in helper_init()
840 if (!TEST_ptr(h->server_thread.c = ossl_crypto_condvar_new())) in helper_init()
843 h->server_thread.t in helper_init()
844 = ossl_crypto_thread_native_start(server_helper_thread, h, 1); in helper_init()
845 if (!TEST_ptr(h->server_thread.t)) in helper_init()
853 h->start_time = ossl_time_now(); in helper_init()
854 h->init = 1; in helper_init()
858 helper_cleanup(h); in helper_init()
862 static int helper_local_init(struct helper_local *hl, struct helper *h, in helper_local_init() argument
865 hl->h = h; in helper_local_init()
866 hl->c_streams = NULL; in helper_local_init()
867 hl->thread_idx = thread_idx; in helper_local_init()
868 hl->explicit_event_handling = 0; in helper_local_init()
870 if (!TEST_ptr(h)) in helper_local_init()
874 hl->c_streams = h->c_streams; in helper_local_init()
876 if (!TEST_ptr(hl->c_streams = lh_STREAM_INFO_new(stream_info_hash, in helper_local_init()
886 if (hl->h == NULL) in helper_local_cleanup()
889 if (hl->thread_idx >= 0) in helper_local_cleanup()
890 helper_cleanup_streams(&hl->c_streams); in helper_local_cleanup()
892 hl->h = NULL; in helper_local_cleanup()
913 info->name = stream_name; in get_stream_info()
914 info->s_stream_id = UINT64_MAX; in get_stream_info()
925 STREAM_INFO *info = get_stream_info(hl->c_streams, stream_name); in helper_local_set_c_stream()
930 info->c_stream = c_stream; in helper_local_set_c_stream()
931 info->s_stream_id = UINT64_MAX; in helper_local_set_c_stream()
941 return hl->h->c_conn; in helper_local_get_c_stream()
943 info = get_stream_info(hl->c_streams, stream_name); in helper_local_get_c_stream()
947 return info->c_stream; in helper_local_get_c_stream()
951 helper_set_s_stream(struct helper *h, const char *stream_name, in helper_set_s_stream() argument
959 info = get_stream_info(h->s_streams, stream_name); in helper_set_s_stream()
963 info->c_stream = NULL; in helper_set_s_stream()
964 info->s_stream_id = s_stream_id; in helper_set_s_stream()
968 static uint64_t helper_get_s_stream(struct helper *h, const char *stream_name) in helper_get_s_stream() argument
975 info = get_stream_info(h->s_streams, stream_name); in helper_get_s_stream()
979 return info->s_stream_id; in helper_get_s_stream()
986 struct helper *h = arg; in helper_packet_plain_listener() local
988 return h->qtf_packet_plain_cb(h, hdr, buf, buf_len); in helper_packet_plain_listener()
995 struct helper *h = arg; in helper_handshake_listener() local
997 return h->qtf_handshake_cb(h, buf, buf_len); in helper_handshake_listener()
1004 struct helper *h = arg; in helper_datagram_listener() local
1006 return h->qtf_datagram_cb(h, msg, stride); in helper_datagram_listener()
1039 static int run_script_worker(struct helper *h, const struct script_op *script, in run_script_worker() argument
1060 if (!TEST_true(helper_local_init(hl, h, thread_idx))) in run_script_worker()
1070 s_lock(h, hl); \ in run_script_worker()
1071 ossl_quic_tserver_tick(h->s); \ in run_script_worker()
1076 if (h->blocking) { \ in run_script_worker()
1084 SSL *c_tgt = h->c_conn; in run_script_worker()
1087 s_unlock(h, hl); in run_script_worker()
1108 if (op->stream_name != NULL) { in run_script_worker()
1109 c_tgt = helper_local_get_c_stream(hl, op->stream_name); in run_script_worker()
1111 s_stream_id = helper_get_s_stream(h, op->stream_name); in run_script_worker()
1117 if (!h->blocking) { in run_script_worker()
1118 ossl_quic_tserver_tick(h->s); in run_script_worker()
1121 else if (h->blocking && !h->server_thread.ready) { in run_script_worker()
1122 ossl_crypto_mutex_lock(h->server_thread.m); in run_script_worker()
1123 h->server_thread.ready = 1; in run_script_worker()
1124 ossl_crypto_condvar_signal(h->server_thread.c); in run_script_worker()
1125 ossl_crypto_mutex_unlock(h->server_thread.m); in run_script_worker()
1127 if (h->blocking) in run_script_worker()
1128 assert(h->s == NULL); in run_script_worker()
1132 if (!hl->explicit_event_handling in run_script_worker()
1134 SSL_handle_events(h->c_conn); in run_script_worker()
1138 switch (op->op) { in run_script_worker()
1161 (unsigned long)op->op); in run_script_worker()
1166 switch (op->op) { in run_script_worker()
1176 for (i = 0; i < h->num_threads; ++i) { in run_script_worker()
1177 if (h->threads[i].m == NULL) in run_script_worker()
1180 ossl_crypto_mutex_lock(h->threads[i].m); in run_script_worker()
1181 done = h->threads[i].done; in run_script_worker()
1182 ossl_crypto_mutex_unlock(h->threads[i].m); in run_script_worker()
1204 if (!TEST_size_t_gt(op->arg1, 0)) in run_script_worker()
1209 repeat_stack_limit[repeat_stack_len] = op->arg1; in run_script_worker()
1217 op_idx += op->arg1; in run_script_worker()
1221 if (!h->blocking) in run_script_worker()
1224 op_idx += op->arg1; in run_script_worker()
1231 if (++repeat_stack_done[repeat_stack_len - 1] in run_script_worker()
1232 == repeat_stack_limit[repeat_stack_len - 1]) { in run_script_worker()
1233 --repeat_stack_len; in run_script_worker()
1235 op_idx = repeat_stack_idx[repeat_stack_len - 1]; in run_script_worker()
1246 hl->check_op = op; in run_script_worker()
1247 ok = op->check_func(h, hl); in run_script_worker()
1248 hl->check_op = NULL; in run_script_worker()
1250 if (thread_idx < 0 && h->check_spin_again) { in run_script_worker()
1251 h->check_spin_again = 0; in run_script_worker()
1262 const char *alpn = op->arg0; in run_script_worker()
1273 if (!TEST_false(SSL_set_alpn_protos(h->c_conn, tmp_buf, in run_script_worker()
1288 ret = SSL_connect(h->c_conn); in run_script_worker()
1292 if (!h->blocking && is_want(h->c_conn, ret)) in run_script_worker()
1295 if (op->arg1 == 0 && !TEST_int_eq(ret, 1)) in run_script_worker()
1309 r = SSL_write_ex(c_tgt, op->arg0, op->arg1, &bytes_written); in run_script_worker()
1312 || !TEST_size_t_eq(bytes_written, op->arg1)) in run_script_worker()
1325 r = SSL_write_ex2(c_tgt, op->arg0, op->arg1, op->arg2, in run_script_worker()
1329 || !TEST_size_t_eq(bytes_written, op->arg1)) in run_script_worker()
1342 op->arg0, op->arg1, in run_script_worker()
1344 || !TEST_size_t_eq(bytes_written, op->arg1)) in run_script_worker()
1384 if (op->arg1 > 0 && tmp_buf == NULL in run_script_worker()
1385 && !TEST_ptr(tmp_buf = OPENSSL_malloc(op->arg1))) in run_script_worker()
1388 r = SSL_read_ex(c_tgt, tmp_buf + offset, op->arg1 - offset, in run_script_worker()
1396 if (bytes_read + offset != op->arg1) { in run_script_worker()
1401 if (op->arg1 > 0 in run_script_worker()
1402 && !TEST_mem_eq(tmp_buf, op->arg1, op->arg0, op->arg1)) in run_script_worker()
1417 if (op->arg1 > 0 && tmp_buf == NULL in run_script_worker()
1418 && !TEST_ptr(tmp_buf = OPENSSL_malloc(op->arg1))) in run_script_worker()
1423 op->arg1 - offset, in run_script_worker()
1427 if (bytes_read + offset != op->arg1) { in run_script_worker()
1432 if (op->arg1 > 0 in run_script_worker()
1433 && !TEST_mem_eq(tmp_buf, op->arg1, op->arg0, op->arg1)) in run_script_worker()
1482 if (!TEST_ptr(op->stream_name)) in run_script_worker()
1485 if (!TEST_ptr(c_stream = ossl_quic_detach_stream(h->c_conn))) in run_script_worker()
1488 if (!TEST_true(helper_local_set_c_stream(hl, op->stream_name, c_stream))) in run_script_worker()
1498 if (!TEST_ptr(op->stream_name)) in run_script_worker()
1501 if (!TEST_true(ossl_quic_attach_stream(h->c_conn, c_tgt))) in run_script_worker()
1504 if (!TEST_true(helper_local_set_c_stream(hl, op->stream_name, NULL))) in run_script_worker()
1512 uint64_t flags = op->arg1; in run_script_worker()
1520 if (!TEST_ptr(op->stream_name)) in run_script_worker()
1523 c_stream = SSL_new_stream(h->c_conn, flags); in run_script_worker()
1532 ++h->fail_count; in run_script_worker()
1536 if (op->arg2 != UINT64_MAX in run_script_worker()
1538 op->arg2)) in run_script_worker()
1541 if (!TEST_true(helper_local_set_c_stream(hl, op->stream_name, c_stream))) in run_script_worker()
1553 if (!TEST_ptr(op->stream_name)) in run_script_worker()
1557 op->arg1 > 0, in run_script_worker()
1561 if (op->arg2 != UINT64_MAX in run_script_worker()
1562 && !TEST_uint64_t_eq(stream_id, op->arg2)) in run_script_worker()
1565 if (!TEST_true(helper_set_s_stream(h, op->stream_name, in run_script_worker()
1578 if (!TEST_ptr(op->stream_name)) in run_script_worker()
1581 if ((c_stream = SSL_accept_stream(h->c_conn, 0)) == NULL) in run_script_worker()
1584 if (!TEST_true(helper_local_set_c_stream(hl, op->stream_name, in run_script_worker()
1597 if (!TEST_ptr(op->stream_name)) in run_script_worker()
1604 if (!TEST_true(helper_set_s_stream(h, op->stream_name, new_stream_id))) in run_script_worker()
1613 if (!TEST_ptr_null(c_stream = SSL_accept_stream(h->c_conn, in run_script_worker()
1627 if (!TEST_ptr(op->stream_name)) in run_script_worker()
1630 if (!TEST_true(helper_local_set_c_stream(hl, op->stream_name, NULL))) in run_script_worker()
1643 if (!TEST_true(SSL_set_default_stream_mode(c_tgt, op->arg1))) in run_script_worker()
1654 op->arg1, 0))) in run_script_worker()
1662 QUIC_CHANNEL *ch = ossl_quic_conn_get_channel(h->c_conn); in run_script_worker()
1670 args.quic_reason = (const char *)op->arg0; in run_script_worker()
1672 ret = SSL_shutdown_ex(c_tgt, op->arg1, &args, sizeof(args)); in run_script_worker()
1683 ossl_quic_tserver_shutdown(ACQUIRE_S(), op->arg1); in run_script_worker()
1690 int expect_app = (op->arg1 & EXPECT_CONN_CLOSE_APP) != 0; in run_script_worker()
1691 int expect_remote = (op->arg1 & EXPECT_CONN_CLOSE_REMOTE) != 0; in run_script_worker()
1692 uint64_t error_code = op->arg2; in run_script_worker()
1697 if (h->blocking in run_script_worker()
1722 int expect_app = (op->arg1 & EXPECT_CONN_CLOSE_APP) != 0; in run_script_worker()
1723 int expect_remote = (op->arg1 & EXPECT_CONN_CLOSE_REMOTE) != 0; in run_script_worker()
1724 uint64_t error_code = op->arg2; in run_script_worker()
1734 if (!TEST_uint64_t_eq(error_code, tc->error_code) in run_script_worker()
1735 || !TEST_int_eq(expect_app, tc->app) in run_script_worker()
1736 || !TEST_int_eq(expect_remote, tc->remote)) in run_script_worker()
1746 if (!TEST_ptr(op->stream_name)) in run_script_worker()
1749 if (!TEST_true(helper_set_s_stream(h, op->stream_name, op->arg2))) in run_script_worker()
1759 if (!TEST_ptr(op->stream_name)) in run_script_worker()
1762 if (!TEST_true(helper_set_s_stream(h, op->stream_name, UINT64_MAX))) in run_script_worker()
1845 if (!TEST_true(ret == 0 || (op->arg1 && bytes_read == 0))) in run_script_worker()
1858 args.quic_error_code = op->arg2; in run_script_worker()
1859 if (op->op == OPK_C_STREAM_RESET) { in run_script_worker()
1882 if (!TEST_ptr_null(h->threads)) { in run_script_worker()
1887 h->threads = OPENSSL_zalloc(op->arg1 * sizeof(struct child_thread_args)); in run_script_worker()
1888 if (!TEST_ptr(h->threads)) in run_script_worker()
1891 h->num_threads = op->arg1; in run_script_worker()
1893 for (i = 0; i < op->arg1; ++i) { in run_script_worker()
1894 h->threads[i].h = h; in run_script_worker()
1895 h->threads[i].script = op->arg0; in run_script_worker()
1896 h->threads[i].script_name = script_name; in run_script_worker()
1897 h->threads[i].thread_idx = i; in run_script_worker()
1899 h->threads[i].m = ossl_crypto_mutex_new(); in run_script_worker()
1900 if (!TEST_ptr(h->threads[i].m)) in run_script_worker()
1903 h->threads[i].t in run_script_worker()
1905 &h->threads[i], 1); in run_script_worker()
1906 if (!TEST_ptr(h->threads[i].t)) in run_script_worker()
1915 BIO_closesocket(h->c_fd); in run_script_worker()
1916 h->c_fd = -1; in run_script_worker()
1922 if (!TEST_size_t_eq((size_t)SSL_get_error(c_tgt, 0), op->arg1)) in run_script_worker()
1931 if (!TEST_size_t_eq((size_t)ERR_GET_REASON(ERR_peek_last_error()), op->arg1)) in run_script_worker()
1938 if (!TEST_size_t_eq((size_t)ERR_GET_LIB(ERR_peek_last_error()), op->arg1)) in run_script_worker()
1949 OSSL_sleep(op->arg2); in run_script_worker()
1954 h->qtf_packet_plain_cb = op->qtf_packet_plain_cb; in run_script_worker()
1956 if (!TEST_true(qtest_fault_set_packet_plain_listener(h->qtf, in run_script_worker()
1957 h->qtf_packet_plain_cb != NULL ? in run_script_worker()
1959 h))) in run_script_worker()
1965 h->qtf_handshake_cb = op->qtf_handshake_cb; in run_script_worker()
1967 if (!TEST_true(qtest_fault_set_handshake_listener(h->qtf, in run_script_worker()
1968 h->qtf_handshake_cb != NULL ? in run_script_worker()
1970 h))) in run_script_worker()
1976 h->qtf_datagram_cb = op->qtf_datagram_cb; in run_script_worker()
1978 if (!TEST_true(qtest_fault_set_datagram_listener(h->qtf, in run_script_worker()
1979 h->qtf_datagram_cb != NULL ? in run_script_worker()
1981 h))) in run_script_worker()
1988 * Must hold server tick lock - callbacks can be called from other in run_script_worker()
1992 h->inject_word0 = op->arg1; in run_script_worker()
1993 h->inject_word1 = op->arg2; in run_script_worker()
1998 QUIC_CHANNEL *ch = ossl_quic_conn_get_channel(h->c_conn); in run_script_worker()
2001 op->arg1); in run_script_worker()
2009 if (!TEST_true(ossl_quic_set_write_buffer_size(c_tgt, op->arg1))) in run_script_worker()
2026 s_unlock(h, hl); /* idempotent */ in run_script_worker()
2043 if (h->c_conn != NULL) { in run_script_worker()
2046 if (SSL_get_conn_close_info(h->c_conn, &cc_info, sizeof(cc_info))) { in run_script_worker()
2065 cc_info.reason != NULL ? cc_info.reason : "-"); in run_script_worker()
2069 tcause = (h->s != NULL in run_script_worker()
2070 ? ossl_quic_tserver_get_terminate_cause(h->s) : NULL); in run_script_worker()
2072 e_str = ossl_quic_err_to_string(tcause->error_code); in run_script_worker()
2073 f_str = ossl_quic_frame_type_to_string(tcause->frame_type); in run_script_worker()
2082 (unsigned long long)tcause->error_code, in run_script_worker()
2084 (unsigned long long)tcause->frame_type, in run_script_worker()
2086 tcause->remote ? "remote" : "local", in run_script_worker()
2087 tcause->app ? "app" : "transport", in run_script_worker()
2088 tcause->reason != NULL ? tcause->reason : "-"); in run_script_worker()
2103 struct helper h; in run_script() local
2105 if (!TEST_true(helper_init(&h, script_name, in run_script()
2109 if (!TEST_true(run_script_worker(&h, script, script_name, -1))) in run_script()
2113 if (!TEST_true(join_threads(h.threads, h.num_threads))) in run_script()
2119 helper_cleanup(&h); in run_script()
2129 testresult = run_script_worker(args->h, args->script, in run_script_child_thread()
2130 args->script_name, in run_script_child_thread()
2131 args->thread_idx); in run_script_child_thread()
2133 ossl_crypto_mutex_lock(args->m); in run_script_child_thread()
2134 args->testresult = testresult; in run_script_child_thread()
2135 args->done = 1; in run_script_child_thread()
2136 ossl_crypto_mutex_unlock(args->m); in run_script_child_thread()
2141 /* 1. Simple single-stream test */
2147 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
2148 OP_S_READ_EXPECT (a, "apple", 5)
2149 OP_S_EXPECT_FIN (a)
2150 OP_S_WRITE (a, "orange", 6)
2151 OP_S_CONCLUDE (a)
2157 /* 2. Multi-stream test */
2163 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
2164 OP_S_READ_EXPECT (a, "apple", 5)
2165 OP_S_WRITE (a, "orange", 6)
2228 OP_S_NEW_STREAM_BIDI (h, S_BIDI_ID(3))
2229 OP_S_WRITE (h, "UNSEEN", 6)
2230 OP_S_CONCLUDE (h)
2235 * Streams g, h should have been rejected, so server should have got
2250 OP_C_DETACH (a) /* DEFAULT becomes stream 'a' */
2253 OP_C_WRITE (a, "by", 2)
2255 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
2256 OP_S_READ_EXPECT (a, "appleby", 7)
2258 OP_S_WRITE (a, "hello", 5)
2259 OP_C_READ_EXPECT (a, "hello", 5)
2262 OP_C_ATTACH (a)
2264 OP_S_READ_EXPECT (a, "is here", 7)
2266 OP_C_DETACH (a)
2267 OP_C_CONCLUDE (a)
2268 OP_S_EXPECT_FIN (a)
2281 OP_S_NEW_STREAM_BIDI (a, S_BIDI_ID(0))
2282 OP_S_WRITE (a, "apple", 5)
2286 OP_C_ACCEPT_STREAM_WAIT (a)
2287 OP_C_READ_EXPECT (a, "apple", 5)
2289 OP_C_ATTACH (a)
2291 OP_S_READ_EXPECT (a, "orange", 6)
2302 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
2305 OP_C_WRITE (a, "apple", 5)
2306 OP_C_STREAM_RESET (a, 42)
2310 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
2314 OP_S_READ_FAIL (a, 0)
2326 OP_S_NEW_STREAM_BIDI (a, S_BIDI_ID(0))
2327 OP_S_WRITE (a, "apple", 5)
2329 OP_C_ACCEPT_STREAM_WAIT (a)
2330 OP_C_FREE_STREAM (a)
2346 OP_S_BIND_STREAM_ID (a, C_UNI_ID(0))
2347 OP_S_READ_EXPECT (a, "apple", 5)
2348 OP_S_WRITE_FAIL (a)
2359 OP_S_NEW_STREAM_UNI (a, S_UNI_ID(0))
2360 OP_S_WRITE (a, "apple", 5)
2373 OP_S_NEW_STREAM_BIDI (a, S_BIDI_ID(0))
2374 OP_S_WRITE (a, "apple", 5)
2377 OP_S_READ_EXPECT (a, "orange", 6)
2388 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
2389 OP_S_READ_EXPECT (a, "apple", 5)
2400 OP_C_ACCEPT_STREAM_WAIT (a)
2401 OP_C_READ_EXPECT (a, "foo", 3)
2403 OP_C_EXPECT_FIN (a)
2415 OP_S_NEW_STREAM_BIDI (a, ANY_ID)
2416 OP_S_WRITE (a, "foo", 3)
2417 OP_S_CONCLUDE (a)
2440 OP_C_NEW_STREAM_BIDI (a, ANY_ID)
2441 OP_C_WRITE (a, "foo", 3)
2442 OP_C_CONCLUDE (a)
2443 OP_C_FREE_STREAM (a)
2455 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
2456 OP_S_READ_EXPECT (a, "foo", 3)
2457 OP_S_EXPECT_FIN (a)
2478 OP_C_ACCEPT_STREAM_WAIT (a)
2479 OP_C_READ_EXPECT (a, "foo", 3)
2480 OP_C_EXPECT_FIN (a)
2481 OP_C_FREE_STREAM (a)
2497 OP_S_NEW_STREAM_BIDI (a, ANY_ID)
2498 OP_S_WRITE (a, "foo", 3)
2499 OP_S_CONCLUDE (a)
2500 OP_S_UNBIND_STREAM_ID (a)
2511 OP_C_NEW_STREAM_BIDI (a, ANY_ID)
2512 OP_C_WRITE (a, "foo", 3)
2513 OP_C_CONCLUDE (a)
2514 OP_C_FREE_STREAM (a)
2530 OP_S_ACCEPT_STREAM_WAIT (a)
2531 OP_S_READ_EXPECT (a, "foo", 3)
2532 OP_S_EXPECT_FIN (a)
2533 OP_S_UNBIND_STREAM_ID (a)
2547 * This will cause a protocol violation to be raised by the server if we are
2552 OP_C_NEW_STREAM_BIDI_EX (a, ANY_ID, SSL_STREAM_FLAG_ADVANCE)
2553 OP_C_WRITE (a, "foo", 3)
2554 OP_C_CONCLUDE (a)
2555 OP_C_FREE_STREAM (a)
2560 OP_S_NEW_STREAM_BIDI (a, S_BIDI_ID(0))
2561 OP_S_WRITE (a, "bar", 3)
2562 OP_S_CONCLUDE (a)
2564 OP_C_ACCEPT_STREAM_WAIT (a)
2565 OP_C_READ_EXPECT (a, "bar", 3)
2566 OP_C_EXPECT_FIN (a)
2570 * even though only 100 can be initiated at a time.
2591 * This will cause a protocol violation to be raised by the client if we are
2596 OP_S_NEW_STREAM_BIDI (a, ANY_ID)
2597 OP_S_WRITE (a, "foo", 3)
2598 OP_S_CONCLUDE (a)
2599 OP_S_UNBIND_STREAM_ID (a)
2604 OP_C_NEW_STREAM_BIDI (a, ANY_ID)
2605 OP_C_WRITE (a, "bar", 3)
2606 OP_C_CONCLUDE (a)
2625 /* 17. Key update test - unlimited */
2632 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
2633 OP_S_READ_EXPECT (a, "apple", 5)
2640 OP_S_READ_EXPECT (a, "apple", 5)
2643 * TXKU frequency is bounded by RTT because a previous TXKU needs to be
2660 OP_S_READ_EXPECT (a, "xyzzy", 5)
2662 OP_S_WRITE (a, "plugh", 5)
2668 /* 18. Key update test - RTT-bounded */
2675 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
2676 OP_S_READ_EXPECT (a, "apple", 5)
2683 OP_S_READ_EXPECT (a, "apple", 5)
2690 * fewer opportunities to initiate TXKUs. Note that we ask for a TXKU every
2701 OP_S_READ_EXPECT (a, "xyzzy", 5)
2703 OP_S_WRITE (a, "plugh", 5)
2709 /* 19. Key update test - artificially triggered */
2716 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
2717 OP_S_READ_EXPECT (a, "apple", 5)
2720 OP_S_READ_EXPECT (a, "orange", 6)
2722 OP_S_WRITE (a, "strawberry", 10)
2729 OP_S_READ_EXPECT (a, "orange", 6)
2730 OP_S_WRITE (a, "ok", 2)
2739 static int script_20_trigger(struct helper *h, volatile uint64_t *counter) in script_20_trigger() argument
2742 ossl_crypto_mutex_lock(h->misc_m); in script_20_trigger()
2744 ossl_crypto_condvar_broadcast(h->misc_cv); in script_20_trigger()
2745 ossl_crypto_mutex_unlock(h->misc_m); in script_20_trigger()
2750 static int script_20_wait(struct helper *h, volatile uint64_t *counter, uint64_t threshold) in script_20_wait() argument
2755 ossl_crypto_mutex_lock(h->misc_m); in script_20_wait()
2761 ossl_crypto_condvar_wait(h->misc_cv, h->misc_m); in script_20_wait()
2764 ossl_crypto_mutex_unlock(h->misc_m); in script_20_wait()
2769 static int script_20_trigger1(struct helper *h, struct helper_local *hl) in script_20_trigger1() argument
2771 return script_20_trigger(h, &h->scratch0); in script_20_trigger1()
2774 static int script_20_wait1(struct helper *h, struct helper_local *hl) in script_20_wait1() argument
2776 return script_20_wait(h, &h->scratch0, hl->check_op->arg2); in script_20_wait1()
2779 static int script_20_trigger2(struct helper *h, struct helper_local *hl) in script_20_trigger2() argument
2781 return script_20_trigger(h, &h->scratch1); in script_20_trigger2()
2784 static int script_20_wait2(struct helper *h, struct helper_local *hl) in script_20_wait2() argument
2786 return script_20_wait(h, &h->scratch1, hl->check_op->arg2); in script_20_wait2()
2790 OP_C_ACCEPT_STREAM_WAIT (a)
2791 OP_C_READ_EXPECT (a, "foo", 3)
2796 OP_C_READ_FAIL_WAIT (a)
2797 OP_C_EXPECT_SSL_ERR (a, SSL_ERROR_SYSCALL)
2806 OP_C_FREE_STREAM (a)
2820 OP_S_NEW_STREAM_BIDI (a, ANY_ID)
2821 OP_S_WRITE (a, "foo", 3)
2822 OP_S_UNBIND_STREAM_ID (a)
2834 /* 21. Fault injection - unknown frame in 1-RTT packet */
2835 static int script_21_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr, in script_21_inject_plain() argument
2843 if (h->inject_word0 == 0 || hdr->type != h->inject_word0) in script_21_inject_plain()
2850 if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, h->inject_word1))) in script_21_inject_plain()
2853 switch (h->inject_word1) { in script_21_inject_plain()
2858 * These cases to be formatted properly need a single uint64_t in script_21_inject_plain()
2870 * These cases require a single vlint in script_21_inject_plain()
2914 * Special case for New Connection ids, has a combination in script_21_inject_plain()
2944 if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written)) in script_21_inject_plain()
2962 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
2963 OP_S_READ_EXPECT (a, "apple", 5)
2967 OP_S_WRITE (a, "orange", 6)
2974 /* 22. Fault injection - non-zero packet header reserved bits */
2975 static int script_22_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr, in script_22_inject_plain() argument
2978 if (h->inject_word0 == 0) in script_22_inject_plain()
2981 hdr->reserved = 1; in script_22_inject_plain()
2991 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
2992 OP_S_READ_EXPECT (a, "apple", 5)
2996 OP_S_WRITE (a, "orange", 6)
3003 /* 23. Fault injection - empty NEW_TOKEN */
3004 static int script_23_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr, in script_23_inject_plain() argument
3012 if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT) in script_23_inject_plain()
3026 if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written)) in script_23_inject_plain()
3044 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
3045 OP_S_READ_EXPECT (a, "apple", 5)
3049 OP_S_WRITE (a, "orange", 6)
3056 /* 24. Fault injection - excess value of MAX_STREAMS_BIDI */
3057 static int script_24_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr, in script_24_inject_plain() argument
3065 if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT) in script_24_inject_plain()
3072 if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, h->inject_word1)) in script_24_inject_plain()
3079 if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written)) in script_24_inject_plain()
3097 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
3098 OP_S_READ_EXPECT (a, "apple", 5)
3102 OP_S_WRITE (a, "orange", 6)
3109 /* 25. Fault injection - excess value of MAX_STREAMS_UNI */
3116 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
3117 OP_S_READ_EXPECT (a, "apple", 5)
3121 OP_S_WRITE (a, "orange", 6)
3128 /* 26. Fault injection - excess value of STREAMS_BLOCKED_BIDI */
3135 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
3136 OP_S_READ_EXPECT (a, "apple", 5)
3140 OP_S_WRITE (a, "orange", 6)
3147 /* 27. Fault injection - excess value of STREAMS_BLOCKED_UNI */
3154 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
3155 OP_S_READ_EXPECT (a, "apple", 5)
3159 OP_S_WRITE (a, "orange", 6)
3166 /* 28. Fault injection - received RESET_STREAM for send-only stream */
3167 static int script_28_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr, in script_28_inject_plain() argument
3175 if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT) in script_28_inject_plain()
3182 if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, h->inject_word1)) in script_28_inject_plain()
3184 h->inject_word0 - 1)) in script_28_inject_plain()
3186 || (h->inject_word1 == OSSL_QUIC_FRAME_TYPE_RESET_STREAM in script_28_inject_plain()
3193 if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written)) in script_28_inject_plain()
3211 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
3212 OP_C_WRITE (a, "orange", 6)
3214 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
3215 OP_S_READ_EXPECT (a, "orange", 6)
3224 OP_S_WRITE (a, "fruit", 5)
3231 /* 29. Fault injection - received RESET_STREAM for nonexistent send-only stream */
3238 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
3239 OP_C_WRITE (a, "orange", 6)
3241 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
3242 OP_S_READ_EXPECT (a, "orange", 6)
3251 OP_S_WRITE (a, "fruit", 5)
3258 /* 30. Fault injection - received STOP_SENDING for receive-only stream */
3265 OP_S_NEW_STREAM_UNI (a, S_UNI_ID(0))
3266 OP_S_WRITE (a, "apple", 5)
3268 OP_C_ACCEPT_STREAM_WAIT (a)
3269 OP_C_READ_EXPECT (a, "apple", 5)
3272 OP_S_WRITE (a, "orange", 6)
3279 /* 31. Fault injection - received STOP_SENDING for nonexistent receive-only stream */
3286 OP_S_NEW_STREAM_UNI (a, S_UNI_ID(0))
3287 OP_S_WRITE (a, "apple", 5)
3289 OP_C_ACCEPT_STREAM_WAIT (a)
3290 OP_C_READ_EXPECT (a, "apple", 5)
3293 OP_S_WRITE (a, "orange", 6)
3300 /* 32. Fault injection - STREAM frame for nonexistent stream */
3301 static int script_32_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr, in script_32_inject_plain() argument
3310 if (hdr->type != QUIC_PKT_TYPE_1RTT) in script_32_inject_plain()
3313 switch (h->inject_word1) { in script_32_inject_plain()
3323 offset = (((uint64_t)1)<<62) - 1; in script_32_inject_plain()
3342 h->inject_word0 - 1)) in script_32_inject_plain()
3354 if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written)) in script_32_inject_plain()
3372 OP_S_NEW_STREAM_UNI (a, S_UNI_ID(0))
3373 OP_S_WRITE (a, "apple", 5)
3375 OP_C_ACCEPT_STREAM_WAIT (a)
3376 OP_C_READ_EXPECT (a, "apple", 5)
3379 OP_S_WRITE (a, "orange", 6)
3386 /* 33. Fault injection - STREAM frame with illegal offset */
3393 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
3394 OP_C_WRITE (a, "apple", 5)
3396 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
3397 OP_S_READ_EXPECT (a, "apple", 5)
3400 OP_S_WRITE (a, "orange", 6)
3407 /* 34. Fault injection - STREAM frame which exceeds FC */
3414 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
3415 OP_C_WRITE (a, "apple", 5)
3417 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
3418 OP_S_READ_EXPECT (a, "apple", 5)
3421 OP_S_WRITE (a, "orange", 6)
3428 /* 35. Fault injection - MAX_STREAM_DATA for receive-only stream */
3435 OP_S_NEW_STREAM_UNI (a, S_UNI_ID(0))
3436 OP_S_WRITE (a, "apple", 5)
3438 OP_C_ACCEPT_STREAM_WAIT (a)
3439 OP_C_READ_EXPECT (a, "apple", 5)
3442 OP_S_WRITE (a, "orange", 6)
3449 /* 36. Fault injection - MAX_STREAM_DATA for nonexistent stream */
3456 OP_S_NEW_STREAM_UNI (a, S_UNI_ID(0))
3457 OP_S_WRITE (a, "apple", 5)
3459 OP_C_ACCEPT_STREAM_WAIT (a)
3460 OP_C_READ_EXPECT (a, "apple", 5)
3463 OP_S_WRITE (a, "orange", 6)
3470 /* 37. Fault injection - STREAM_DATA_BLOCKED for send-only stream */
3477 OP_C_NEW_STREAM_UNI (a, C_UNI_ID(0))
3478 OP_C_WRITE (a, "apple", 5)
3480 OP_S_BIND_STREAM_ID (a, C_UNI_ID(0))
3481 OP_S_READ_EXPECT (a, "apple", 5)
3492 /* 38. Fault injection - STREAM_DATA_BLOCKED for non-existent stream */
3499 OP_C_NEW_STREAM_UNI (a, C_UNI_ID(0))
3500 OP_C_WRITE (a, "apple", 5)
3502 OP_S_BIND_STREAM_ID (a, C_UNI_ID(0))
3503 OP_S_READ_EXPECT (a, "apple", 5)
3515 /* 39. Fault injection - NEW_CONN_ID with zero-len CID */
3516 static int script_39_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr, in script_39_inject_plain() argument
3525 QUIC_CHANNEL *ch = ossl_quic_tserver_get_channel(h->s_priv); in script_39_inject_plain()
3527 if (hdr->type != QUIC_PKT_TYPE_1RTT) in script_39_inject_plain()
3530 switch (h->inject_word1) { in script_39_inject_plain()
3555 * Use a bogus CID which will need to be ignored if connectivity is to in script_39_inject_plain()
3591 if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written)) in script_39_inject_plain()
3609 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
3610 OP_C_WRITE (a, "apple", 5)
3611 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
3612 OP_S_READ_EXPECT (a, "apple", 5)
3615 OP_S_WRITE (a, "orange", 5)
3630 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
3631 OP_C_WRITE (a, "apple", 5)
3634 OP_C_SET_WRITE_BUF_SIZE (a, 1024 * 100 * 3)
3638 OP_C_WRITE (a, script_40_data, sizeof(script_40_data))
3642 OP_C_CONCLUDE (a)
3645 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
3646 OP_S_READ_EXPECT (a, "apple", 5)
3650 OP_S_READ_EXPECT (a, script_40_data, sizeof(script_40_data))
3654 OP_S_EXPECT_FIN (a)
3662 /* 41. Fault injection - PATH_CHALLENGE yields PATH_RESPONSE */
3665 static int script_41_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr, in script_41_inject_plain() argument
3673 if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT) in script_41_inject_plain()
3680 if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, h->inject_word1)) in script_41_inject_plain()
3688 if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written)) in script_41_inject_plain()
3691 --h->inject_word0; in script_41_inject_plain()
3706 struct helper *h = arg; in script_41_trace() local
3715 ++h->scratch1; in script_41_trace()
3721 ++h->scratch1; in script_41_trace()
3730 ++h->scratch1; in script_41_trace()
3734 ++h->scratch0; in script_41_trace()
3737 static int script_41_setup(struct helper *h, struct helper_local *hl) in script_41_setup() argument
3739 ossl_quic_tserver_set_msg_callback(ACQUIRE_S(), script_41_trace, h); in script_41_setup()
3743 static int script_41_check(struct helper *h, struct helper_local *hl) in script_41_check() argument
3746 if (!TEST_uint64_t_gt(h->scratch0, 0)) in script_41_check()
3750 if (!TEST_uint64_t_eq(h->scratch1, 0)) in script_41_check()
3763 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
3764 OP_S_READ_EXPECT (a, "apple", 5)
3768 OP_S_WRITE (a, "orange", 6)
3772 OP_S_READ_EXPECT (a, "strawberry", 10)
3778 /* 42. Fault injection - CRYPTO frame with illegal offset */
3779 static int script_42_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr, in script_42_inject_plain() argument
3787 if (h->inject_word0 == 0) in script_42_inject_plain()
3790 --h->inject_word0; in script_42_inject_plain()
3797 || !TEST_true(WPACKET_quic_write_vlint(&wpkt, h->inject_word1)) in script_42_inject_plain()
3805 if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written)) in script_42_inject_plain()
3823 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
3824 OP_C_WRITE (a, "apple", 5)
3826 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
3827 OP_S_READ_EXPECT (a, "apple", 5)
3829 OP_SET_INJECT_WORD (1, (((uint64_t)1) << 62) - 1)
3830 OP_S_WRITE (a, "orange", 6)
3837 /* 43. Fault injection - CRYPTO frame exceeding FC */
3844 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
3845 OP_C_WRITE (a, "apple", 5)
3847 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
3848 OP_S_READ_EXPECT (a, "apple", 5)
3851 OP_S_WRITE (a, "orange", 6)
3858 /* 44. Fault injection - PADDING */
3859 static int script_44_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr, in script_44_inject_plain() argument
3867 if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT) in script_44_inject_plain()
3880 if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written)) in script_44_inject_plain()
3898 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
3899 OP_S_READ_EXPECT (a, "apple", 5)
3903 OP_S_WRITE (a, "Strawberry", 10)
3910 static int force_ping(struct helper *h, struct helper_local *hl) in force_ping() argument
3914 h->scratch0 = ossl_quic_channel_get_diag_num_rx_ack(ch); in force_ping()
3922 static int wait_incoming_acks_increased(struct helper *h, struct helper_local *hl) in wait_incoming_acks_increased() argument
3929 if (count == h->scratch0) { in wait_incoming_acks_increased()
3930 h->check_spin_again = 1; in wait_incoming_acks_increased()
3942 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
3943 OP_S_READ_EXPECT (a, "apple", 5)
3952 OP_S_WRITE (a, "Strawberry", 10)
3958 /* 46. Fault injection - ACK - malformed initial range */
3959 static int script_46_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr, in script_46_inject_plain() argument
3970 if (h->inject_word0 == 0) in script_46_inject_plain()
3979 switch (h->inject_word0) { in script_46_inject_plain()
4017 h->inject_word0 = 0; in script_46_inject_plain()
4040 if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written)) in script_46_inject_plain()
4058 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
4059 OP_S_READ_EXPECT (a, "apple", 5)
4063 OP_S_WRITE (a, "Strawberry", 10)
4070 /* 47. Fault injection - ACK - malformed subsequent range */
4077 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
4078 OP_S_READ_EXPECT (a, "apple", 5)
4082 OP_S_WRITE (a, "Strawberry", 10)
4089 /* 48. Fault injection - ACK - malformed subsequent range */
4096 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
4097 OP_S_READ_EXPECT (a, "apple", 5)
4101 OP_S_WRITE (a, "Strawberry", 10)
4108 /* 49. Fault injection - ACK - fictional PN */
4115 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
4116 OP_S_READ_EXPECT (a, "apple", 5)
4120 OP_S_WRITE (a, "Strawberry", 10)
4126 /* 50. Fault injection - ACK - duplicate PN */
4133 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
4134 OP_S_READ_EXPECT (a, "apple", 5)
4140 OP_S_WRITE (a, "Strawberry", 10)
4148 /* 51. Fault injection - PATH_RESPONSE is ignored */
4155 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
4156 OP_S_READ_EXPECT (a, "apple", 5)
4160 OP_S_WRITE (a, "orange", 6)
4164 OP_S_READ_EXPECT (a, "Strawberry", 10)
4169 /* 52. Fault injection - ignore BLOCKED frames with bogus values */
4170 static int script_52_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr, in script_52_inject_plain() argument
4177 uint64_t type = h->inject_word1; in script_52_inject_plain()
4179 if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT) in script_52_inject_plain()
4182 --h->inject_word0; in script_52_inject_plain()
4201 if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written)) in script_52_inject_plain()
4219 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
4220 OP_S_READ_EXPECT (a, "apple", 5)
4224 OP_S_WRITE (a, "orange", 6)
4228 OP_S_READ_EXPECT (a, "Strawberry", 10)
4232 OP_S_WRITE (a, "orange", 6)
4236 OP_S_READ_EXPECT (a, "Strawberry", 10)
4240 OP_S_WRITE (a, "orange", 6)
4244 OP_S_READ_EXPECT (a, "Strawberry", 10)
4248 OP_S_WRITE (a, "orange", 6)
4252 OP_S_READ_EXPECT (a, "Strawberry", 10)
4257 /* 53. Fault injection - excess CRYPTO buffer size */
4258 static int script_53_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr, in script_53_inject_plain() argument
4268 if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT) in script_53_inject_plain()
4271 h->inject_word0 = 0; in script_53_inject_plain()
4273 switch (h->inject_word1) { in script_53_inject_plain()
4278 * waiting for in-order delivery of previous bytes. This tests our flow in script_53_inject_plain()
4305 if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written)) in script_53_inject_plain()
4324 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
4325 OP_S_READ_EXPECT (a, "apple", 5)
4328 OP_S_WRITE (a, "Strawberry", 10)
4335 /* 54. Fault injection - corrupted crypto stream data */
4336 static int script_54_inject_handshake(struct helper *h, in script_54_inject_handshake() argument
4357 /* 55. Fault injection - NEW_CONN_ID with >20 byte CID */
4364 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
4365 OP_C_WRITE (a, "apple", 5)
4366 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
4367 OP_S_READ_EXPECT (a, "apple", 5)
4370 OP_S_WRITE (a, "orange", 5)
4377 /* 56. Fault injection - NEW_CONN_ID with seq no < retire prior to */
4384 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
4385 OP_C_WRITE (a, "apple", 5)
4386 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
4387 OP_S_READ_EXPECT (a, "apple", 5)
4390 OP_S_WRITE (a, "orange", 5)
4397 /* 57. Fault injection - NEW_CONN_ID with lower seq so ignored */
4404 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
4405 OP_C_WRITE (a, "apple", 5)
4406 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
4407 OP_S_READ_EXPECT (a, "apple", 5)
4410 OP_S_WRITE (a, "orange", 5)
4411 OP_C_READ_EXPECT (a, "orange", 5)
4413 OP_C_WRITE (a, "Strawberry", 10)
4414 OP_S_READ_EXPECT (a, "Strawberry", 10)
4417 * Now we send a NEW_CONN_ID with a bogus CID. However the sequence number
4422 OP_S_WRITE (a, "raspberry", 9)
4423 OP_C_READ_EXPECT (a, "raspberry", 9)
4425 OP_C_WRITE (a, "peach", 5)
4426 OP_S_READ_EXPECT (a, "peach", 5)
4431 /* 58. Fault injection - repeated HANDSHAKE_DONE */
4432 static int script_58_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr, in script_58_inject_plain() argument
4440 if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT) in script_58_inject_plain()
4447 if (h->inject_word0 == 1) { in script_58_inject_plain()
4451 /* Needless multi-byte encoding */ in script_58_inject_plain()
4460 if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written)) in script_58_inject_plain()
4478 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
4479 OP_S_READ_EXPECT (a, "apple", 5)
4483 OP_S_WRITE (a, "orange", 6)
4487 OP_S_READ_EXPECT (a, "Strawberry", 10)
4492 /* 59. Fault injection - multi-byte frame encoding */
4499 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
4500 OP_S_READ_EXPECT (a, "apple", 5)
4504 OP_S_WRITE (a, "orange", 6)
4514 static int init_reason(struct helper *h, struct helper_local *hl) in init_reason() argument
4517 memcpy(long_reason, "This is a long reason string.", 29); in init_reason()
4518 long_reason[OSSL_NELEM(long_reason) - 1] = '\0'; in init_reason()
4522 static int check_shutdown_reason(struct helper *h, struct helper_local *hl) in check_shutdown_reason() argument
4527 h->check_spin_again = 1; in check_shutdown_reason()
4531 if (!TEST_size_t_ge(tc->reason_len, 50) in check_shutdown_reason()
4532 || !TEST_mem_eq(long_reason, tc->reason_len, in check_shutdown_reason()
4533 tc->reason, tc->reason_len)) in check_shutdown_reason()
4544 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
4545 OP_S_READ_EXPECT (a, "apple", 5)
4554 /* 61. Fault injection - RESET_STREAM exceeding stream count FC */
4555 static int script_61_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr, in script_61_inject_plain() argument
4563 if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT) in script_61_inject_plain()
4570 if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, h->inject_word0)) in script_61_inject_plain()
4572 h->inject_word1)) in script_61_inject_plain()
4574 || (h->inject_word0 == OSSL_QUIC_FRAME_TYPE_RESET_STREAM in script_61_inject_plain()
4581 if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written)) in script_61_inject_plain()
4599 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
4600 OP_C_WRITE (a, "orange", 6)
4602 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
4603 OP_S_READ_EXPECT (a, "orange", 6)
4607 OP_S_WRITE (a, "fruit", 5)
4614 /* 62. Fault injection - STOP_SENDING with high ID */
4621 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
4622 OP_C_WRITE (a, "orange", 6)
4624 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
4625 OP_S_READ_EXPECT (a, "orange", 6)
4629 OP_S_WRITE (a, "fruit", 5)
4636 /* 63. Fault injection - STREAM frame exceeding stream limit */
4643 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
4644 OP_C_WRITE (a, "apple", 5)
4646 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
4647 OP_S_READ_EXPECT (a, "apple", 5)
4650 OP_S_WRITE (a, "orange", 6)
4657 /* 64. Fault injection - STREAM - zero-length no-FIN is accepted */
4664 OP_S_NEW_STREAM_UNI (a, S_UNI_ID(0))
4665 OP_S_WRITE (a, "apple", 5)
4667 OP_C_ACCEPT_STREAM_WAIT (a)
4668 OP_C_READ_EXPECT (a, "apple", 5)
4671 OP_S_WRITE (a, "orange", 6)
4672 OP_C_READ_EXPECT (a, "orange", 6)
4677 /* 65. Fault injection - CRYPTO - zero-length is accepted */
4678 static int script_65_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr, in script_65_inject_plain() argument
4686 if (h->inject_word0 == 0) in script_65_inject_plain()
4689 --h->inject_word0; in script_65_inject_plain()
4703 if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written)) in script_65_inject_plain()
4721 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
4722 OP_C_WRITE (a, "apple", 5)
4724 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
4725 OP_S_READ_EXPECT (a, "apple", 5)
4728 OP_S_WRITE (a, "orange", 6)
4729 OP_C_READ_EXPECT (a, "orange", 6)
4734 /* 66. Fault injection - large MAX_STREAM_DATA */
4735 static int script_66_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr, in script_66_inject_plain() argument
4743 if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT) in script_66_inject_plain()
4750 if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, h->inject_word1))) in script_66_inject_plain()
4753 if (h->inject_word1 == OSSL_QUIC_FRAME_TYPE_MAX_STREAM_DATA) in script_66_inject_plain()
4755 h->inject_word0 - 1))) in script_66_inject_plain()
4764 if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written)) in script_66_inject_plain()
4782 OP_S_NEW_STREAM_BIDI (a, S_BIDI_ID(0))
4783 OP_S_WRITE (a, "apple", 5)
4785 OP_C_ACCEPT_STREAM_WAIT (a)
4786 OP_C_READ_EXPECT (a, "apple", 5)
4789 OP_S_WRITE (a, "orange", 6)
4790 OP_C_READ_EXPECT (a, "orange", 6)
4791 OP_C_WRITE (a, "Strawberry", 10)
4792 OP_S_READ_EXPECT (a, "Strawberry", 10)
4797 /* 67. Fault injection - large MAX_DATA */
4804 OP_S_NEW_STREAM_BIDI (a, S_BIDI_ID(0))
4805 OP_S_WRITE (a, "apple", 5)
4807 OP_C_ACCEPT_STREAM_WAIT (a)
4808 OP_C_READ_EXPECT (a, "apple", 5)
4811 OP_S_WRITE (a, "orange", 6)
4812 OP_C_READ_EXPECT (a, "orange", 6)
4813 OP_C_WRITE (a, "Strawberry", 10)
4814 OP_S_READ_EXPECT (a, "Strawberry", 10)
4819 /* 68. Fault injection - Unexpected TLS messages */
4820 static int script_68_inject_handshake(struct helper *h, unsigned char *msg, in script_68_inject_handshake() argument
4842 switch(h->inject_word0) { in script_68_inject_handshake()
4862 if (!TEST_true(qtest_fault_resize_message(h->qtf, in script_68_inject_handshake()
4863 datalen - SSL3_HM_HEADER_LENGTH))) in script_68_inject_handshake()
4871 /* Send a CerticateRequest message post-handshake */
4878 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
4879 OP_C_WRITE (a, "apple", 5)
4880 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
4881 OP_S_READ_EXPECT (a, "apple", 5)
4885 OP_S_WRITE (a, "orange", 6)
4892 /* 69. Send a TLS KeyUpdate message post-handshake */
4899 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
4900 OP_C_WRITE (a, "apple", 5)
4901 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
4902 OP_S_READ_EXPECT (a, "apple", 5)
4906 OP_S_WRITE (a, "orange", 6)
4914 static int set_max_early_data(struct helper *h, struct helper_local *hl) in set_max_early_data() argument
4918 (uint32_t)hl->check_op->arg2))) in set_max_early_data()
4924 /* 70. Send a TLS NewSessionTicket message with invalid max_early_data */
4930 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
4931 OP_C_WRITE (a, "apple", 5)
4932 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
4933 OP_S_READ_EXPECT (a, "apple", 5)
4937 OP_S_WRITE (a, "orange", 6)
4944 /* 71. Send a TLS NewSessionTicket message with valid max_early_data */
4950 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
4951 OP_C_WRITE (a, "apple", 5)
4952 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
4953 OP_S_READ_EXPECT (a, "apple", 5)
4957 OP_S_WRITE (a, "orange", 6)
4958 OP_C_READ_EXPECT (a, "orange", 6)
4964 static int script_72_check(struct helper *h, struct helper_local *hl) in script_72_check() argument
4966 if (!TEST_uint64_t_ge(h->fail_count, 50)) in script_72_check()
4978 * Request more streams than a server will initially hand out and test that
4983 OP_C_NEW_STREAM_BIDI_EX (a, ANY_ID, ALLOW_FAIL | SSL_STREAM_FLAG_NO_BLOCK)
4984 OP_C_SKIP_IF_UNBOUND (a, 2)
4985 OP_C_WRITE (a, "apple", 5)
4986 OP_C_FREE_STREAM (a)
5002 * Request more streams than a server will initially hand out and test that
5007 OP_C_NEW_STREAM_UNI_EX (a, ANY_ID, ALLOW_FAIL | SSL_STREAM_FLAG_NO_BLOCK)
5008 OP_C_SKIP_IF_UNBOUND (a, 2)
5009 OP_C_WRITE (a, "apple", 5)
5010 OP_C_FREE_STREAM (a)
5040 static int server_gen_version_neg(struct helper *h, BIO_MSG *msg, size_t stride) in server_gen_version_neg() argument
5048 switch (h->inject_word0) { in server_gen_version_neg()
5072 if (!TEST_true(qtest_fault_resize_datagram(h->qtf, l))) in server_gen_version_neg()
5075 memcpy(msg->data, buf->data, l); in server_gen_version_neg()
5076 h->inject_word0 = 0; in server_gen_version_neg()
5093 * so that we trigger a version negotiation
5094 * Note, this is a use once function, it will only modify the
5114 if (hdrin->type == QUIC_PKT_TYPE_INITIAL) in script_74_alter_version()
5115 (*hdrout)->version = 0xdeadbeef; in script_74_alter_version()
5126 * So that when we send a Initial packet
5128 * to force a version negotiation
5130 static int script_74_arm_packet_mutator(struct helper *h, in script_74_arm_packet_mutator() argument
5133 QUIC_CHANNEL *ch = ossl_quic_conn_get_channel(h->c_conn); in script_74_arm_packet_mutator()
5150 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
5151 OP_C_WRITE (a, "apple", 5)
5152 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
5153 OP_S_READ_EXPECT (a, "apple", 5)
5171 /* 76. Test peer-initiated shutdown wait */
5172 static int script_76_check(struct helper *h, struct helper_local *hl) in script_76_check() argument
5174 if (!TEST_false(SSL_shutdown_ex(h->c_conn, in script_76_check()
5188 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
5189 OP_C_WRITE (a, "apple", 5)
5191 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
5192 OP_S_READ_EXPECT (a, "apple", 5)
5194 /* Check a WAIT_PEER call doesn't succeed yet. */
5211 OP_S_NEW_STREAM_BIDI (a, S_BIDI_ID(0))
5212 OP_S_WRITE (a, "Strawberry", 10)
5225 /* 78. Post-connection session ticket handling */
5234 static int setup_session(struct helper *h, struct helper_local *hl) in setup_session() argument
5236 SSL_CTX_set_session_cache_mode(h->c_ctx, SSL_SESS_CACHE_BOTH); in setup_session()
5237 SSL_CTX_sess_set_new_cb(h->c_ctx, on_new_session); in setup_session()
5241 static int trigger_late_session_ticket(struct helper *h, struct helper_local *hl) in trigger_late_session_ticket() argument
5251 static int check_got_session_ticket(struct helper *h, struct helper_local *hl) in check_got_session_ticket() argument
5259 static int check_idle_timeout(struct helper *h, struct helper_local *hl);
5268 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
5269 OP_C_WRITE (a, "apple", 5)
5271 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
5272 OP_S_READ_EXPECT (a, "apple", 5)
5274 OP_S_WRITE (a, "orange", 6)
5275 OP_C_READ_EXPECT (a, "orange", 6)
5279 OP_S_WRITE (a, "Strawberry", 10)
5280 OP_C_READ_EXPECT (a, "Strawberry", 10)
5294 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
5295 OP_S_READ_EXPECT (a, "apple", 5)
5296 OP_S_EXPECT_FIN (a)
5297 OP_S_WRITE (a, "orange", 6)
5298 OP_S_CONCLUDE (a)
5310 * Generate a packet in the following format:
5311 * https://www.rfc-editor.org/rfc/rfc9000.html#name-stateless-reset
5318 static int script_80_send_stateless_reset(struct helper *h, QUIC_PKT_HDR *hdr, in script_80_send_stateless_reset() argument
5323 if (h->inject_word1 == 0) in script_80_send_stateless_reset()
5326 h->inject_word1 = 0; in script_80_send_stateless_reset()
5335 if (!TEST_int_eq(SSL_inject_net_dgram(h->c_conn, databuf, sizeof(databuf), in script_80_send_stateless_reset()
5336 NULL, h->s_net_bio_addr), 1)) in script_80_send_stateless_reset()
5342 static int script_80_gen_new_conn_id(struct helper *h, QUIC_PKT_HDR *hdr, in script_80_gen_new_conn_id() argument
5353 if (h->inject_word0 == 0) in script_80_gen_new_conn_id()
5356 h->inject_word0 = 0; in script_80_gen_new_conn_id()
5377 if (!qtest_fault_prepend_frame(h->qtf, frame_buf, l)) in script_80_gen_new_conn_id()
5390 static int script_80_inject_pkt(struct helper *h, QUIC_PKT_HDR *hdr, in script_80_inject_pkt() argument
5393 if (h->inject_word1 == 1) in script_80_inject_pkt()
5394 return script_80_send_stateless_reset(h, hdr, buf, len); in script_80_inject_pkt()
5395 else if (h->inject_word0 == 1) in script_80_inject_pkt()
5396 return script_80_gen_new_conn_id(h, hdr, buf, len); in script_80_inject_pkt()
5407 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
5408 OP_S_READ_EXPECT (a, "apple", 5)
5410 OP_S_WRITE (a, "apple", 5)
5413 OP_S_WRITE (a, "apple", 5)
5419 static int modify_idle_timeout(struct helper *h, struct helper_local *hl) in modify_idle_timeout() argument
5424 if (!TEST_false(SSL_set_feature_request_uint(h->c_conn, in modify_idle_timeout()
5430 if (!TEST_true(SSL_set_feature_request_uint(h->c_conn, in modify_idle_timeout()
5432 hl->check_op->arg2))) in modify_idle_timeout()
5435 if (!TEST_true(SSL_get_feature_request_uint(h->c_conn, in modify_idle_timeout()
5440 if (!TEST_uint64_t_eq(v, hl->check_op->arg2)) in modify_idle_timeout()
5446 static int check_idle_timeout(struct helper *h, struct helper_local *hl) in check_idle_timeout() argument
5450 if (!TEST_true(SSL_get_value_uint(h->c_conn, hl->check_op->arg1, in check_idle_timeout()
5455 if (!TEST_uint64_t_eq(v, hl->check_op->arg2)) in check_idle_timeout()
5492 static int cannot_change_idle_timeout(struct helper *h, struct helper_local *hl) in cannot_change_idle_timeout() argument
5496 if (!TEST_true(SSL_get_feature_request_uint(h->c_conn, in cannot_change_idle_timeout()
5504 if (!TEST_false(SSL_set_feature_request_uint(h->c_conn, in cannot_change_idle_timeout()
5528 static int check_avail_streams(struct helper *h, struct helper_local *hl) in check_avail_streams() argument
5532 switch (hl->check_op->arg1) { in check_avail_streams()
5534 if (!TEST_true(SSL_get_quic_stream_bidi_local_avail(h->c_conn, &v))) in check_avail_streams()
5538 if (!TEST_true(SSL_get_quic_stream_bidi_remote_avail(h->c_conn, &v))) in check_avail_streams()
5542 if (!TEST_true(SSL_get_quic_stream_uni_local_avail(h->c_conn, &v))) in check_avail_streams()
5546 if (!TEST_true(SSL_get_quic_stream_uni_remote_avail(h->c_conn, &v))) in check_avail_streams()
5553 if (!TEST_uint64_t_eq(v, hl->check_op->arg2)) in check_avail_streams()
5559 static int set_event_handling_mode_conn(struct helper *h, struct helper_local *hl);
5560 static int reenable_test_event_handling(struct helper *h, struct helper_local *hl);
5562 static int check_write_buf_stat(struct helper *h, struct helper_local *hl) in check_write_buf_stat() argument
5567 if (!TEST_ptr(c_a = helper_local_get_c_stream(hl, "a"))) in check_write_buf_stat()
5578 if (!TEST_uint64_t_eq(used, hl->check_op->arg1)) in check_write_buf_stat()
5595 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
5634 OP_C_WRITE (a, "apple", 5)
5639 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
5640 OP_S_READ_EXPECT (a, "apple", 5)
5641 OP_S_WRITE (a, "orange", 6)
5642 OP_C_READ_EXPECT (a, "orange", 6)
5647 /* 85. Test SSL_poll (lite, non-blocking) */
5648 ossl_unused static int script_85_poll(struct helper *h, struct helper_local *hl) in script_85_poll() argument
5658 if (!TEST_ptr(c_a = helper_local_get_c_stream(hl, "a")) in script_85_poll()
5664 item->desc = SSL_as_poll_descriptor(c_a); in script_85_poll()
5665 item->events = UINT64_MAX; in script_85_poll()
5666 item->revents = UINT64_MAX; in script_85_poll()
5669 item->desc = SSL_as_poll_descriptor(c_b); in script_85_poll()
5670 item->events = UINT64_MAX; in script_85_poll()
5671 item->revents = UINT64_MAX; in script_85_poll()
5674 item->desc = SSL_as_poll_descriptor(c_c); in script_85_poll()
5675 item->events = UINT64_MAX; in script_85_poll()
5676 item->revents = UINT64_MAX; in script_85_poll()
5679 item->desc = SSL_as_poll_descriptor(c_d); in script_85_poll()
5680 item->events = UINT64_MAX; in script_85_poll()
5681 item->revents = UINT64_MAX; in script_85_poll()
5684 item->desc = SSL_as_poll_descriptor(h->c_conn); in script_85_poll()
5685 item->events = UINT64_MAX; in script_85_poll()
5686 item->revents = UINT64_MAX; in script_85_poll()
5694 mode = hl->check_op->arg2; in script_85_poll()
5738 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
5739 OP_C_WRITE (a, "flamingo", 8)
5750 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
5759 OP_S_READ_EXPECT (a, "flamingo", 8)
5760 OP_S_WRITE (a, "herringbone", 11)
5782 /* Check a is now readable. */
5789 static int set_event_handling_mode_conn(struct helper *h, struct helper_local *hl) in set_event_handling_mode_conn() argument
5791 hl->explicit_event_handling = 1; in set_event_handling_mode_conn()
5792 return SSL_set_event_handling_mode(h->c_conn, hl->check_op->arg2); in set_event_handling_mode_conn()
5795 static int reenable_test_event_handling(struct helper *h, struct helper_local *hl) in reenable_test_event_handling() argument
5797 hl->explicit_event_handling = 0; in reenable_test_event_handling()
5801 static ossl_unused int set_event_handling_mode_stream(struct helper *h, struct helper_local *hl) in set_event_handling_mode_stream() argument
5803 SSL *ssl = helper_local_get_c_stream(hl, "a"); in set_event_handling_mode_stream()
5808 return SSL_set_event_handling_mode(ssl, hl->check_op->arg2); in set_event_handling_mode_stream()
5824 * Create a new stream and write data. This won't get sent
5828 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
5829 OP_C_WRITE (a, "apple", 5)
5838 OP_C_WRITE (a, "orange", 6)
5839 OP_C_CONCLUDE (a)
5846 * Slow OSes will pass this anyway (fail-open).
5848 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
5851 OP_S_READ_FAIL (a, 1)
5857 OP_S_READ_EXPECT (a, "appleorange", 11)
5858 OP_S_EXPECT_FIN (a)
5863 OP_S_WRITE (a, "ok", 2)
5864 OP_C_READ_FAIL (a)
5868 OP_C_READ_EXPECT (a, "ok", 2)
5878 OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
5879 OP_C_WRITE (a, "apple", 5)
5880 OP_C_CONCLUDE (a)
5881 OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
5882 OP_S_READ_EXPECT (a, "apple", 5)
5883 OP_S_EXPECT_FIN (a)
5884 OP_S_WRITE (a, "orange", 6)
5885 OP_C_READ_EXPECT (a, "orange", 6)
5886 OP_S_CONCLUDE (a)
5887 OP_C_EXPECT_FIN (a)
5889 OP_C_STREAM_RESET_FAIL (a, 42)
6073 /* Client uses a zero-length CID so this is not allowed. */