]> git.ipfire.org Git - thirdparty/openssl.git/blob - test/quic_txp_test.c
Fix test cases using NEW_CONNECTION_ID frame
[thirdparty/openssl.git] / test / quic_txp_test.c
1 /*
2 * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9 #include "internal/packet.h"
10 #include "internal/quic_txp.h"
11 #include "internal/quic_statm.h"
12 #include "internal/quic_demux.h"
13 #include "internal/quic_record_rx.h"
14 #include "testutil.h"
15 #include "quic_record_test_util.h"
16
17 static const QUIC_CONN_ID scid_1 = {
18 1, { 0x5f }
19 };
20
21 static const QUIC_CONN_ID dcid_1 = {
22 8, { 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8 }
23 };
24
25 static const QUIC_CONN_ID cid_1 = {
26 8, { 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8 }
27 };
28
29 static const unsigned char reset_token_1[16] = {
30 0x99, 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11,
31 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x12,
32 };
33
34 static const unsigned char secret_1[32] = {
35 0x01
36 };
37
38 static OSSL_TIME fake_now(void *arg)
39 {
40 return ossl_time_now(); /* TODO */
41 }
42
43 struct helper {
44 OSSL_QUIC_TX_PACKETISER *txp;
45 OSSL_QUIC_TX_PACKETISER_ARGS args;
46 OSSL_QTX_ARGS qtx_args;
47 BIO *bio1, *bio2;
48 QUIC_TXFC conn_txfc;
49 QUIC_RXFC conn_rxfc, stream_rxfc;
50 QUIC_RXFC max_streams_bidi_rxfc, max_streams_uni_rxfc;
51 OSSL_STATM statm;
52 OSSL_CC_DATA *cc_data;
53 const OSSL_CC_METHOD *cc_method;
54 QUIC_STREAM_MAP qsm;
55 char have_statm, have_qsm;
56 QUIC_DEMUX *demux;
57 OSSL_QRX *qrx;
58 OSSL_QRX_ARGS qrx_args;
59 OSSL_QRX_PKT *qrx_pkt;
60 PACKET pkt;
61 uint64_t frame_type;
62 union {
63 uint64_t max_data;
64 OSSL_QUIC_FRAME_NEW_CONN_ID new_conn_id;
65 OSSL_QUIC_FRAME_ACK ack;
66 struct {
67 const unsigned char *token;
68 size_t token_len;
69 } new_token;
70 OSSL_QUIC_FRAME_CRYPTO crypto;
71 OSSL_QUIC_FRAME_STREAM stream;
72 OSSL_QUIC_FRAME_STOP_SENDING stop_sending;
73 OSSL_QUIC_FRAME_RESET_STREAM reset_stream;
74 OSSL_QUIC_FRAME_CONN_CLOSE conn_close;
75 } frame;
76 OSSL_QUIC_ACK_RANGE ack_ranges[16];
77 };
78
79 static void helper_cleanup(struct helper *h)
80 {
81 size_t i;
82 uint32_t pn_space;
83
84 ossl_qrx_pkt_release(h->qrx_pkt);
85 h->qrx_pkt = NULL;
86
87 for (pn_space = QUIC_PN_SPACE_INITIAL;
88 pn_space < QUIC_PN_SPACE_NUM;
89 ++pn_space)
90 ossl_ackm_on_pkt_space_discarded(h->args.ackm, pn_space);
91
92 ossl_quic_tx_packetiser_free(h->txp);
93 ossl_qtx_free(h->args.qtx);
94 ossl_quic_txpim_free(h->args.txpim);
95 ossl_quic_cfq_free(h->args.cfq);
96 if (h->cc_data != NULL)
97 h->cc_method->free(h->cc_data);
98 if (h->have_statm)
99 ossl_statm_destroy(&h->statm);
100 if (h->have_qsm)
101 ossl_quic_stream_map_cleanup(&h->qsm);
102 for (i = 0; i < QUIC_PN_SPACE_NUM; ++i)
103 ossl_quic_sstream_free(h->args.crypto[i]);
104 ossl_ackm_free(h->args.ackm);
105 ossl_qrx_free(h->qrx);
106 ossl_quic_demux_free(h->demux);
107 BIO_free(h->bio1);
108 BIO_free(h->bio2);
109 }
110
111 static int helper_init(struct helper *h)
112 {
113 int rc = 0;
114 size_t i;
115
116 memset(h, 0, sizeof(*h));
117
118 /* Initialisation */
119 if (!TEST_true(BIO_new_bio_dgram_pair(&h->bio1, 0, &h->bio2, 0)))
120 goto err;
121
122 h->qtx_args.bio = h->bio1;
123 h->qtx_args.mdpl = 1200;
124
125 if (!TEST_ptr(h->args.qtx = ossl_qtx_new(&h->qtx_args)))
126 goto err;
127
128 if (!TEST_ptr(h->args.txpim = ossl_quic_txpim_new()))
129 goto err;
130
131 if (!TEST_ptr(h->args.cfq = ossl_quic_cfq_new()))
132 goto err;
133
134 if (!TEST_true(ossl_quic_txfc_init(&h->conn_txfc, NULL)))
135 goto err;
136
137 if (!TEST_true(ossl_quic_rxfc_init(&h->conn_rxfc, NULL,
138 2 * 1024 * 1024,
139 10 * 1024 * 1024,
140 fake_now,
141 NULL)))
142 goto err;
143
144 if (!TEST_true(ossl_quic_rxfc_init(&h->stream_rxfc, &h->conn_rxfc,
145 1 * 1024 * 1024,
146 5 * 1024 * 1024,
147 fake_now,
148 NULL)))
149 goto err;
150
151 if (!TEST_true(ossl_quic_rxfc_init(&h->max_streams_bidi_rxfc, NULL,
152 100, 100,
153 fake_now,
154 NULL)))
155 goto err;
156
157 if (!TEST_true(ossl_quic_rxfc_init(&h->max_streams_uni_rxfc, NULL,
158 100, 100,
159 fake_now,
160 NULL)))
161
162 if (!TEST_true(ossl_statm_init(&h->statm)))
163 goto err;
164
165 h->have_statm = 1;
166
167 h->cc_method = &ossl_cc_dummy_method;
168 if (!TEST_ptr(h->cc_data = h->cc_method->new(fake_now, NULL)))
169 goto err;
170
171 if (!TEST_ptr(h->args.ackm = ossl_ackm_new(fake_now, NULL,
172 &h->statm,
173 h->cc_method,
174 h->cc_data)))
175 goto err;
176
177 if (!TEST_true(ossl_quic_stream_map_init(&h->qsm, NULL, NULL,
178 &h->max_streams_bidi_rxfc,
179 &h->max_streams_uni_rxfc)))
180 goto err;
181
182 h->have_qsm = 1;
183
184 for (i = 0; i < QUIC_PN_SPACE_NUM; ++i)
185 if (!TEST_ptr(h->args.crypto[i] = ossl_quic_sstream_new(4096)))
186 goto err;
187
188 h->args.cur_scid = scid_1;
189 h->args.cur_dcid = dcid_1;
190 h->args.qsm = &h->qsm;
191 h->args.conn_txfc = &h->conn_txfc;
192 h->args.conn_rxfc = &h->conn_rxfc;
193 h->args.max_streams_bidi_rxfc = &h->max_streams_bidi_rxfc;
194 h->args.max_streams_uni_rxfc = &h->max_streams_uni_rxfc;
195 h->args.cc_method = h->cc_method;
196 h->args.cc_data = h->cc_data;
197 h->args.now = fake_now;
198
199 if (!TEST_ptr(h->txp = ossl_quic_tx_packetiser_new(&h->args)))
200 goto err;
201
202 if (!TEST_ptr(h->demux = ossl_quic_demux_new(h->bio2, 8,
203 fake_now, NULL)))
204 goto err;
205
206 h->qrx_args.demux = h->demux;
207 h->qrx_args.short_conn_id_len = 8;
208 h->qrx_args.max_deferred = 32;
209
210 if (!TEST_ptr(h->qrx = ossl_qrx_new(&h->qrx_args)))
211 goto err;
212
213 if (!TEST_true(ossl_qrx_add_dst_conn_id(h->qrx, &dcid_1)))
214 goto err;
215
216 rc = 1;
217 err:
218 if (!rc)
219 helper_cleanup(h);
220
221 return rc;
222 }
223
224 #define OPK_END 0 /* End of Script */
225 #define OPK_TXP_GENERATE 1 /* Call generate, expect packet output */
226 #define OPK_TXP_GENERATE_NONE 2 /* Call generate, expect no packet output */
227 #define OPK_RX_PKT 3 /* Receive, expect packet */
228 #define OPK_RX_PKT_NONE 4 /* Receive, expect no packet */
229 #define OPK_EXPECT_DGRAM_LEN 5 /* Expect received datagram length in range */
230 #define OPK_EXPECT_FRAME 6 /* Expect next frame is of type */
231 #define OPK_EXPECT_INITIAL_TOKEN 7 /* Expect initial token buffer match */
232 #define OPK_EXPECT_HDR 8 /* Expect header structure match */
233 #define OPK_CHECK 9 /* Call check function */
234 #define OPK_NEXT_FRAME 10 /* Next frame */
235 #define OPK_EXPECT_NO_FRAME 11 /* Expect no further frames */
236 #define OPK_PROVIDE_SECRET 12 /* Provide secret to QTX and QRX */
237 #define OPK_DISCARD_EL 13 /* Discard QTX EL */
238 #define OPK_CRYPTO_SEND 14 /* Push data into crypto send stream */
239 #define OPK_STREAM_NEW 15 /* Create new application stream */
240 #define OPK_STREAM_SEND 16 /* Push data into application send stream */
241 #define OPK_STREAM_FIN 17 /* Mark stream as finished */
242 #define OPK_STOP_SENDING 18 /* Mark stream for STOP_SENDING */
243 #define OPK_RESET_STREAM 19 /* Mark stream for RESET_STREAM */
244 #define OPK_CONN_TXFC_BUMP 20 /* Bump connection TXFC CWM */
245 #define OPK_STREAM_TXFC_BUMP 21 /* Bump stream TXFC CWM */
246 #define OPK_HANDSHAKE_COMPLETE 22 /* Mark handshake as complete */
247
248 struct script_op {
249 uint32_t opcode;
250 uint64_t arg0, arg1;
251 const void *buf;
252 size_t buf_len;
253 int (*check_func)(struct helper *h);
254 };
255
256 #define OP_END \
257 { OPK_END }
258 #define OP_TXP_GENERATE(archetype) \
259 { OPK_TXP_GENERATE, (archetype) },
260 #define OP_TXP_GENERATE_NONE(archetype) \
261 { OPK_TXP_GENERATE_NONE, (archetype) },
262 #define OP_RX_PKT() \
263 { OPK_RX_PKT },
264 #define OP_RX_PKT_NONE() \
265 { OPK_RX_PKT_NONE },
266 #define OP_EXPECT_DGRAM_LEN(lo, hi) \
267 { OPK_EXPECT_DGRAM_LEN, (lo), (hi) },
268 #define OP_EXPECT_FRAME(frame_type) \
269 { OPK_EXPECT_FRAME, (frame_type) },
270 #define OP_EXPECT_INITIAL_TOKEN(buf) \
271 { OPK_EXPECT_INITIAL_TOKEN, sizeof(buf), 0, buf },
272 #define OP_EXPECT_HDR(hdr) \
273 { OPK_EXPECT_HDR, 0, 0, &(hdr) },
274 #define OP_CHECK(func) \
275 { OPK_CHECK, 0, 0, NULL, 0, (func) },
276 #define OP_NEXT_FRAME() \
277 { OPK_NEXT_FRAME },
278 #define OP_EXPECT_NO_FRAME() \
279 { OPK_EXPECT_NO_FRAME },
280 #define OP_PROVIDE_SECRET(el, suite, secret) \
281 { OPK_PROVIDE_SECRET, (el), (suite), (secret), sizeof(secret) },
282 #define OP_DISCARD_EL(el) \
283 { OPK_DISCARD_EL, (el) },
284 #define OP_CRYPTO_SEND(pn_space, buf) \
285 { OPK_CRYPTO_SEND, (pn_space), 0, (buf), sizeof(buf) },
286 #define OP_STREAM_NEW(id) \
287 { OPK_STREAM_NEW, (id) },
288 #define OP_STREAM_SEND(id, buf) \
289 { OPK_STREAM_SEND, (id), 0, (buf), sizeof(buf) },
290 #define OP_STREAM_FIN(id) \
291 { OPK_STREAM_FIN, (id) },
292 #define OP_STOP_SENDING(id, aec) \
293 { OPK_STOP_SENDING, (id), (aec) },
294 #define OP_RESET_STREAM(id, aec) \
295 { OPK_RESET_STREAM, (id), (aec) },
296 #define OP_CONN_TXFC_BUMP(cwm) \
297 { OPK_CONN_TXFC_BUMP, (cwm) },
298 #define OP_STREAM_TXFC_BUMP(id, cwm) \
299 { OPK_STREAM_TXFC_BUMP, (cwm), (id) },
300 #define OP_HANDSHAKE_COMPLETE() \
301 { OPK_HANDSHAKE_COMPLETE },
302
303 static int schedule_handshake_done(struct helper *h)
304 {
305 ossl_quic_tx_packetiser_schedule_handshake_done(h->txp);
306 return 1;
307 }
308
309 static int schedule_ack_eliciting_app(struct helper *h)
310 {
311 ossl_quic_tx_packetiser_schedule_ack_eliciting(h->txp, QUIC_PN_SPACE_APP);
312 return 1;
313 }
314
315 /* 1. 1-RTT, Single Handshake Done Frame */
316 static const struct script_op script_1[] = {
317 OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT, QRL_SUITE_AES128GCM, secret_1)
318 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
319 OP_CHECK(schedule_handshake_done)
320 OP_TXP_GENERATE(TX_PACKETISER_ARCHETYPE_NORMAL)
321 OP_RX_PKT()
322 /* Should not be long */
323 OP_EXPECT_DGRAM_LEN(21, 32)
324 OP_NEXT_FRAME()
325 OP_EXPECT_FRAME(OSSL_QUIC_FRAME_TYPE_HANDSHAKE_DONE)
326 OP_EXPECT_NO_FRAME()
327 OP_RX_PKT_NONE()
328 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
329 OP_END
330 };
331
332 /* 2. 1-RTT, Forced ACK-Eliciting Frame */
333 static const struct script_op script_2[] = {
334 OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT, QRL_SUITE_AES128GCM, secret_1)
335 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
336 OP_CHECK(schedule_ack_eliciting_app)
337 OP_TXP_GENERATE(TX_PACKETISER_ARCHETYPE_NORMAL)
338 OP_RX_PKT()
339 /* Should not be long */
340 OP_EXPECT_DGRAM_LEN(21, 32)
341 /* A PING frame should have been added */
342 OP_NEXT_FRAME()
343 OP_EXPECT_FRAME(OSSL_QUIC_FRAME_TYPE_PING)
344 OP_EXPECT_NO_FRAME()
345 OP_RX_PKT_NONE()
346 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
347 OP_END
348 };
349
350 /* 3. 1-RTT, MAX_DATA */
351 static int schedule_max_data(struct helper *h)
352 {
353 uint64_t cwm;
354
355 cwm = ossl_quic_rxfc_get_cwm(&h->stream_rxfc);
356
357 if (!TEST_true(ossl_quic_rxfc_on_rx_stream_frame(&h->stream_rxfc, cwm, 0))
358 || !TEST_true(ossl_quic_rxfc_on_retire(&h->stream_rxfc, cwm,
359 ossl_ticks2time(OSSL_TIME_MS))))
360 return 0;
361
362 return 1;
363 }
364
365 static const struct script_op script_3[] = {
366 OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT, QRL_SUITE_AES128GCM, secret_1)
367 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
368 OP_CHECK(schedule_max_data)
369 OP_TXP_GENERATE(TX_PACKETISER_ARCHETYPE_NORMAL)
370 OP_RX_PKT()
371 /* Should not be long */
372 OP_EXPECT_DGRAM_LEN(21, 40)
373 /* A PING frame should have been added */
374 OP_NEXT_FRAME()
375 OP_EXPECT_FRAME(OSSL_QUIC_FRAME_TYPE_MAX_DATA)
376 OP_EXPECT_NO_FRAME()
377 OP_RX_PKT_NONE()
378 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
379 OP_END
380 };
381
382 /* 4. 1-RTT, CFQ (NEW_CONN_ID) */
383 static void free_buf_mem(unsigned char *buf, size_t buf_len, void *arg)
384 {
385 BUF_MEM_free((BUF_MEM *)arg);
386 }
387
388 static int schedule_cfq_new_conn_id(struct helper *h)
389 {
390 int rc = 0;
391 QUIC_CFQ_ITEM *cfq_item;
392 WPACKET wpkt;
393 BUF_MEM *buf_mem = NULL;
394 size_t l = 0;
395 OSSL_QUIC_FRAME_NEW_CONN_ID ncid = {0};
396
397 ncid.seq_num = 2345;
398 ncid.retire_prior_to = 1234;
399 ncid.conn_id = cid_1;
400 memcpy(ncid.stateless_reset_token, reset_token_1, sizeof(reset_token_1));
401
402 if (!TEST_ptr(buf_mem = BUF_MEM_new()))
403 goto err;
404
405 if (!TEST_true(WPACKET_init(&wpkt, buf_mem)))
406 goto err;
407
408 if (!TEST_true(ossl_quic_wire_encode_frame_new_conn_id(&wpkt, &ncid))) {
409 WPACKET_cleanup(&wpkt);
410 goto err;
411 }
412
413 WPACKET_finish(&wpkt);
414
415 if (!TEST_true(WPACKET_get_total_written(&wpkt, &l)))
416 goto err;
417
418 if (!TEST_ptr(cfq_item = ossl_quic_cfq_add_frame(h->args.cfq, 1,
419 QUIC_PN_SPACE_APP,
420 OSSL_QUIC_FRAME_TYPE_NEW_CONN_ID,
421 (unsigned char *)buf_mem->data, l,
422 free_buf_mem,
423 buf_mem)))
424 goto err;
425
426 rc = 1;
427 err:
428 if (!rc)
429 BUF_MEM_free(buf_mem);
430 return rc;
431 }
432
433 static int check_cfq_new_conn_id(struct helper *h)
434 {
435 if (!TEST_uint64_t_eq(h->frame.new_conn_id.seq_num, 2345)
436 || !TEST_uint64_t_eq(h->frame.new_conn_id.retire_prior_to, 1234)
437 || !TEST_mem_eq(&h->frame.new_conn_id.conn_id, sizeof(cid_1),
438 &cid_1, sizeof(cid_1))
439 || !TEST_mem_eq(&h->frame.new_conn_id.stateless_reset_token,
440 sizeof(reset_token_1),
441 reset_token_1,
442 sizeof(reset_token_1)))
443 return 0;
444
445 return 1;
446 }
447
448 static const struct script_op script_4[] = {
449 OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT, QRL_SUITE_AES128GCM, secret_1)
450 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
451 OP_CHECK(schedule_cfq_new_conn_id)
452 OP_TXP_GENERATE(TX_PACKETISER_ARCHETYPE_NORMAL)
453 OP_RX_PKT()
454 OP_EXPECT_DGRAM_LEN(21, 128)
455 OP_NEXT_FRAME()
456 OP_EXPECT_FRAME(OSSL_QUIC_FRAME_TYPE_NEW_CONN_ID)
457 OP_CHECK(check_cfq_new_conn_id)
458 OP_EXPECT_NO_FRAME()
459 OP_RX_PKT_NONE()
460 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
461 OP_END
462 };
463
464 /* 5. 1-RTT, CFQ (NEW_TOKEN) */
465 static const unsigned char token_1[] = {
466 0x10, 0x11, 0x12, 0x13, 0x14, 0x15
467 };
468
469 static int schedule_cfq_new_token(struct helper *h)
470 {
471 int rc = 0;
472 QUIC_CFQ_ITEM *cfq_item;
473 WPACKET wpkt;
474 BUF_MEM *buf_mem = NULL;
475 size_t l = 0;
476
477 if (!TEST_ptr(buf_mem = BUF_MEM_new()))
478 goto err;
479
480 if (!TEST_true(WPACKET_init(&wpkt, buf_mem)))
481 goto err;
482
483 if (!TEST_true(ossl_quic_wire_encode_frame_new_token(&wpkt, token_1,
484 sizeof(token_1)))) {
485 WPACKET_cleanup(&wpkt);
486 goto err;
487 }
488
489 WPACKET_finish(&wpkt);
490
491 if (!TEST_true(WPACKET_get_total_written(&wpkt, &l)))
492 goto err;
493
494 if (!TEST_ptr(cfq_item = ossl_quic_cfq_add_frame(h->args.cfq, 1,
495 QUIC_PN_SPACE_APP,
496 OSSL_QUIC_FRAME_TYPE_NEW_TOKEN,
497 (unsigned char *)buf_mem->data, l,
498 free_buf_mem,
499 buf_mem)))
500 goto err;
501
502 rc = 1;
503 err:
504 if (!rc)
505 BUF_MEM_free(buf_mem);
506 return rc;
507 }
508
509 static int check_cfq_new_token(struct helper *h)
510 {
511 if (!TEST_mem_eq(h->frame.new_token.token,
512 h->frame.new_token.token_len,
513 token_1,
514 sizeof(token_1)))
515 return 0;
516
517 return 1;
518 }
519
520 static const struct script_op script_5[] = {
521 OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT, QRL_SUITE_AES128GCM, secret_1)
522 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
523 OP_CHECK(schedule_cfq_new_token)
524 OP_TXP_GENERATE(TX_PACKETISER_ARCHETYPE_NORMAL)
525 OP_RX_PKT()
526 OP_EXPECT_DGRAM_LEN(21, 512)
527 OP_NEXT_FRAME()
528 OP_EXPECT_FRAME(OSSL_QUIC_FRAME_TYPE_NEW_TOKEN)
529 OP_CHECK(check_cfq_new_token)
530 OP_EXPECT_NO_FRAME()
531 OP_RX_PKT_NONE()
532 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
533 OP_END
534 };
535
536 /* 6. 1-RTT, ACK */
537 static int schedule_ack(struct helper *h)
538 {
539 size_t i;
540 OSSL_ACKM_RX_PKT rx_pkt = {0};
541
542 /* Stimulate ACK emission by simulating a few received packets. */
543 for (i = 0; i < 5; ++i) {
544 rx_pkt.pkt_num = i;
545 rx_pkt.time = fake_now(NULL);
546 rx_pkt.pkt_space = QUIC_PN_SPACE_APP;
547 rx_pkt.is_ack_eliciting = 1;
548
549 if (!TEST_true(ossl_ackm_on_rx_packet(h->args.ackm, &rx_pkt)))
550 return 0;
551 }
552
553 return 1;
554 }
555
556 static const struct script_op script_6[] = {
557 OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT, QRL_SUITE_AES128GCM, secret_1)
558 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
559 OP_CHECK(schedule_ack)
560 OP_TXP_GENERATE(TX_PACKETISER_ARCHETYPE_NORMAL)
561 OP_RX_PKT()
562 OP_EXPECT_DGRAM_LEN(21, 512)
563 OP_NEXT_FRAME()
564 OP_EXPECT_FRAME(OSSL_QUIC_FRAME_TYPE_ACK_WITHOUT_ECN)
565 OP_EXPECT_NO_FRAME()
566 OP_RX_PKT_NONE()
567 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
568 OP_END
569 };
570
571 /* 7. 1-RTT, ACK, NEW_TOKEN */
572 static const struct script_op script_7[] = {
573 OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT, QRL_SUITE_AES128GCM, secret_1)
574 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
575 OP_CHECK(schedule_cfq_new_token)
576 OP_CHECK(schedule_ack)
577 OP_TXP_GENERATE(TX_PACKETISER_ARCHETYPE_NORMAL)
578 OP_RX_PKT()
579 OP_EXPECT_DGRAM_LEN(21, 512)
580 /* ACK must come before NEW_TOKEN */
581 OP_NEXT_FRAME()
582 OP_EXPECT_FRAME(OSSL_QUIC_FRAME_TYPE_ACK_WITHOUT_ECN)
583 OP_NEXT_FRAME()
584 OP_EXPECT_FRAME(OSSL_QUIC_FRAME_TYPE_NEW_TOKEN)
585 OP_EXPECT_NO_FRAME()
586 OP_RX_PKT_NONE()
587 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
588 OP_END
589 };
590
591 /* 8. 1-RTT, CRYPTO */
592 static const unsigned char crypto_1[] = {
593 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09
594 };
595
596 static const struct script_op script_8[] = {
597 OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT, QRL_SUITE_AES128GCM, secret_1)
598 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
599 OP_CRYPTO_SEND(QUIC_PN_SPACE_APP, crypto_1)
600 OP_TXP_GENERATE(TX_PACKETISER_ARCHETYPE_NORMAL)
601 OP_RX_PKT()
602 OP_EXPECT_DGRAM_LEN(21, 512)
603 OP_NEXT_FRAME()
604 OP_EXPECT_FRAME(OSSL_QUIC_FRAME_TYPE_CRYPTO)
605 OP_EXPECT_NO_FRAME()
606 OP_RX_PKT_NONE()
607 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
608 OP_END
609 };
610
611 /* 9. 1-RTT, STREAM */
612 static const unsigned char stream_9[] = {
613 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x7a, 0x7b
614 };
615
616 static int check_stream_9(struct helper *h)
617 {
618 if (!TEST_mem_eq(h->frame.stream.data, (size_t)h->frame.stream.len,
619 stream_9, sizeof(stream_9)))
620 return 0;
621
622 return 1;
623 }
624
625 static const struct script_op script_9[] = {
626 OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT, QRL_SUITE_AES128GCM, secret_1)
627 OP_HANDSHAKE_COMPLETE()
628 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
629 OP_STREAM_NEW(42)
630 OP_STREAM_SEND(42, stream_9)
631 /* Still no output because of TXFC */
632 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
633 /* Now grant a TXFC budget */
634 OP_CONN_TXFC_BUMP(1000)
635 OP_STREAM_TXFC_BUMP(42, 1000)
636 OP_TXP_GENERATE(TX_PACKETISER_ARCHETYPE_NORMAL)
637 OP_RX_PKT()
638 OP_EXPECT_DGRAM_LEN(21, 512)
639 OP_NEXT_FRAME()
640 OP_EXPECT_FRAME(OSSL_QUIC_FRAME_TYPE_STREAM)
641 OP_CHECK(check_stream_9)
642 OP_EXPECT_NO_FRAME()
643 OP_RX_PKT_NONE()
644 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
645 OP_END
646 };
647
648 /* 10. 1-RTT, STREAM, round robin */
649 /* The data below is randomly generated data. */
650 static const unsigned char stream_10a[1300] = {
651 0x40, 0x0d, 0xb6, 0x0d, 0x25, 0x5f, 0xdd, 0xb9, 0x05, 0x79, 0xa8, 0xe3,
652 0x79, 0x32, 0xb2, 0xa7, 0x30, 0x6d, 0x29, 0xf6, 0xba, 0x50, 0xbe, 0x83,
653 0xcb, 0x56, 0xec, 0xd6, 0xc7, 0x80, 0x84, 0xa2, 0x2f, 0xeb, 0xc4, 0x37,
654 0x40, 0x44, 0xef, 0xd8, 0x78, 0xbb, 0x92, 0x80, 0x22, 0x33, 0xc0, 0xce,
655 0x33, 0x5b, 0x75, 0x8c, 0xa5, 0x1a, 0x7a, 0x2a, 0xa9, 0x88, 0xaf, 0xf6,
656 0x3a, 0xe2, 0x5e, 0x60, 0x52, 0x6d, 0xef, 0x7f, 0x2a, 0x9a, 0xaa, 0x17,
657 0x0e, 0x12, 0x51, 0x82, 0x08, 0x2f, 0x0f, 0x5b, 0xff, 0xf5, 0x7c, 0x7c,
658 0x89, 0x04, 0xfb, 0xa7, 0x80, 0x4e, 0xda, 0x12, 0x89, 0x01, 0x4a, 0x81,
659 0x84, 0x78, 0x15, 0xa9, 0x12, 0x28, 0x69, 0x4a, 0x25, 0xe5, 0x8b, 0x69,
660 0xc2, 0x9f, 0xb6, 0x59, 0x49, 0xe3, 0x53, 0x90, 0xef, 0xc9, 0xb8, 0x40,
661 0xdd, 0x62, 0x5f, 0x99, 0x68, 0xd2, 0x0a, 0x77, 0xde, 0xf3, 0x11, 0x39,
662 0x7f, 0x93, 0x8b, 0x81, 0x69, 0x36, 0xa7, 0x76, 0xa4, 0x10, 0x56, 0x51,
663 0xe5, 0x45, 0x3a, 0x42, 0x49, 0x6c, 0xc6, 0xa0, 0xb4, 0x13, 0x46, 0x59,
664 0x0e, 0x48, 0x60, 0xc9, 0xff, 0x70, 0x10, 0x8d, 0x6a, 0xf9, 0x5b, 0x94,
665 0xc2, 0x9e, 0x49, 0x19, 0x56, 0xf2, 0xc1, 0xff, 0x08, 0x3f, 0x9e, 0x26,
666 0x8e, 0x99, 0x71, 0xc4, 0x25, 0xb1, 0x4e, 0xcc, 0x7e, 0x5f, 0xf0, 0x4e,
667 0x25, 0xa2, 0x2f, 0x3f, 0x68, 0xaa, 0xcf, 0xbd, 0x19, 0x19, 0x1c, 0x92,
668 0xa0, 0xb6, 0xb8, 0x32, 0xb1, 0x0b, 0x91, 0x05, 0xa9, 0xf8, 0x1a, 0x4b,
669 0x74, 0x09, 0xf9, 0x57, 0xd0, 0x1c, 0x38, 0x10, 0x05, 0x54, 0xd8, 0x4e,
670 0x12, 0x67, 0xcc, 0x43, 0xa3, 0x81, 0xa9, 0x3a, 0x12, 0x57, 0xe7, 0x4b,
671 0x0e, 0xe5, 0x51, 0xf9, 0x5f, 0xd4, 0x46, 0x73, 0xa2, 0x78, 0xb7, 0x00,
672 0x24, 0x69, 0x35, 0x10, 0x1e, 0xb8, 0xa7, 0x4a, 0x9b, 0xbc, 0xfc, 0x04,
673 0x6f, 0x1a, 0xb0, 0x4f, 0x12, 0xc9, 0x2b, 0x3b, 0x94, 0x85, 0x1b, 0x8e,
674 0xba, 0xac, 0xfd, 0x10, 0x22, 0x68, 0x90, 0x17, 0x13, 0x44, 0x18, 0x2f,
675 0x33, 0x37, 0x1a, 0x89, 0xc0, 0x2c, 0x14, 0x59, 0xb2, 0xaf, 0xc0, 0x6b,
676 0xdc, 0x28, 0xe1, 0xe9, 0xc1, 0x0c, 0xb4, 0x80, 0x90, 0xb9, 0x1f, 0x45,
677 0xb4, 0x63, 0x9a, 0x0e, 0xfa, 0x33, 0xf5, 0x75, 0x3a, 0x4f, 0xc3, 0x8c,
678 0x70, 0xdb, 0xd7, 0xbf, 0xf6, 0xb8, 0x7f, 0xcc, 0xe5, 0x85, 0xb6, 0xae,
679 0x25, 0x60, 0x18, 0x5b, 0xf1, 0x51, 0x1a, 0x85, 0xc1, 0x7f, 0xf3, 0xbe,
680 0xb6, 0x82, 0x38, 0xe3, 0xd2, 0xff, 0x8a, 0xc4, 0xdb, 0x08, 0xe6, 0x96,
681 0xd5, 0x3d, 0x1f, 0xc5, 0x12, 0x35, 0x45, 0x75, 0x5d, 0x17, 0x4e, 0xe1,
682 0xb8, 0xc9, 0xf0, 0x45, 0x95, 0x0b, 0x03, 0xcb, 0x85, 0x47, 0xaf, 0xc7,
683 0x88, 0xb6, 0xc1, 0x2c, 0xb8, 0x9b, 0xe6, 0x8b, 0x51, 0xd5, 0x2e, 0x71,
684 0xba, 0xc9, 0xa9, 0x37, 0x5e, 0x1c, 0x2c, 0x03, 0xf0, 0xc7, 0xc1, 0xd3,
685 0x72, 0xaa, 0x4d, 0x19, 0xd6, 0x51, 0x64, 0x12, 0xeb, 0x39, 0xeb, 0x45,
686 0xe9, 0xb4, 0x84, 0x08, 0xb6, 0x6c, 0xc7, 0x3e, 0xf0, 0x88, 0x64, 0xc2,
687 0x91, 0xb7, 0xa5, 0x86, 0x66, 0x83, 0xd5, 0xd3, 0x41, 0x24, 0xb2, 0x1c,
688 0x9a, 0x18, 0x10, 0x0e, 0xa5, 0xc9, 0xef, 0xcd, 0x06, 0xce, 0xa8, 0xaf,
689 0x22, 0x52, 0x25, 0x0b, 0x99, 0x3d, 0xe9, 0x26, 0xda, 0xa9, 0x47, 0xd1,
690 0x4b, 0xa6, 0x4c, 0xfc, 0x80, 0xaf, 0x6a, 0x59, 0x4b, 0x35, 0xa4, 0x93,
691 0x39, 0x5b, 0xfa, 0x91, 0x9d, 0xdf, 0x9d, 0x3c, 0xfb, 0x53, 0xca, 0x18,
692 0x19, 0xe4, 0xda, 0x95, 0x47, 0x5a, 0x37, 0x59, 0xd7, 0xd2, 0xe4, 0x75,
693 0x45, 0x0d, 0x03, 0x7f, 0xa0, 0xa9, 0xa0, 0x71, 0x06, 0xb1, 0x9d, 0x46,
694 0xbd, 0xcf, 0x4a, 0x8b, 0x73, 0xc1, 0x45, 0x5c, 0x00, 0x61, 0xfd, 0xd1,
695 0xa4, 0xa2, 0x3e, 0xaa, 0xbe, 0x72, 0xf1, 0x7a, 0x1a, 0x76, 0x88, 0x5c,
696 0x9e, 0x74, 0x6d, 0x2a, 0x34, 0xfc, 0xf7, 0x41, 0x28, 0xe8, 0xa3, 0x43,
697 0x4d, 0x43, 0x1d, 0x6c, 0x36, 0xb1, 0x45, 0x71, 0x5a, 0x3c, 0xd3, 0x28,
698 0x44, 0xe4, 0x9b, 0xbf, 0x54, 0x16, 0xc3, 0x99, 0x6c, 0x42, 0xd8, 0x20,
699 0xb6, 0x20, 0x5f, 0x6e, 0xbc, 0xba, 0x88, 0x5e, 0x2f, 0xa5, 0xd1, 0x82,
700 0x5c, 0x92, 0xd0, 0x79, 0xfd, 0xcc, 0x61, 0x49, 0xd0, 0x73, 0x92, 0xe6,
701 0x98, 0xe3, 0x80, 0x7a, 0xf9, 0x56, 0x63, 0x33, 0x19, 0xda, 0x54, 0x13,
702 0xf0, 0x21, 0xa8, 0x15, 0xf6, 0xb7, 0x43, 0x7c, 0x1c, 0x1e, 0xb1, 0x89,
703 0x8d, 0xce, 0x20, 0x54, 0x81, 0x80, 0xb5, 0x8f, 0x9b, 0xb1, 0x09, 0x92,
704 0xdb, 0x25, 0x6f, 0x30, 0x29, 0x08, 0x1a, 0x05, 0x08, 0xf4, 0x83, 0x8b,
705 0x1e, 0x2d, 0xfd, 0xe4, 0xb2, 0x76, 0xc8, 0x4d, 0xf3, 0xa6, 0x49, 0x5f,
706 0x2c, 0x99, 0x78, 0xbd, 0x07, 0xef, 0xc8, 0xd9, 0xb5, 0x70, 0x3b, 0x0a,
707 0xcb, 0xbd, 0xa0, 0xea, 0x15, 0xfb, 0xd1, 0x6e, 0x61, 0x83, 0xcb, 0x90,
708 0xd0, 0xa3, 0x81, 0x28, 0xdc, 0xd5, 0x84, 0xae, 0x55, 0x28, 0x13, 0x9e,
709 0xc6, 0xd8, 0xf4, 0x67, 0xd6, 0x0d, 0xd4, 0x69, 0xac, 0xf6, 0x35, 0x95,
710 0x99, 0x44, 0x26, 0x72, 0x36, 0x55, 0xf9, 0x42, 0xa6, 0x1b, 0x00, 0x93,
711 0x00, 0x19, 0x2f, 0x70, 0xd3, 0x16, 0x66, 0x4e, 0x80, 0xbb, 0xb6, 0x84,
712 0xa1, 0x2c, 0x09, 0xfb, 0x41, 0xdf, 0x63, 0xde, 0x62, 0x3e, 0xd0, 0xa8,
713 0xd8, 0x0c, 0x03, 0x06, 0xa9, 0x82, 0x17, 0x9c, 0xd2, 0xa9, 0xd5, 0x6f,
714 0xcc, 0xc0, 0xf2, 0x5d, 0xb1, 0xba, 0xf8, 0x2e, 0x37, 0x8b, 0xe6, 0x5d,
715 0x9f, 0x1b, 0xfb, 0x53, 0x0a, 0x96, 0xbe, 0x69, 0x31, 0x19, 0x8f, 0x44,
716 0x1b, 0xc2, 0x42, 0x7e, 0x65, 0x12, 0x1d, 0x52, 0x1e, 0xe2, 0xc0, 0x86,
717 0x70, 0x88, 0xe5, 0xf6, 0x87, 0x5d, 0x03, 0x4b, 0x12, 0x3c, 0x2d, 0xaf,
718 0x09, 0xf5, 0x4f, 0x82, 0x2e, 0x2e, 0xbe, 0x07, 0xe8, 0x8d, 0x57, 0x6e,
719 0xc0, 0xeb, 0xf9, 0x37, 0xac, 0x89, 0x01, 0xb7, 0xc6, 0x52, 0x1c, 0x86,
720 0xe5, 0xbc, 0x1f, 0xbd, 0xde, 0xa2, 0x42, 0xb6, 0x73, 0x85, 0x6f, 0x06,
721 0x36, 0x56, 0x40, 0x2b, 0xea, 0x16, 0x8c, 0xf4, 0x7b, 0x65, 0x6a, 0xca,
722 0x3c, 0x56, 0x68, 0x01, 0xe3, 0x9c, 0xbb, 0xb9, 0x45, 0x54, 0xcd, 0x13,
723 0x74, 0xad, 0x80, 0x40, 0xbc, 0xd0, 0x74, 0xb4, 0x31, 0xe4, 0xca, 0xd5,
724 0xf8, 0x4f, 0x08, 0x5b, 0xc4, 0x15, 0x1a, 0x51, 0x3b, 0xc6, 0x40, 0xc8,
725 0xea, 0x76, 0x30, 0x95, 0xb7, 0x76, 0xa4, 0xda, 0x20, 0xdb, 0x75, 0x1c,
726 0xf4, 0x87, 0x24, 0x29, 0x54, 0xc6, 0x59, 0x0c, 0xf0, 0xed, 0xf5, 0x3d,
727 0xce, 0x95, 0x23, 0x30, 0x49, 0x91, 0xa7, 0x7b, 0x22, 0xb5, 0xd7, 0x71,
728 0xb0, 0x60, 0xe1, 0xf0, 0x84, 0x74, 0x0e, 0x2f, 0xa8, 0x79, 0x35, 0xb9,
729 0x03, 0xb5, 0x2c, 0xdc, 0x60, 0x48, 0x12, 0xd9, 0x14, 0x5a, 0x58, 0x5d,
730 0x95, 0xc6, 0x47, 0xfd, 0xaf, 0x09, 0xc2, 0x67, 0xa5, 0x09, 0xae, 0xff,
731 0x4b, 0xd5, 0x6c, 0x2f, 0x1d, 0x33, 0x31, 0xcb, 0xdb, 0xcf, 0xf5, 0xf6,
732 0xbc, 0x90, 0xb2, 0x15, 0xd4, 0x34, 0xeb, 0xde, 0x0e, 0x8f, 0x3d, 0xea,
733 0xa4, 0x9b, 0x29, 0x8a, 0xf9, 0x4a, 0xac, 0x38, 0x1e, 0x46, 0xb2, 0x2d,
734 0xa2, 0x61, 0xc5, 0x99, 0x5e, 0x85, 0x36, 0x85, 0xb0, 0xb1, 0x6b, 0xc4,
735 0x06, 0x68, 0xc7, 0x9b, 0x54, 0xb9, 0xc8, 0x9d, 0xf3, 0x1a, 0xe0, 0x67,
736 0x0e, 0x4d, 0x5c, 0x13, 0x54, 0xa4, 0x62, 0x62, 0x6f, 0xae, 0x0e, 0x86,
737 0xa2, 0xe0, 0x31, 0xc7, 0x72, 0xa1, 0xbb, 0x87, 0x3e, 0x61, 0x96, 0xb7,
738 0x53, 0xf9, 0x34, 0xcb, 0xfd, 0x6c, 0x67, 0x25, 0x73, 0x61, 0x75, 0x4f,
739 0xab, 0x37, 0x08, 0xef, 0x35, 0x5a, 0x03, 0xe5, 0x08, 0x43, 0xec, 0xdc,
740 0xb5, 0x2c, 0x1f, 0xe6, 0xeb, 0xc6, 0x06, 0x0b, 0xed, 0xad, 0x74, 0xf4,
741 0x55, 0xef, 0xe0, 0x2e, 0x83, 0x00, 0xdb, 0x32, 0xde, 0xe9, 0xe4, 0x2f,
742 0xf5, 0x20, 0x6d, 0x72, 0x47, 0xf4, 0x68, 0xa6, 0x7f, 0x3e, 0x6a, 0x5a,
743 0x21, 0x76, 0x31, 0x97, 0xa0, 0xc6, 0x7d, 0x03, 0xf7, 0x27, 0x45, 0x5a,
744 0x75, 0x03, 0xc1, 0x5c, 0x94, 0x2b, 0x37, 0x9f, 0x46, 0x8f, 0xc3, 0xa7,
745 0x50, 0xe4, 0xe7, 0x23, 0xf7, 0x20, 0xa2, 0x8e, 0x4b, 0xfd, 0x7a, 0xa7,
746 0x8a, 0x54, 0x7b, 0x32, 0xef, 0x0e, 0x82, 0xb9, 0xf9, 0x14, 0x62, 0x68,
747 0x32, 0x9e, 0x55, 0xc0, 0xd8, 0xc7, 0x41, 0x9c, 0x67, 0x95, 0xbf, 0xc3,
748 0x86, 0x74, 0x70, 0x64, 0x44, 0x23, 0x77, 0x79, 0x82, 0x23, 0x1c, 0xf4,
749 0xa1, 0x05, 0xd3, 0x98, 0x89, 0xde, 0x7d, 0xb3, 0x5b, 0xef, 0x38, 0xd2,
750 0x07, 0xbc, 0x5a, 0x69, 0xa3, 0xe4, 0x37, 0x9b, 0x53, 0xff, 0x04, 0x6b,
751 0xd9, 0xd8, 0x32, 0x89, 0xf7, 0x82, 0x77, 0xcf, 0xe6, 0xff, 0xf4, 0x15,
752 0x54, 0x91, 0x65, 0x96, 0x49, 0xd7, 0x0a, 0xa4, 0xf3, 0x55, 0x2b, 0xc1,
753 0x48, 0xc1, 0x7e, 0x56, 0x69, 0x27, 0xf4, 0xd1, 0x47, 0x1f, 0xde, 0x86,
754 0x15, 0x67, 0x04, 0x9d, 0x41, 0x1f, 0xe8, 0xe1, 0x23, 0xe4, 0x56, 0xb9,
755 0xdb, 0x4e, 0xe4, 0x84, 0x6c, 0x63, 0x39, 0xad, 0x44, 0x6d, 0x4e, 0x28,
756 0xcd, 0xf6, 0xac, 0xec, 0xc2, 0xad, 0xcd, 0xc3, 0xed, 0x03, 0x63, 0x5d,
757 0xef, 0x1d, 0x40, 0x8d, 0x9a, 0x02, 0x67, 0x4b, 0x55, 0xb5, 0xfe, 0x75,
758 0xb6, 0x53, 0x34, 0x1d, 0x7b, 0x26, 0x23, 0xfe, 0xb9, 0x21, 0xd3, 0xe0,
759 0xa0, 0x1a, 0x85, 0xe5
760 };
761
762 static const unsigned char stream_10b[1300] = {
763 0x18, 0x00, 0xd7, 0xfb, 0x12, 0xda, 0xdb, 0x68, 0xeb, 0x38, 0x4d, 0xf6,
764 0xb2, 0x45, 0x74, 0x4c, 0xcc, 0xe7, 0xa7, 0xc1, 0x26, 0x84, 0x3d, 0xdf,
765 0x7d, 0xc5, 0xe9, 0xd4, 0x31, 0xa2, 0x51, 0x38, 0x95, 0xe2, 0x68, 0x11,
766 0x9d, 0xd1, 0x52, 0xb5, 0xef, 0x76, 0xe0, 0x3d, 0x11, 0x50, 0xd7, 0xb2,
767 0xc1, 0x7d, 0x12, 0xaf, 0x02, 0x52, 0x97, 0x03, 0xf3, 0x2e, 0x54, 0xdf,
768 0xa0, 0x40, 0x76, 0x52, 0x82, 0x23, 0x3c, 0xbd, 0x20, 0x6d, 0x0a, 0x6f,
769 0x81, 0xfc, 0x41, 0x9d, 0x2e, 0xa7, 0x2c, 0x78, 0x9c, 0xd8, 0x56, 0xb0,
770 0x31, 0x35, 0xc8, 0x53, 0xef, 0xf9, 0x43, 0x17, 0xc0, 0x8c, 0x2c, 0x8f,
771 0x4a, 0x68, 0xe8, 0x9f, 0xbd, 0x3f, 0xf2, 0x18, 0xb8, 0xe6, 0x55, 0xea,
772 0x2a, 0x37, 0x3e, 0xac, 0xb0, 0x75, 0xd4, 0x75, 0x12, 0x82, 0xec, 0x21,
773 0xb9, 0xce, 0xe5, 0xc1, 0x62, 0x49, 0xd5, 0xf1, 0xca, 0xd4, 0x32, 0x76,
774 0x34, 0x5f, 0x3e, 0xc9, 0xb3, 0x54, 0xe4, 0xd0, 0xa9, 0x7d, 0x0c, 0x64,
775 0x48, 0x0a, 0x74, 0x38, 0x03, 0xd0, 0x20, 0xac, 0xe3, 0x58, 0x3d, 0x4b,
776 0xa7, 0x46, 0xac, 0x57, 0x63, 0x12, 0x17, 0xcb, 0x96, 0xed, 0xc9, 0x39,
777 0x64, 0xde, 0xff, 0xc6, 0xb2, 0x40, 0x2c, 0xf9, 0x1d, 0xa6, 0x94, 0x2a,
778 0x16, 0x4d, 0x7f, 0x22, 0x91, 0x8b, 0xfe, 0x83, 0x77, 0x02, 0x68, 0x62,
779 0x27, 0x77, 0x2e, 0xe9, 0xce, 0xbc, 0x20, 0xe8, 0xfb, 0xf8, 0x4e, 0x17,
780 0x07, 0xe1, 0xaa, 0x29, 0xb7, 0x50, 0xcf, 0xb0, 0x6a, 0xcf, 0x01, 0xec,
781 0xbf, 0xff, 0xb5, 0x9f, 0x00, 0x64, 0x80, 0xbb, 0xa6, 0xe4, 0xa2, 0x1e,
782 0xe4, 0xf8, 0xa3, 0x0d, 0xc7, 0x65, 0x45, 0xb7, 0x01, 0x33, 0x80, 0x37,
783 0x11, 0x16, 0x34, 0xc1, 0x06, 0xc5, 0xd3, 0xc4, 0x70, 0x62, 0x75, 0xd8,
784 0xa3, 0xba, 0x84, 0x9f, 0x81, 0x9f, 0xda, 0x01, 0x83, 0x42, 0x84, 0x05,
785 0x69, 0x68, 0xb0, 0x74, 0x73, 0x0f, 0x68, 0x39, 0xd3, 0x11, 0xc5, 0x55,
786 0x3e, 0xf2, 0xb7, 0xf4, 0xa6, 0xed, 0x0b, 0x50, 0xbe, 0x44, 0xf8, 0x67,
787 0x48, 0x46, 0x5e, 0x71, 0x07, 0xcf, 0xca, 0x8a, 0xbc, 0xa4, 0x3c, 0xd2,
788 0x4a, 0x80, 0x2e, 0x4f, 0xc5, 0x3b, 0x61, 0xc1, 0x7e, 0x93, 0x9e, 0xe0,
789 0x05, 0xfb, 0x10, 0xe8, 0x53, 0xff, 0x16, 0x5e, 0x18, 0xe0, 0x9f, 0x39,
790 0xbf, 0xaa, 0x80, 0x6d, 0xb7, 0x9f, 0x51, 0x91, 0xa0, 0xf6, 0xce, 0xad,
791 0xed, 0x56, 0x15, 0xb9, 0x12, 0x57, 0x60, 0xa6, 0xae, 0x54, 0x6e, 0x36,
792 0xf3, 0xe0, 0x05, 0xd8, 0x3e, 0x6d, 0x08, 0x36, 0xc9, 0x79, 0x64, 0x51,
793 0x63, 0x92, 0xa8, 0xa1, 0xbf, 0x55, 0x26, 0x80, 0x75, 0x44, 0x33, 0x33,
794 0xfb, 0xb7, 0xec, 0xf9, 0xc6, 0x01, 0xf9, 0xd5, 0x93, 0xfc, 0xb7, 0x43,
795 0xa2, 0x38, 0x0d, 0x17, 0x75, 0x67, 0xec, 0xc9, 0x98, 0xd6, 0x25, 0xe6,
796 0xb9, 0xed, 0x61, 0xa4, 0xee, 0x2c, 0xda, 0x27, 0xbd, 0xff, 0x86, 0x1e,
797 0x45, 0x64, 0xfe, 0xcf, 0x0c, 0x9b, 0x7b, 0x75, 0x5f, 0xf1, 0xe0, 0xba,
798 0x77, 0x8c, 0x03, 0x8f, 0xb4, 0x3a, 0xb6, 0x9c, 0xda, 0x9a, 0x83, 0xcb,
799 0xe9, 0xcb, 0x3f, 0xf4, 0x10, 0x99, 0x5b, 0xe1, 0x19, 0x8f, 0x6b, 0x95,
800 0x50, 0xe6, 0x78, 0xc9, 0x35, 0xb6, 0x87, 0xd8, 0x9e, 0x17, 0x30, 0x96,
801 0x70, 0xa3, 0x04, 0x69, 0x1c, 0xa2, 0x6c, 0xd4, 0x88, 0x48, 0x44, 0x14,
802 0x94, 0xd4, 0xc9, 0x4d, 0xe3, 0x82, 0x7e, 0x62, 0xf0, 0x0a, 0x18, 0x4d,
803 0xd0, 0xd6, 0x63, 0xa3, 0xdf, 0xea, 0x28, 0xf4, 0x00, 0x75, 0x70, 0x78,
804 0x08, 0x70, 0x3f, 0xff, 0x84, 0x86, 0x72, 0xea, 0x4f, 0x15, 0x8c, 0x17,
805 0x60, 0x5f, 0xa1, 0x50, 0xa0, 0xfc, 0x6f, 0x8a, 0x46, 0xfc, 0x01, 0x8d,
806 0x7c, 0xdc, 0x69, 0x6a, 0xd3, 0x74, 0x69, 0x76, 0x77, 0xdd, 0xe4, 0x9c,
807 0x49, 0x1e, 0x6f, 0x7d, 0x31, 0x14, 0xd9, 0xe9, 0xe7, 0x17, 0x66, 0x82,
808 0x1b, 0xf1, 0x0f, 0xe2, 0xba, 0xd2, 0x28, 0xd1, 0x6f, 0x48, 0xc7, 0xac,
809 0x08, 0x4e, 0xee, 0x94, 0x66, 0x99, 0x34, 0x16, 0x5d, 0x95, 0xae, 0xe3,
810 0x59, 0x79, 0x7f, 0x8e, 0x9f, 0xe3, 0xdb, 0xff, 0xdc, 0x4d, 0xb0, 0xbf,
811 0xf9, 0xf3, 0x3e, 0xec, 0xcf, 0x50, 0x3d, 0x2d, 0xba, 0x94, 0x1f, 0x1a,
812 0xab, 0xa4, 0xf4, 0x67, 0x43, 0x7e, 0xb9, 0x65, 0x20, 0x13, 0xb1, 0xd9,
813 0x88, 0x4a, 0x24, 0x13, 0x84, 0x86, 0xae, 0x2b, 0x0c, 0x6c, 0x7e, 0xd4,
814 0x25, 0x6e, 0xaa, 0x8d, 0x0c, 0x54, 0x99, 0xde, 0x1d, 0xac, 0x8c, 0x5c,
815 0x73, 0x94, 0xd9, 0x75, 0xcb, 0x5a, 0x54, 0x3d, 0xeb, 0xff, 0xc1, 0x95,
816 0x53, 0xb5, 0x39, 0xf7, 0xe5, 0xf1, 0x77, 0xd1, 0x42, 0x82, 0x4b, 0xb0,
817 0xab, 0x19, 0x28, 0xff, 0x53, 0x28, 0x87, 0x46, 0xc6, 0x6f, 0x05, 0x06,
818 0xa6, 0x0c, 0x97, 0x93, 0x68, 0x38, 0xe1, 0x61, 0xed, 0xf8, 0x90, 0x13,
819 0xa3, 0x6f, 0xf2, 0x08, 0x37, 0xd7, 0x05, 0x25, 0x34, 0x43, 0x57, 0x72,
820 0xfd, 0x6c, 0xc2, 0x19, 0x26, 0xe7, 0x50, 0x30, 0xb8, 0x6d, 0x09, 0x71,
821 0x83, 0x75, 0xd4, 0x11, 0x25, 0x29, 0xc6, 0xee, 0xb2, 0x51, 0x1c, 0x1c,
822 0x9e, 0x2d, 0x09, 0xb9, 0x73, 0x2b, 0xbf, 0xda, 0xc8, 0x1e, 0x2b, 0xe5,
823 0x3f, 0x1e, 0x63, 0xe9, 0xc0, 0x6d, 0x04, 0x3a, 0x48, 0x61, 0xa8, 0xc6,
824 0x16, 0x8d, 0x69, 0xc0, 0x67, 0x0c, 0x3b, 0xc4, 0x05, 0x36, 0xa1, 0x30,
825 0x62, 0x92, 0x4d, 0x44, 0x31, 0x66, 0x46, 0xda, 0xef, 0x0f, 0x4e, 0xfb,
826 0x78, 0x6a, 0xa9, 0x5b, 0xf8, 0x56, 0x26, 0x74, 0x16, 0xab, 0x17, 0x93,
827 0x3c, 0x36, 0xbb, 0xa2, 0xbf, 0xad, 0xba, 0xb1, 0xfe, 0xc4, 0x9f, 0x75,
828 0x47, 0x1e, 0x99, 0x7e, 0x32, 0xe8, 0xd4, 0x6c, 0xa4, 0xf8, 0xd2, 0xe4,
829 0xb2, 0x51, 0xbb, 0xb2, 0xd7, 0xce, 0x94, 0xaf, 0x7f, 0xe6, 0x2c, 0x13,
830 0xae, 0xd2, 0x29, 0x30, 0x7b, 0xfd, 0x25, 0x61, 0xf9, 0xe8, 0x35, 0x2d,
831 0x1a, 0xc9, 0x81, 0xa5, 0xfe, 0xce, 0xf6, 0x17, 0xc5, 0xfb, 0x8c, 0x79,
832 0x67, 0xa8, 0x5f, 0x5c, 0x31, 0xbc, 0xfc, 0xf3, 0x6b, 0xd3, 0x0d, 0xe0,
833 0x62, 0xab, 0x86, 0xc3, 0x17, 0x5a, 0xba, 0x97, 0x86, 0x8f, 0x65, 0xd6,
834 0xbd, 0x0c, 0xa1, 0xfb, 0x7f, 0x7c, 0xdc, 0xcb, 0x94, 0x30, 0x0b, 0x04,
835 0x54, 0xc4, 0x31, 0xa1, 0xca, 0x1e, 0xc5, 0xf0, 0xb6, 0x08, 0xd7, 0x2e,
836 0xa1, 0x90, 0x41, 0xce, 0xd9, 0xef, 0x3a, 0x58, 0x01, 0x1a, 0x73, 0x18,
837 0xad, 0xdc, 0x20, 0x25, 0x95, 0x1a, 0xfe, 0x61, 0xf1, 0x58, 0x32, 0x8b,
838 0x43, 0x59, 0xd6, 0x21, 0xdb, 0xa9, 0x8e, 0x54, 0xe6, 0x21, 0xcf, 0xd3,
839 0x6b, 0x59, 0x29, 0x9b, 0x3e, 0x6c, 0x7f, 0xe2, 0x29, 0x72, 0x8c, 0xd1,
840 0x3e, 0x9a, 0x84, 0x98, 0xb0, 0xf3, 0x20, 0x30, 0x34, 0x71, 0xa7, 0x5b,
841 0xf0, 0x26, 0xe1, 0xf4, 0x76, 0x65, 0xc9, 0xd7, 0xe4, 0xb9, 0x25, 0x48,
842 0xc2, 0x7e, 0xa6, 0x0b, 0x0d, 0x05, 0x68, 0xa1, 0x96, 0x61, 0x0b, 0x4c,
843 0x2f, 0x1a, 0xe3, 0x56, 0x71, 0x89, 0x48, 0x66, 0xd8, 0xd0, 0x69, 0x37,
844 0x7a, 0xdf, 0xdb, 0xed, 0xad, 0x82, 0xaa, 0x40, 0x25, 0x47, 0x3e, 0x75,
845 0xa6, 0x0e, 0xf5, 0x2f, 0xa7, 0x4e, 0x97, 0xa2, 0x5f, 0x01, 0x99, 0x48,
846 0x3a, 0x63, 0x18, 0x20, 0x61, 0x72, 0xe4, 0xcf, 0x4b, 0x3b, 0x99, 0x36,
847 0xe1, 0xf3, 0xbf, 0xae, 0x2b, 0x6b, 0xa1, 0x94, 0xa0, 0x15, 0x94, 0xd6,
848 0xe0, 0xba, 0x71, 0xa2, 0x85, 0xa0, 0x8c, 0x5e, 0x58, 0xe2, 0xde, 0x6b,
849 0x08, 0x68, 0x90, 0x82, 0x71, 0x8d, 0xfd, 0x12, 0xa2, 0x49, 0x87, 0x70,
850 0xee, 0x2a, 0x08, 0xe2, 0x26, 0xaf, 0xeb, 0x85, 0x35, 0xd2, 0x0e, 0xfd,
851 0x2b, 0x6f, 0xc0, 0xfe, 0x41, 0xbb, 0xd7, 0x0a, 0xa3, 0x8d, 0x8b, 0xec,
852 0x44, 0x9f, 0x46, 0x59, 0x4d, 0xac, 0x04, 0x1e, 0xde, 0x10, 0x7b, 0x17,
853 0x0a, 0xb0, 0xcc, 0x26, 0x0c, 0xa9, 0x3c, 0x5f, 0xd8, 0xe6, 0x52, 0xd3,
854 0xfd, 0x0b, 0x66, 0x75, 0x06, 0x84, 0x23, 0x64, 0x2b, 0x80, 0x68, 0xf9,
855 0xcb, 0xcd, 0x04, 0x07, 0xf7, 0xe0, 0x07, 0xb4, 0xc6, 0xa0, 0x08, 0xd0,
856 0x76, 0x16, 0x77, 0xd8, 0x48, 0xf0, 0x45, 0x4e, 0xe2, 0xf2, 0x88, 0xcd,
857 0x0f, 0xbd, 0x7d, 0xb6, 0xbe, 0x4e, 0x9e, 0x5d, 0x6c, 0x47, 0x26, 0x34,
858 0x94, 0xfb, 0xc5, 0x4f, 0x5c, 0xb5, 0xb5, 0xfc, 0x99, 0x34, 0x71, 0xe5,
859 0xe1, 0x36, 0x0c, 0xd2, 0x95, 0xb8, 0x93, 0x3c, 0x5d, 0x2d, 0x71, 0x55,
860 0x0b, 0x96, 0x4e, 0x9f, 0x07, 0x9a, 0x38, 0x9a, 0xcc, 0x24, 0xb5, 0xac,
861 0x05, 0x8b, 0x1c, 0x61, 0xd4, 0xf2, 0xdf, 0x9e, 0x11, 0xe3, 0x7d, 0x64,
862 0x2f, 0xe5, 0x13, 0xd4, 0x0a, 0xe9, 0x32, 0x26, 0xa8, 0x93, 0x21, 0x59,
863 0xf3, 0x41, 0x48, 0x0a, 0xbd, 0x59, 0x8f, 0xf8, 0x72, 0xab, 0xd3, 0x65,
864 0x8e, 0xdc, 0xaa, 0x0c, 0xc0, 0x01, 0x36, 0xb7, 0xf5, 0x84, 0x27, 0x9a,
865 0x98, 0x89, 0x73, 0x3a, 0xeb, 0x55, 0x15, 0xc9, 0x3d, 0xe1, 0xf8, 0xea,
866 0xf6, 0x11, 0x28, 0xe0, 0x80, 0x93, 0xcc, 0xba, 0xe1, 0xf1, 0x81, 0xbc,
867 0xa4, 0x30, 0xbc, 0x98, 0xe8, 0x9e, 0x8d, 0x17, 0x7e, 0xb7, 0xb1, 0x27,
868 0x6f, 0xcf, 0x9c, 0x0d, 0x1d, 0x01, 0xea, 0x45, 0xc0, 0x90, 0xda, 0x53,
869 0xf6, 0xde, 0xdf, 0x12, 0xa1, 0x23, 0x3d, 0x92, 0x89, 0x77, 0xa7, 0x2a,
870 0xe7, 0x45, 0x24, 0xdd, 0xf2, 0x17, 0x10, 0xca, 0x6e, 0x14, 0xb2, 0x77,
871 0x08, 0xc4, 0x18, 0xcd
872 };
873
874 static uint64_t stream_10a_off, stream_10b_off;
875
876 static int check_stream_10a(struct helper *h)
877 {
878 /*
879 * Must have filled or almost filled the packet (using default MDPL of
880 * 1200).
881 */
882 if (!TEST_uint64_t_ge(h->frame.stream.len, 1150)
883 || !TEST_uint64_t_le(h->frame.stream.len, 1200))
884 return 0;
885
886 if (!TEST_mem_eq(h->frame.stream.data, (size_t)h->frame.stream.len,
887 stream_10a, (size_t)h->frame.stream.len))
888 return 0;
889
890 stream_10a_off = h->frame.stream.offset + h->frame.stream.len;
891 return 1;
892 }
893
894 static int check_stream_10b(struct helper *h)
895 {
896 if (!TEST_uint64_t_ge(h->frame.stream.len, 1150)
897 || !TEST_uint64_t_le(h->frame.stream.len, 1200))
898 return 0;
899
900 if (!TEST_mem_eq(h->frame.stream.data, (size_t)h->frame.stream.len,
901 stream_10b, (size_t)h->frame.stream.len))
902 return 0;
903
904 stream_10b_off = h->frame.stream.offset + h->frame.stream.len;
905 return 1;
906 }
907
908 static int check_stream_10c(struct helper *h)
909 {
910 if (!TEST_uint64_t_ge(h->frame.stream.len, 5)
911 || !TEST_uint64_t_le(h->frame.stream.len, 200))
912 return 0;
913
914 if (!TEST_mem_eq(h->frame.stream.data, (size_t)h->frame.stream.len,
915 stream_10a + stream_10a_off, (size_t)h->frame.stream.len))
916 return 0;
917
918 return 1;
919 }
920
921 static int check_stream_10d(struct helper *h)
922 {
923 if (!TEST_uint64_t_ge(h->frame.stream.len, 5)
924 || !TEST_uint64_t_le(h->frame.stream.len, 200))
925 return 0;
926
927 if (!TEST_mem_eq(h->frame.stream.data, (size_t)h->frame.stream.len,
928 stream_10b + stream_10b_off, (size_t)h->frame.stream.len))
929 return 0;
930
931 return 1;
932 }
933
934 static const struct script_op script_10[] = {
935 OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT, QRL_SUITE_AES128GCM, secret_1)
936 OP_HANDSHAKE_COMPLETE()
937 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
938 OP_STREAM_NEW(42)
939 OP_STREAM_NEW(43)
940 OP_CONN_TXFC_BUMP(10000)
941 OP_STREAM_TXFC_BUMP(42, 5000)
942 OP_STREAM_TXFC_BUMP(43, 5000)
943 OP_STREAM_SEND(42, stream_10a)
944 OP_STREAM_SEND(43, stream_10b)
945
946 /* First packet containing data from stream 42 */
947 OP_TXP_GENERATE(TX_PACKETISER_ARCHETYPE_NORMAL)
948 OP_RX_PKT()
949 OP_EXPECT_DGRAM_LEN(1100, 1200)
950 OP_NEXT_FRAME()
951 OP_EXPECT_FRAME(OSSL_QUIC_FRAME_TYPE_STREAM)
952 OP_CHECK(check_stream_10a)
953 OP_EXPECT_NO_FRAME()
954
955 /* Second packet containing data from stream 43 */
956 OP_TXP_GENERATE(TX_PACKETISER_ARCHETYPE_NORMAL)
957 OP_RX_PKT()
958 OP_EXPECT_DGRAM_LEN(1100, 1200)
959 OP_NEXT_FRAME()
960 OP_EXPECT_FRAME(OSSL_QUIC_FRAME_TYPE_STREAM)
961 OP_CHECK(check_stream_10b)
962 OP_EXPECT_NO_FRAME()
963
964 /* Third packet containing data from stream 42 */
965 OP_TXP_GENERATE(TX_PACKETISER_ARCHETYPE_NORMAL)
966 OP_RX_PKT()
967 OP_EXPECT_DGRAM_LEN(200, 500)
968 OP_NEXT_FRAME()
969 OP_EXPECT_FRAME(OSSL_QUIC_FRAME_TYPE_STREAM_OFF_LEN)
970 OP_CHECK(check_stream_10c)
971 OP_NEXT_FRAME()
972 OP_EXPECT_FRAME(OSSL_QUIC_FRAME_TYPE_STREAM_OFF)
973 OP_CHECK(check_stream_10d)
974 OP_EXPECT_NO_FRAME()
975
976 OP_RX_PKT_NONE()
977 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
978
979 OP_END
980 };
981
982 /* 11. Initial, CRYPTO */
983 static const struct script_op script_11[] = {
984 OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_INITIAL, QRL_SUITE_AES128GCM, secret_1)
985 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
986 OP_CRYPTO_SEND(QUIC_PN_SPACE_INITIAL, crypto_1)
987 OP_TXP_GENERATE(TX_PACKETISER_ARCHETYPE_NORMAL)
988 OP_RX_PKT()
989 OP_EXPECT_DGRAM_LEN(1200, 1200)
990 OP_NEXT_FRAME()
991 OP_EXPECT_FRAME(OSSL_QUIC_FRAME_TYPE_CRYPTO)
992 OP_EXPECT_NO_FRAME()
993 OP_RX_PKT_NONE()
994 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
995 OP_END
996 };
997
998 /* 12. 1-RTT, STOP_SENDING */
999 static int check_stream_12(struct helper *h)
1000 {
1001 if (!TEST_uint64_t_eq(h->frame.stop_sending.stream_id, 42)
1002 || !TEST_uint64_t_eq(h->frame.stop_sending.app_error_code, 4568))
1003 return 0;
1004
1005 return 1;
1006 }
1007
1008 static const struct script_op script_12[] = {
1009 OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT, QRL_SUITE_AES128GCM, secret_1)
1010 OP_HANDSHAKE_COMPLETE()
1011 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
1012 OP_STREAM_NEW(42)
1013 OP_STOP_SENDING(42, 4568)
1014 OP_TXP_GENERATE(TX_PACKETISER_ARCHETYPE_NORMAL)
1015 OP_RX_PKT()
1016 OP_EXPECT_DGRAM_LEN(21, 128)
1017 OP_NEXT_FRAME()
1018 OP_EXPECT_FRAME(OSSL_QUIC_FRAME_TYPE_STOP_SENDING)
1019 OP_CHECK(check_stream_12)
1020 OP_EXPECT_NO_FRAME()
1021 OP_RX_PKT_NONE()
1022 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
1023 OP_END
1024 };
1025
1026 /* 13. 1-RTT, RESET_STREAM */
1027 static const unsigned char stream_13[] = {
1028 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x7a, 0x7b
1029 };
1030
1031 static ossl_unused int check_stream_13(struct helper *h)
1032 {
1033 if (!TEST_uint64_t_eq(h->frame.reset_stream.stream_id, 42)
1034 || !TEST_uint64_t_eq(h->frame.reset_stream.app_error_code, 4568)
1035 || !TEST_uint64_t_eq(h->frame.reset_stream.final_size, 8))
1036 return 0;
1037
1038 return 1;
1039 }
1040
1041 static const struct script_op script_13[] = {
1042 OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT, QRL_SUITE_AES128GCM, secret_1)
1043 OP_HANDSHAKE_COMPLETE()
1044 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
1045 OP_STREAM_NEW(42)
1046 OP_CONN_TXFC_BUMP(8)
1047 OP_STREAM_TXFC_BUMP(42, 8)
1048 OP_STREAM_SEND(42, stream_13)
1049 OP_RESET_STREAM(42, 4568)
1050 OP_TXP_GENERATE(TX_PACKETISER_ARCHETYPE_NORMAL)
1051 OP_RX_PKT()
1052 OP_EXPECT_DGRAM_LEN(21, 128)
1053 OP_NEXT_FRAME()
1054 OP_EXPECT_FRAME(OSSL_QUIC_FRAME_TYPE_RESET_STREAM)
1055 OP_CHECK(check_stream_13)
1056 OP_NEXT_FRAME()
1057 OP_EXPECT_FRAME(OSSL_QUIC_FRAME_TYPE_STREAM)
1058 OP_EXPECT_NO_FRAME()
1059 OP_RX_PKT_NONE()
1060 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
1061 OP_END
1062 };
1063
1064 /* 14. 1-RTT, CONNECTION_CLOSE */
1065 static int gen_conn_close(struct helper *h)
1066 {
1067 OSSL_QUIC_FRAME_CONN_CLOSE f = {0};
1068
1069 f.error_code = 2345;
1070 f.frame_type = OSSL_QUIC_FRAME_TYPE_HANDSHAKE_DONE;
1071 f.reason = "Reason string";
1072 f.reason_len = strlen(f.reason);
1073
1074 if (!TEST_true(ossl_quic_tx_packetiser_schedule_conn_close(h->txp, &f)))
1075 return 0;
1076
1077 return 1;
1078 }
1079
1080 static int check_14(struct helper *h)
1081 {
1082 if (!TEST_int_eq(h->frame.conn_close.is_app, 0)
1083 || !TEST_uint64_t_eq(h->frame.conn_close.frame_type,
1084 OSSL_QUIC_FRAME_TYPE_HANDSHAKE_DONE)
1085 || !TEST_uint64_t_eq(h->frame.conn_close.error_code, 2345)
1086 || !TEST_mem_eq(h->frame.conn_close.reason, h->frame.conn_close.reason_len,
1087 "Reason string", 13))
1088 return 0;
1089
1090 return 1;
1091 }
1092
1093 static const struct script_op script_14[] = {
1094 OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT, QRL_SUITE_AES128GCM, secret_1)
1095 OP_HANDSHAKE_COMPLETE()
1096 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
1097 OP_CHECK(gen_conn_close)
1098 OP_TXP_GENERATE(TX_PACKETISER_ARCHETYPE_NORMAL)
1099 OP_RX_PKT()
1100 OP_EXPECT_DGRAM_LEN(21, 512)
1101 OP_NEXT_FRAME()
1102 OP_EXPECT_FRAME(OSSL_QUIC_FRAME_TYPE_CONN_CLOSE_TRANSPORT)
1103 OP_CHECK(check_14)
1104 OP_EXPECT_NO_FRAME()
1105 OP_RX_PKT_NONE()
1106 OP_END
1107 };
1108
1109 /* 15. INITIAL, Anti-Deadlock Probe Simulation */
1110 static int gen_probe_initial(struct helper *h)
1111 {
1112 OSSL_ACKM_PROBE_INFO *probe = ossl_ackm_get0_probe_request(h->args.ackm);
1113
1114 /*
1115 * Pretend the ACKM asked for an anti-deadlock Initial probe.
1116 * We test output of this in the ACKM unit tests.
1117 */
1118 ++probe->anti_deadlock_initial;
1119 return 1;
1120 }
1121
1122 static const struct script_op script_15[] = {
1123 OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_INITIAL, QRL_SUITE_AES128GCM, secret_1)
1124 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
1125 OP_CHECK(gen_probe_initial)
1126 OP_TXP_GENERATE(TX_PACKETISER_ARCHETYPE_NORMAL)
1127 OP_RX_PKT()
1128 OP_EXPECT_DGRAM_LEN(1200, 1200)
1129 OP_NEXT_FRAME()
1130 OP_EXPECT_FRAME(OSSL_QUIC_FRAME_TYPE_PING)
1131 OP_EXPECT_NO_FRAME()
1132 OP_RX_PKT_NONE()
1133 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
1134 OP_END
1135 };
1136
1137 /* 16. HANDSHAKE, Anti-Deadlock Probe Simulation */
1138 static int gen_probe_handshake(struct helper *h)
1139 {
1140 OSSL_ACKM_PROBE_INFO *probe = ossl_ackm_get0_probe_request(h->args.ackm);
1141
1142 /*
1143 * Pretend the ACKM asked for an anti-deadlock Handshake probe.
1144 * We test output of this in the ACKM unit tests.
1145 */
1146 ++probe->anti_deadlock_handshake;
1147 return 1;
1148 }
1149
1150 static const struct script_op script_16[] = {
1151 OP_DISCARD_EL(QUIC_ENC_LEVEL_INITIAL)
1152 OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_HANDSHAKE, QRL_SUITE_AES128GCM, secret_1)
1153 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
1154 OP_CHECK(gen_probe_handshake)
1155 OP_TXP_GENERATE(TX_PACKETISER_ARCHETYPE_NORMAL)
1156 OP_RX_PKT()
1157 OP_EXPECT_DGRAM_LEN(21, 512)
1158 OP_NEXT_FRAME()
1159 OP_EXPECT_FRAME(OSSL_QUIC_FRAME_TYPE_PING)
1160 OP_EXPECT_NO_FRAME()
1161 OP_RX_PKT_NONE()
1162 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
1163 OP_END
1164 };
1165
1166 /* 17. 1-RTT, Probe Simulation */
1167 static int gen_probe_1rtt(struct helper *h)
1168 {
1169 OSSL_ACKM_PROBE_INFO *probe = ossl_ackm_get0_probe_request(h->args.ackm);
1170
1171 /*
1172 * Pretend the ACKM asked for a 1-RTT PTO probe.
1173 * We test output of this in the ACKM unit tests.
1174 */
1175 ++probe->pto[QUIC_PN_SPACE_APP];
1176 return 1;
1177 }
1178
1179 static const struct script_op script_17[] = {
1180 OP_DISCARD_EL(QUIC_ENC_LEVEL_INITIAL)
1181 OP_DISCARD_EL(QUIC_ENC_LEVEL_HANDSHAKE)
1182 OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT, QRL_SUITE_AES128GCM, secret_1)
1183 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
1184 OP_CHECK(gen_probe_1rtt)
1185 OP_TXP_GENERATE(TX_PACKETISER_ARCHETYPE_NORMAL)
1186 OP_RX_PKT()
1187 OP_EXPECT_DGRAM_LEN(21, 512)
1188 OP_NEXT_FRAME()
1189 OP_EXPECT_FRAME(OSSL_QUIC_FRAME_TYPE_PING)
1190 OP_EXPECT_NO_FRAME()
1191 OP_RX_PKT_NONE()
1192 OP_TXP_GENERATE_NONE(TX_PACKETISER_ARCHETYPE_NORMAL)
1193 OP_END
1194 };
1195
1196 static const struct script_op *const scripts[] = {
1197 script_1,
1198 script_2,
1199 script_3,
1200 script_4,
1201 script_5,
1202 script_6,
1203 script_7,
1204 script_8,
1205 script_9,
1206 script_10,
1207 script_11,
1208 script_12,
1209 script_13,
1210 script_14,
1211 script_15,
1212 script_16,
1213 script_17
1214 };
1215
1216 static void skip_padding(struct helper *h)
1217 {
1218 uint64_t frame_type;
1219
1220 if (!ossl_quic_wire_peek_frame_header(&h->pkt, &frame_type))
1221 return; /* EOF */
1222
1223 if (frame_type == OSSL_QUIC_FRAME_TYPE_PADDING)
1224 ossl_quic_wire_decode_padding(&h->pkt);
1225 }
1226
1227 static int run_script(const struct script_op *script)
1228 {
1229 int testresult = 0, have_helper = 0, sent_ack_eliciting = 0;
1230 struct helper h;
1231 const struct script_op *op;
1232
1233 if (!helper_init(&h))
1234 goto err;
1235
1236 have_helper = 1;
1237 for (op = script; op->opcode != OPK_END; ++op) {
1238 switch (op->opcode) {
1239 case OPK_TXP_GENERATE:
1240 if (!TEST_int_eq(ossl_quic_tx_packetiser_generate(h.txp, (int)op->arg0,
1241 &sent_ack_eliciting),
1242 TX_PACKETISER_RES_SENT_PKT))
1243 goto err;
1244
1245 ossl_qtx_finish_dgram(h.args.qtx);
1246 ossl_qtx_flush_net(h.args.qtx);
1247 break;
1248 case OPK_TXP_GENERATE_NONE:
1249 if (!TEST_int_eq(ossl_quic_tx_packetiser_generate(h.txp, (int)op->arg0,
1250 &sent_ack_eliciting),
1251 TX_PACKETISER_RES_NO_PKT))
1252 goto err;
1253
1254 break;
1255 case OPK_RX_PKT:
1256 ossl_quic_demux_pump(h.demux);
1257 ossl_qrx_pkt_release(h.qrx_pkt);
1258 h.qrx_pkt = NULL;
1259 if (!TEST_true(ossl_qrx_read_pkt(h.qrx, &h.qrx_pkt)))
1260 goto err;
1261 if (!TEST_true(PACKET_buf_init(&h.pkt,
1262 h.qrx_pkt->hdr->data,
1263 h.qrx_pkt->hdr->len)))
1264 goto err;
1265 h.frame_type = UINT64_MAX;
1266 break;
1267 case OPK_RX_PKT_NONE:
1268 ossl_quic_demux_pump(h.demux);
1269 if (!TEST_false(ossl_qrx_read_pkt(h.qrx, &h.qrx_pkt)))
1270 goto err;
1271 h.frame_type = UINT64_MAX;
1272 break;
1273 case OPK_EXPECT_DGRAM_LEN:
1274 if (!TEST_size_t_ge(h.qrx_pkt->datagram_len, (size_t)op->arg0)
1275 || !TEST_size_t_le(h.qrx_pkt->datagram_len, (size_t)op->arg1))
1276 goto err;
1277 break;
1278 case OPK_EXPECT_FRAME:
1279 if (!TEST_uint64_t_eq(h.frame_type, op->arg0))
1280 goto err;
1281 break;
1282 case OPK_EXPECT_INITIAL_TOKEN:
1283 if (!TEST_mem_eq(h.qrx_pkt->hdr->token, h.qrx_pkt->hdr->token_len,
1284 op->buf, (size_t)op->arg0))
1285 goto err;
1286 break;
1287 case OPK_EXPECT_HDR:
1288 if (!TEST_true(cmp_pkt_hdr(h.qrx_pkt->hdr, op->buf,
1289 NULL, 0, 0)))
1290 goto err;
1291 break;
1292 case OPK_CHECK:
1293 if (!TEST_true(op->check_func(&h)))
1294 goto err;
1295 break;
1296 case OPK_NEXT_FRAME:
1297 skip_padding(&h);
1298 if (!ossl_quic_wire_peek_frame_header(&h.pkt, &h.frame_type)) {
1299 h.frame_type = UINT64_MAX;
1300 break;
1301 }
1302
1303 switch (h.frame_type) {
1304 case OSSL_QUIC_FRAME_TYPE_HANDSHAKE_DONE:
1305 if (!TEST_true(ossl_quic_wire_decode_frame_handshake_done(&h.pkt)))
1306 goto err;
1307 break;
1308 case OSSL_QUIC_FRAME_TYPE_PING:
1309 if (!TEST_true(ossl_quic_wire_decode_frame_ping(&h.pkt)))
1310 goto err;
1311 break;
1312 case OSSL_QUIC_FRAME_TYPE_MAX_DATA:
1313 if (!TEST_true(ossl_quic_wire_decode_frame_max_data(&h.pkt,
1314 &h.frame.max_data)))
1315 goto err;
1316 break;
1317 case OSSL_QUIC_FRAME_TYPE_NEW_CONN_ID:
1318 if (!TEST_true(ossl_quic_wire_decode_frame_new_conn_id(&h.pkt,
1319 &h.frame.new_conn_id)))
1320 goto err;
1321 break;
1322 case OSSL_QUIC_FRAME_TYPE_NEW_TOKEN:
1323 if (!TEST_true(ossl_quic_wire_decode_frame_new_token(&h.pkt,
1324 &h.frame.new_token.token,
1325 &h.frame.new_token.token_len)))
1326 goto err;
1327 break;
1328 case OSSL_QUIC_FRAME_TYPE_ACK_WITH_ECN:
1329 case OSSL_QUIC_FRAME_TYPE_ACK_WITHOUT_ECN:
1330 h.frame.ack.ack_ranges = h.ack_ranges;
1331 h.frame.ack.num_ack_ranges = OSSL_NELEM(h.ack_ranges);
1332 if (!TEST_true(ossl_quic_wire_decode_frame_ack(&h.pkt,
1333 h.args.ack_delay_exponent,
1334 &h.frame.ack,
1335 NULL)))
1336 goto err;
1337 break;
1338 case OSSL_QUIC_FRAME_TYPE_CRYPTO:
1339 if (!TEST_true(ossl_quic_wire_decode_frame_crypto(&h.pkt, &h.frame.crypto)))
1340 goto err;
1341 break;
1342
1343 case OSSL_QUIC_FRAME_TYPE_STREAM:
1344 case OSSL_QUIC_FRAME_TYPE_STREAM_FIN:
1345 case OSSL_QUIC_FRAME_TYPE_STREAM_LEN:
1346 case OSSL_QUIC_FRAME_TYPE_STREAM_LEN_FIN:
1347 case OSSL_QUIC_FRAME_TYPE_STREAM_OFF:
1348 case OSSL_QUIC_FRAME_TYPE_STREAM_OFF_FIN:
1349 case OSSL_QUIC_FRAME_TYPE_STREAM_OFF_LEN:
1350 case OSSL_QUIC_FRAME_TYPE_STREAM_OFF_LEN_FIN:
1351 if (!TEST_true(ossl_quic_wire_decode_frame_stream(&h.pkt, &h.frame.stream)))
1352 goto err;
1353 break;
1354
1355 case OSSL_QUIC_FRAME_TYPE_STOP_SENDING:
1356 if (!TEST_true(ossl_quic_wire_decode_frame_stop_sending(&h.pkt,
1357 &h.frame.stop_sending)))
1358 goto err;
1359 break;
1360
1361 case OSSL_QUIC_FRAME_TYPE_RESET_STREAM:
1362 if (!TEST_true(ossl_quic_wire_decode_frame_reset_stream(&h.pkt,
1363 &h.frame.reset_stream)))
1364 goto err;
1365 break;
1366
1367 case OSSL_QUIC_FRAME_TYPE_CONN_CLOSE_TRANSPORT:
1368 case OSSL_QUIC_FRAME_TYPE_CONN_CLOSE_APP:
1369 if (!TEST_true(ossl_quic_wire_decode_frame_conn_close(&h.pkt,
1370 &h.frame.conn_close)))
1371 goto err;
1372 break;
1373
1374 default:
1375 TEST_error("unknown frame type");
1376 goto err;
1377 }
1378 break;
1379 case OPK_EXPECT_NO_FRAME:
1380 skip_padding(&h);
1381 if (!TEST_size_t_eq(PACKET_remaining(&h.pkt), 0))
1382 goto err;
1383 break;
1384 case OPK_PROVIDE_SECRET:
1385 if (!TEST_true(ossl_qtx_provide_secret(h.args.qtx,
1386 (uint32_t)op->arg0,
1387 (uint32_t)op->arg1,
1388 NULL, op->buf, op->buf_len)))
1389 goto err;
1390 if (!TEST_true(ossl_qrx_provide_secret(h.qrx,
1391 (uint32_t)op->arg0,
1392 (uint32_t)op->arg1,
1393 NULL, op->buf, op->buf_len)))
1394 goto err;
1395 break;
1396 case OPK_DISCARD_EL:
1397 if (!TEST_true(ossl_quic_tx_packetiser_discard_enc_level(h.txp,
1398 (uint32_t)op->arg0)))
1399 goto err;
1400 /*
1401 * We do not discard on the QRX here, the object is to test the
1402 * TXP so if the TXP does erroneously send at a discarded EL we
1403 * want to know about it.
1404 */
1405 break;
1406 case OPK_CRYPTO_SEND:
1407 {
1408 size_t consumed = 0;
1409
1410 if (!TEST_true(ossl_quic_sstream_append(h.args.crypto[op->arg0],
1411 op->buf, op->buf_len,
1412 &consumed)))
1413 goto err;
1414
1415 if (!TEST_size_t_eq(consumed, op->buf_len))
1416 goto err;
1417 }
1418 break;
1419 case OPK_STREAM_NEW:
1420 {
1421 QUIC_STREAM *s;
1422
1423 if (!TEST_ptr(s = ossl_quic_stream_map_alloc(h.args.qsm, op->arg0,
1424 QUIC_STREAM_DIR_BIDI)))
1425 goto err;
1426
1427 if (!TEST_ptr(s->sstream = ossl_quic_sstream_new(512 * 1024))
1428 || !TEST_true(ossl_quic_txfc_init(&s->txfc, &h.conn_txfc))
1429 || !TEST_true(ossl_quic_rxfc_init(&s->rxfc, &h.conn_rxfc,
1430 1 * 1024 * 1024,
1431 16 * 1024 * 1024,
1432 fake_now, NULL))) {
1433 ossl_quic_sstream_free(s->sstream);
1434 ossl_quic_stream_map_release(h.args.qsm, s);
1435 goto err;
1436 }
1437 }
1438 break;
1439 case OPK_STREAM_SEND:
1440 {
1441 QUIC_STREAM *s;
1442 size_t consumed = 0;
1443
1444 if (!TEST_ptr(s = ossl_quic_stream_map_get_by_id(h.args.qsm,
1445 op->arg0)))
1446 goto err;
1447
1448 if (!TEST_true(ossl_quic_sstream_append(s->sstream, op->buf,
1449 op->buf_len, &consumed)))
1450 goto err;
1451
1452 if (!TEST_size_t_eq(consumed, op->buf_len))
1453 goto err;
1454
1455 ossl_quic_stream_map_update_state(h.args.qsm, s);
1456 }
1457 break;
1458 case OPK_STREAM_FIN:
1459 {
1460 QUIC_STREAM *s;
1461
1462 if (!TEST_ptr(s = ossl_quic_stream_map_get_by_id(h.args.qsm,
1463 op->arg0)))
1464 goto err;
1465
1466 ossl_quic_sstream_fin(s->sstream);
1467 }
1468 break;
1469 case OPK_STOP_SENDING:
1470 {
1471 QUIC_STREAM *s;
1472
1473 if (!TEST_ptr(s = ossl_quic_stream_map_get_by_id(h.args.qsm,
1474 op->arg0)))
1475 goto err;
1476
1477 if (!TEST_true(ossl_quic_stream_map_stop_sending_recv_part(h.args.qsm,
1478 s, op->arg1)))
1479 goto err;
1480
1481 ossl_quic_stream_map_update_state(h.args.qsm, s);
1482
1483 if (!TEST_true(s->active))
1484 goto err;
1485 }
1486 break;
1487 case OPK_RESET_STREAM:
1488 {
1489 QUIC_STREAM *s;
1490
1491 if (!TEST_ptr(s = ossl_quic_stream_map_get_by_id(h.args.qsm,
1492 op->arg0)))
1493 goto err;
1494
1495 if (!TEST_true(ossl_quic_stream_map_reset_stream_send_part(h.args.qsm,
1496 s, op->arg1)))
1497 goto err;
1498
1499 ossl_quic_stream_map_update_state(h.args.qsm, s);
1500
1501 if (!TEST_true(s->active))
1502 goto err;
1503 }
1504 break;
1505 case OPK_CONN_TXFC_BUMP:
1506 if (!TEST_true(ossl_quic_txfc_bump_cwm(h.args.conn_txfc, op->arg0)))
1507 goto err;
1508
1509 break;
1510 case OPK_STREAM_TXFC_BUMP:
1511 {
1512 QUIC_STREAM *s;
1513
1514 if (!TEST_ptr(s = ossl_quic_stream_map_get_by_id(h.args.qsm,
1515 op->arg1)))
1516 goto err;
1517
1518 if (!TEST_true(ossl_quic_txfc_bump_cwm(&s->txfc, op->arg0)))
1519 goto err;
1520
1521 ossl_quic_stream_map_update_state(h.args.qsm, s);
1522 }
1523 break;
1524 case OPK_HANDSHAKE_COMPLETE:
1525 ossl_quic_tx_packetiser_notify_handshake_complete(h.txp);
1526 break;
1527 default:
1528 TEST_error("bad opcode");
1529 goto err;
1530 }
1531 }
1532
1533 testresult = 1;
1534 err:
1535 if (have_helper)
1536 helper_cleanup(&h);
1537 return testresult;
1538 }
1539
1540 static int test_script(int idx)
1541 {
1542 return run_script(scripts[idx]);
1543 }
1544
1545 int setup_tests(void)
1546 {
1547 ADD_ALL_TESTS(test_script, OSSL_NELEM(scripts));
1548 return 1;
1549 }