]> git.ipfire.org Git - thirdparty/openssl.git/blame - test/quic_record_test.c
Fix various typos, repeated words, align some spelling to LDP.
[thirdparty/openssl.git] / test / quic_record_test.c
CommitLineData
ec279ac2
HL
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
19571483 10#include "internal/quic_record_rx.h"
ecc920b3 11#include "internal/quic_rx_depack.h"
19571483 12#include "internal/quic_record_tx.h"
ecc920b3
RL
13#include "internal/quic_ackm.h"
14#include "internal/quic_cc.h"
15#include "internal/quic_ssl.h"
ec279ac2
HL
16#include "testutil.h"
17
18static const QUIC_CONN_ID empty_conn_id = {0, {0}};
19
19571483
HL
20#define RX_TEST_OP_END 0 /* end of script */
21#define RX_TEST_OP_SET_SCID_LEN 1 /* change SCID length */
22#define RX_TEST_OP_SET_INIT_LARGEST_PN 2 /* set initial largest PN */
23#define RX_TEST_OP_ADD_RX_DCID 3 /* register an RX DCID */
24#define RX_TEST_OP_INJECT 4 /* inject a datagram into demux */
25#define RX_TEST_OP_PROVIDE_SECRET 5 /* provide RX secret */
26#define RX_TEST_OP_PROVIDE_SECRET_INITIAL 6 /* provide RX secret for initial */
27#define RX_TEST_OP_DISCARD_EL 7 /* discard an encryption level */
28#define RX_TEST_OP_CHECK_PKT 8 /* read packet, compare to expected */
29#define RX_TEST_OP_CHECK_NO_PKT 9 /* check no packet is available to read */
948c656c
HL
30#define RX_TEST_OP_CHECK_KEY_EPOCH 10 /* check key epoch value matches */
31#define RX_TEST_OP_KEY_UPDATE_TIMEOUT 11 /* complete key update process */
32#define RX_TEST_OP_SET_INIT_KEY_PHASE 12 /* initial Key Phase bit value */
19571483 33
ecc920b3
RL
34/* These are subtest ops for RX_TEST_OP_CHECK_PKT, to additionally check frames */
35#define RX_TEST_OP_CHECK_PKT_FRAMES_OK 1 /* check that frames are parsed ok */
36#define RX_TEST_OP_CHECK_PKT_FRAMES_INVALID 2 /* check that frames fail to parse ok */
37
19571483 38struct rx_test_op {
ec279ac2 39 unsigned char op;
ecc920b3 40 unsigned char subop;
ec279ac2
HL
41 const unsigned char *buf;
42 size_t buf_len;
43 const QUIC_PKT_HDR *hdr;
44 uint32_t enc_level, suite_id;
45 QUIC_PN largest_pn;
46 const QUIC_CONN_ID *dcid;
19571483 47 int (*new_qrx)(QUIC_DEMUX **demux, OSSL_QRX **qrx);
ecc920b3
RL
48
49 /* For frame checking */
19571483
HL
50};
51
52#define RX_OP_END \
53 { RX_TEST_OP_END }
54#define RX_OP_SET_SCID_LEN(scid_len) \
ecc920b3 55 { RX_TEST_OP_SET_SCID_LEN, 0, NULL, 0, NULL, (scid_len), 0, 0, NULL, NULL },
19571483 56#define RX_OP_SET_INIT_LARGEST_PN(largest_pn) \
ecc920b3 57 { RX_TEST_OP_SET_INIT_LARGEST_PN, 0, NULL, 0, NULL, 0, 0, (largest_pn), NULL, NULL },
19571483 58#define RX_OP_ADD_RX_DCID(dcid) \
ecc920b3 59 { RX_TEST_OP_ADD_RX_DCID, 0, NULL, 0, NULL, 0, 0, 0, &(dcid), NULL },
19571483 60#define RX_OP_INJECT(dgram) \
ecc920b3 61 { RX_TEST_OP_INJECT, 0, (dgram), sizeof(dgram), NULL, 0, 0, 0, NULL },
19571483 62#define RX_OP_PROVIDE_SECRET(el, suite, key) \
ec279ac2 63 { \
ecc920b3 64 RX_TEST_OP_PROVIDE_SECRET, 0, (key), sizeof(key), \
ec279ac2
HL
65 NULL, (el), (suite), 0, NULL, NULL \
66 },
19571483 67#define RX_OP_PROVIDE_SECRET_INITIAL(dcid) \
ecc920b3 68 { RX_TEST_OP_PROVIDE_SECRET_INITIAL, 0, NULL, 0, NULL, 0, 0, 0, &(dcid), NULL },
19571483 69#define RX_OP_DISCARD_EL(el) \
ecc920b3 70 { RX_TEST_OP_DISCARD_EL, 0, NULL, 0, NULL, (el), 0, 0, NULL, NULL },
19571483 71#define RX_OP_CHECK_PKT(expect_hdr, expect_body) \
ec279ac2 72 { \
ecc920b3 73 RX_TEST_OP_CHECK_PKT, 0, (expect_body), sizeof(expect_body), \
ec279ac2
HL
74 &(expect_hdr), 0, 0, 0, NULL, NULL \
75 },
ecc920b3
RL
76#define RX_OP_CHECK_PKT_FRAMES_OK(expect_hdr, expect_body) \
77 { \
78 RX_TEST_OP_CHECK_PKT, RX_TEST_OP_CHECK_PKT_FRAMES_OK, \
79 (expect_body), sizeof(expect_body), &(expect_hdr), \
80 0, 0, 0, NULL, NULL \
81 },
82#define RX_OP_CHECK_PKT_FRAMES_INVALID(expect_hdr, expect_body) \
83 { \
84 RX_TEST_OP_CHECK_PKT, RX_TEST_OP_CHECK_PKT_FRAMES_INVALID, \
85 (expect_body), sizeof(expect_body), &(expect_hdr), \
86 0, 0, 0, NULL, NULL \
87 },
19571483 88#define RX_OP_CHECK_NO_PKT() \
ecc920b3 89 { RX_TEST_OP_CHECK_NO_PKT, 0, NULL, 0, NULL, 0, 0, 0, NULL, NULL },
948c656c 90#define RX_OP_CHECK_KEY_EPOCH(expected) \
ecc920b3 91 { RX_TEST_OP_CHECK_KEY_EPOCH, 0, NULL, 0, NULL, 0, 0, (expected), NULL },
948c656c 92#define RX_OP_KEY_UPDATE_TIMEOUT(normal) \
ecc920b3 93 { RX_TEST_OP_KEY_UPDATE_TIMEOUT, 0, NULL, 0, NULL, (normal), 0, 0, NULL },
948c656c 94#define RX_OP_SET_INIT_KEY_PHASE(kp_bit) \
ecc920b3 95 { RX_TEST_OP_SET_INIT_KEY_PHASE, 0, NULL, 0, NULL, (kp_bit), 0, 0, NULL },
ec279ac2 96
19571483
HL
97#define RX_OP_INJECT_N(n) \
98 RX_OP_INJECT(rx_script_##n##_in)
99#define RX_OP_CHECK_PKT_N(n) \
100 RX_OP_CHECK_PKT(rx_script_##n##_expect_hdr, rx_script_##n##_body)
ecc920b3
RL
101#define RX_OP_CHECK_PKT_FRAMES_OK_N(n) \
102 RX_OP_CHECK_PKT_FRAMES_OK(rx_script_##n##_expect_hdr, rx_script_##n##_body)
103#define RX_OP_CHECK_PKT_FRAMES_INVALID_N(n) \
104 RX_OP_CHECK_PKT_FRAMES_INVALID(rx_script_##n##_expect_hdr, rx_script_##n##_body)
ec279ac2 105
ecc920b3 106#define RX_OP_INJECT_CHECK(n) \
19571483
HL
107 RX_OP_INJECT_N(n) \
108 RX_OP_CHECK_PKT_N(n)
ec279ac2 109
ecc920b3
RL
110#define RX_OP_INJECT_CHECK_FRAMES_OK(n) \
111 RX_OP_INJECT_N(n) \
112 RX_OP_CHECK_PKT_FRAMES_OK_N(n)
113
114#define RX_OP_INJECT_CHECK_FRAMES_INVALID(n) \
115 RX_OP_INJECT_N(n) \
116 RX_OP_CHECK_PKT_FRAMES_INVALID_N(3)
117
ec279ac2 118/* 1. RFC 9001 - A.3 Server Initial */
19571483 119static const unsigned char rx_script_1_in[] = {
ec279ac2
HL
120 0xcf, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0xf0, 0x67, 0xa5, 0x50, 0x2a,
121 0x42, 0x62, 0xb5, 0x00, 0x40, 0x75, 0xc0, 0xd9, 0x5a, 0x48, 0x2c, 0xd0,
122 0x99, 0x1c, 0xd2, 0x5b, 0x0a, 0xac, 0x40, 0x6a, 0x58, 0x16, 0xb6, 0x39,
123 0x41, 0x00, 0xf3, 0x7a, 0x1c, 0x69, 0x79, 0x75, 0x54, 0x78, 0x0b, 0xb3,
124 0x8c, 0xc5, 0xa9, 0x9f, 0x5e, 0xde, 0x4c, 0xf7, 0x3c, 0x3e, 0xc2, 0x49,
125 0x3a, 0x18, 0x39, 0xb3, 0xdb, 0xcb, 0xa3, 0xf6, 0xea, 0x46, 0xc5, 0xb7,
126 0x68, 0x4d, 0xf3, 0x54, 0x8e, 0x7d, 0xde, 0xb9, 0xc3, 0xbf, 0x9c, 0x73,
127 0xcc, 0x3f, 0x3b, 0xde, 0xd7, 0x4b, 0x56, 0x2b, 0xfb, 0x19, 0xfb, 0x84,
128 0x02, 0x2f, 0x8e, 0xf4, 0xcd, 0xd9, 0x37, 0x95, 0xd7, 0x7d, 0x06, 0xed,
129 0xbb, 0x7a, 0xaf, 0x2f, 0x58, 0x89, 0x18, 0x50, 0xab, 0xbd, 0xca, 0x3d,
130 0x20, 0x39, 0x8c, 0x27, 0x64, 0x56, 0xcb, 0xc4, 0x21, 0x58, 0x40, 0x7d,
131 0xd0, 0x74, 0xee
132};
133
19571483 134static const unsigned char rx_script_1_body[] = {
ec279ac2
HL
135 0x02, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x40, 0x5a, 0x02, 0x00, 0x00,
136 0x56, 0x03, 0x03, 0xee, 0xfc, 0xe7, 0xf7, 0xb3, 0x7b, 0xa1, 0xd1, 0x63,
137 0x2e, 0x96, 0x67, 0x78, 0x25, 0xdd, 0xf7, 0x39, 0x88, 0xcf, 0xc7, 0x98,
138 0x25, 0xdf, 0x56, 0x6d, 0xc5, 0x43, 0x0b, 0x9a, 0x04, 0x5a, 0x12, 0x00,
139 0x13, 0x01, 0x00, 0x00, 0x2e, 0x00, 0x33, 0x00, 0x24, 0x00, 0x1d, 0x00,
140 0x20, 0x9d, 0x3c, 0x94, 0x0d, 0x89, 0x69, 0x0b, 0x84, 0xd0, 0x8a, 0x60,
ecc920b3 141 0x99, 0x3c, 0x14, 0x4e, 0xca, 0x68, 0x4d, 0x10, 0x81, 0x28, 0x7c, 0x83,
ec279ac2
HL
142 0x4d, 0x53, 0x11, 0xbc, 0xf3, 0x2b, 0xb9, 0xda, 0x1a, 0x00, 0x2b, 0x00,
143 0x02, 0x03, 0x04
144};
145
19571483 146static const QUIC_CONN_ID rx_script_1_dcid = {
ec279ac2
HL
147 8, { 0x83, 0x94, 0xc8, 0xf0, 0x3e, 0x51, 0x57, 0x08 }
148};
149
19571483 150static const QUIC_PKT_HDR rx_script_1_expect_hdr = {
ec279ac2
HL
151 QUIC_PKT_TYPE_INITIAL,
152 0, 0, 2, 0, 1, 1, { 0, {0} },
153 { 8, {0xf0, 0x67, 0xa5, 0x50, 0x2a, 0x42, 0x62, 0xb5 } },
154 { 0, 1, 0, 0 },
155 NULL, 0,
156 99, NULL
157};
158
19571483
HL
159static const struct rx_test_op rx_script_1[] = {
160 RX_OP_SET_SCID_LEN(2)
161 RX_OP_SET_INIT_LARGEST_PN(0)
162 RX_OP_ADD_RX_DCID(empty_conn_id)
163 RX_OP_PROVIDE_SECRET_INITIAL(rx_script_1_dcid)
ecc920b3 164 RX_OP_INJECT_CHECK_FRAMES_OK(1)
19571483
HL
165 RX_OP_CHECK_NO_PKT()
166 RX_OP_END
ec279ac2
HL
167};
168
169/* 2. RFC 9001 - A.5 ChaCha20-Poly1305 Short Header Packet */
681c4619 170#ifndef OPENSSL_NO_CHACHA
19571483 171static const unsigned char rx_script_2_in[] = {
ec279ac2
HL
172 0x4c, 0xfe, 0x41, 0x89, 0x65, 0x5e, 0x5c, 0xd5, 0x5c, 0x41, 0xf6, 0x90,
173 0x80, 0x57, 0x5d, 0x79, 0x99, 0xc2, 0x5a, 0x5b, 0xfb
174};
175
19571483 176static const unsigned char rx_script_2_secret[] = {
ec279ac2
HL
177 0x9a, 0xc3, 0x12, 0xa7, 0xf8, 0x77, 0x46, 0x8e, 0xbe, 0x69, 0x42, 0x27,
178 0x48, 0xad, 0x00, 0xa1, 0x54, 0x43, 0xf1, 0x82, 0x03, 0xa0, 0x7d, 0x60,
179 0x60, 0xf6, 0x88, 0xf3, 0x0f, 0x21, 0x63, 0x2b
180};
181
19571483 182static const unsigned char rx_script_2_body[] = {
ec279ac2
HL
183 0x01
184};
185
19571483 186static const QUIC_PKT_HDR rx_script_2_expect_hdr = {
ec279ac2
HL
187 QUIC_PKT_TYPE_1RTT,
188 0, 0, 3, 0, 1, 0, {0, {0}}, {0, {0}},
189 {0x00, 0xbf, 0xf4, 0x00},
190 NULL, 0,
191 1, NULL
192};
193
19571483
HL
194static const struct rx_test_op rx_script_2[] = {
195 RX_OP_SET_INIT_LARGEST_PN(654360560)
196 RX_OP_ADD_RX_DCID(empty_conn_id)
197 RX_OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT, QRL_SUITE_CHACHA20POLY1305,
198 rx_script_2_secret)
ecc920b3 199 RX_OP_INJECT_CHECK_FRAMES_OK(2)
19571483
HL
200 RX_OP_CHECK_NO_PKT()
201 RX_OP_END
ec279ac2 202};
681c4619 203#endif /* !defined(OPENSSL_NO_CHACHA) */
ec279ac2
HL
204
205/* 3. Real World - Version Negotiation Response */
19571483 206static const unsigned char rx_script_3_in[] = {
ec279ac2
HL
207 0xc7, /* Long; Random Bits */
208 0x00, 0x00, 0x00, 0x00, /* Version 0 (Version Negotiation) */
209 0x00, /* DCID */
210 0x0c, 0x35, 0x3c, 0x1b, 0x97, 0xca, /* SCID */
211 0xf8, 0x99, 0x11, 0x39, 0xad, 0x79,
212 0x1f,
213 0x00, 0x00, 0x00, 0x01, /* Supported Version: 1 */
214 0xaa, 0x9a, 0x3a, 0x9a /* Supported Version: Random (GREASE) */
215};
216
19571483 217static const QUIC_PKT_HDR rx_script_3_expect_hdr = {
ec279ac2
HL
218 QUIC_PKT_TYPE_VERSION_NEG,
219 0, /* Spin Bit */
220 0, /* Key Phase */
221 0, /* PN Length */
222 0, /* Partial */
223 1, /* Fixed */
224 0, /* Version */
225 {0, {0}}, /* DCID */
226 {12, {0x35, 0x3c, 0x1b, 0x97, 0xca, 0xf8, /* SCID */
227 0x99, 0x11, 0x39, 0xad, 0x79, 0x1f}},
228 {0}, /* PN */
229 NULL, 0, /* Token/Token Len */
230 8, NULL
231};
232
19571483 233static const unsigned char rx_script_3_body[] = {
ec279ac2
HL
234 0x00, 0x00, 0x00, 0x01,
235 0xaa, 0x9a, 0x3a, 0x9a
236};
237
19571483
HL
238static const struct rx_test_op rx_script_3[] = {
239 RX_OP_ADD_RX_DCID(empty_conn_id)
ecc920b3
RL
240 /*
241 * This is a version negotiation packet, so doesn't have any frames.
242 * However, the depacketizer still handles this sort of packet, so
243 * we still pass the packet to it, to exercise what it does.
244 */
245 RX_OP_INJECT_CHECK_FRAMES_OK(3)
19571483
HL
246 RX_OP_CHECK_NO_PKT()
247 RX_OP_END
ec279ac2
HL
248};
249
250/* 4. Real World - Retry (S2C) */
19571483 251static const unsigned char rx_script_4_in[] = {
ec279ac2
HL
252 0xf0, /* Long; Retry */
253 0x00, 0x00, 0x00, 0x01, /* Version 1 */
254 0x00, /* DCID */
255 0x04, 0xad, 0x15, 0x3f, 0xae, /* SCID */
256 /* Retry Token, including 16-byte Retry Integrity Tag */
257 0xf6, 0x8b, 0x6e, 0xa3, 0xdc, 0x40, 0x38, 0xc6, 0xa5, 0x99, 0x1c, 0xa9,
258 0x77, 0xe6, 0x1d, 0x4f, 0x09, 0x36, 0x12, 0x26, 0x00, 0x56, 0x0b, 0x29,
259 0x7d, 0x5e, 0xda, 0x39, 0xc6, 0x61, 0x57, 0x69, 0x15, 0xff, 0x93, 0x39,
260 0x95, 0xf0, 0x57, 0xf1, 0xe5, 0x36, 0x08, 0xad, 0xd2, 0x75, 0xa9, 0x68,
261 0x29, 0xed, 0xaa, 0x03, 0x0e, 0x5f, 0xac, 0xbd, 0x26, 0x07, 0x95, 0x4e,
262 0x48, 0x61, 0x26, 0xc5, 0xe2, 0x6c, 0x60, 0xbf, 0xa8, 0x6f, 0x51, 0xbb,
263 0x1d, 0xf7, 0x98, 0x95, 0x3b, 0x2c, 0x50, 0x79, 0xcc, 0xde, 0x27, 0x84,
264 0x44, 0x9b, 0xb2, 0x4a, 0x94, 0x4d, 0x4d, 0x3d, 0xbc, 0x00, 0x9d, 0x69,
265 0xad, 0x45, 0x89, 0x04, 0x48, 0xca, 0x04, 0xf6, 0x3a, 0x62, 0xc1, 0x38,
266 0x9d, 0x82, 0xb3, 0x45, 0x62, 0x4c,
267};
268
19571483 269static const QUIC_PKT_HDR rx_script_4_expect_hdr = {
ec279ac2
HL
270 QUIC_PKT_TYPE_RETRY,
271 0, /* Spin Bit */
272 0, /* Key Phase */
273 0, /* PN Length */
274 0, /* Partial */
275 1, /* Fixed */
276 1, /* Version */
277 {0, {0}}, /* DCID */
278 {4, {0xad, 0x15, 0x3f, 0xae}}, /* SCID */
279 {0}, /* PN */
280 NULL, 0, /* Token/Token Len */
281 114, NULL
282};
283
19571483 284static const unsigned char rx_script_4_body[] = {
ec279ac2
HL
285 0xf6, 0x8b, 0x6e, 0xa3, 0xdc, 0x40, 0x38, 0xc6, 0xa5, 0x99, 0x1c, 0xa9,
286 0x77, 0xe6, 0x1d, 0x4f, 0x09, 0x36, 0x12, 0x26, 0x00, 0x56, 0x0b, 0x29,
287 0x7d, 0x5e, 0xda, 0x39, 0xc6, 0x61, 0x57, 0x69, 0x15, 0xff, 0x93, 0x39,
288 0x95, 0xf0, 0x57, 0xf1, 0xe5, 0x36, 0x08, 0xad, 0xd2, 0x75, 0xa9, 0x68,
289 0x29, 0xed, 0xaa, 0x03, 0x0e, 0x5f, 0xac, 0xbd, 0x26, 0x07, 0x95, 0x4e,
290 0x48, 0x61, 0x26, 0xc5, 0xe2, 0x6c, 0x60, 0xbf, 0xa8, 0x6f, 0x51, 0xbb,
291 0x1d, 0xf7, 0x98, 0x95, 0x3b, 0x2c, 0x50, 0x79, 0xcc, 0xde, 0x27, 0x84,
292 0x44, 0x9b, 0xb2, 0x4a, 0x94, 0x4d, 0x4d, 0x3d, 0xbc, 0x00, 0x9d, 0x69,
293 0xad, 0x45, 0x89, 0x04, 0x48, 0xca, 0x04, 0xf6, 0x3a, 0x62, 0xc1, 0x38,
294 0x9d, 0x82, 0xb3, 0x45, 0x62, 0x4c
295};
296
19571483
HL
297static const struct rx_test_op rx_script_4[] = {
298 RX_OP_ADD_RX_DCID(empty_conn_id)
ecc920b3 299 RX_OP_INJECT_CHECK_FRAMES_OK(4)
19571483
HL
300 RX_OP_CHECK_NO_PKT()
301 RX_OP_END
ec279ac2
HL
302};
303
304/*
305 * 5. Real World - S2C Multiple Packets
306 * - Initial, Handshake, 1-RTT (AES-128-GCM/SHA256)
307 */
19571483 308static const QUIC_CONN_ID rx_script_5_c2s_init_dcid = {
ec279ac2
HL
309 4, {0xad, 0x15, 0x3f, 0xae}
310};
311
19571483 312static const unsigned char rx_script_5_handshake_secret[32] = {
ec279ac2
HL
313 0x5e, 0xc6, 0x4a, 0x4d, 0x0d, 0x40, 0x43, 0x3b, 0xd5, 0xbd, 0xe0, 0x19,
314 0x71, 0x47, 0x56, 0xf3, 0x59, 0x3a, 0xa6, 0xc9, 0x3e, 0xdc, 0x81, 0x1e,
315 0xc7, 0x72, 0x9d, 0x83, 0xd8, 0x8f, 0x88, 0x77
316};
317
19571483 318static const unsigned char rx_script_5_1rtt_secret[32] = {
ec279ac2
HL
319 0x53, 0xf2, 0x1b, 0x94, 0xa7, 0x65, 0xf7, 0x76, 0xfb, 0x06, 0x27, 0xaa,
320 0xd2, 0x3f, 0xe0, 0x9a, 0xbb, 0xcf, 0x99, 0x6f, 0x13, 0x2c, 0x6a, 0x37,
321 0x95, 0xf3, 0xda, 0x21, 0xcb, 0xcb, 0xa5, 0x26,
322};
323
19571483 324static const unsigned char rx_script_5_in[] = {
ec279ac2
HL
325 /* First Packet: Initial */
326 0xc4, /* Long, Initial, PN Length=2 bytes */
327 0x00, 0x00, 0x00, 0x01, /* Version */
328 0x00, /* DCID */
329 0x04, 0x83, 0xd0, 0x0a, 0x27, /* SCID */
330 0x00, /* Token Length */
331 0x41, 0xd2, /* Length (466) */
332 0xe3, 0xab, /* PN (0) */
333 0x22, 0x35, 0x34, 0x12, 0xcf, 0x20, 0x2b, 0x16, 0xaf, 0x08, 0xd4, 0xe0,
334 0x94, 0x8b, 0x1e, 0x62, 0xdf, 0x31, 0x61, 0xcc, 0xf9, 0xfa, 0x66, 0x4f,
335 0x18, 0x61, 0x07, 0xcb, 0x13, 0xd3, 0xf9, 0xbf, 0xe2, 0x8e, 0x25, 0x8d,
336 0xd1, 0xdf, 0x58, 0x9c, 0x05, 0x20, 0xf9, 0xf2, 0x01, 0x20, 0xe9, 0x39,
337 0xc3, 0x80, 0x77, 0xec, 0xa4, 0x57, 0xcf, 0x57, 0x8c, 0xdd, 0x68, 0x82,
338 0x91, 0xfe, 0x71, 0xa0, 0xfa, 0x56, 0x4c, 0xf2, 0xe7, 0x2b, 0xd0, 0xc0,
339 0xda, 0x81, 0xe2, 0x39, 0xb5, 0xf0, 0x0f, 0xd9, 0x07, 0xd5, 0x67, 0x09,
340 0x02, 0xf0, 0xff, 0x74, 0xb0, 0xa0, 0xd9, 0x3a, 0x7e, 0xb6, 0x57, 0x82,
341 0x47, 0x18, 0x66, 0xed, 0xe2, 0x18, 0x4d, 0xc2, 0x5c, 0x9f, 0x05, 0x09,
342 0x18, 0x24, 0x0e, 0x3f, 0x3d, 0xf9, 0x15, 0x8b, 0x08, 0xfd, 0x25, 0xe9,
343 0xc9, 0xb7, 0x8c, 0x18, 0x7b, 0xf3, 0x37, 0x58, 0xf0, 0xf0, 0xac, 0x33,
344 0x55, 0x3f, 0x39, 0xbc, 0x62, 0x03, 0x8a, 0xc0, 0xd6, 0xcc, 0x49, 0x47,
345 0xeb, 0x85, 0xb6, 0x72, 0xd7, 0xf8, 0xdc, 0x01, 0x32, 0xec, 0x1b, 0x4e,
346 0x38, 0x6e, 0x2c, 0xc5, 0x80, 0xf2, 0x43, 0x4a, 0xf5, 0xe5, 0xa2, 0xf8,
347 0x76, 0xa7, 0xa8, 0x57, 0x32, 0x67, 0x72, 0xeb, 0x82, 0xac, 0x3e, 0xc0,
348 0x15, 0x67, 0xac, 0x32, 0x19, 0x18, 0x0a, 0xef, 0x20, 0xa1, 0xe8, 0xaf,
349 0xac, 0x33, 0x87, 0x4c, 0x55, 0x05, 0x9b, 0x78, 0xf0, 0x3a, 0xce, 0x02,
350 0x28, 0x06, 0x84, 0x61, 0x97, 0xac, 0x87, 0x8f, 0x25, 0xe7, 0x1b, 0xa3,
351 0x02, 0x08, 0x4c, 0x2e, 0xef, 0xbd, 0x4f, 0x82, 0xe7, 0x37, 0x6c, 0x27,
352 0x6f, 0x85, 0xb4, 0xbc, 0x79, 0x38, 0x45, 0x80, 0x8a, 0xda, 0x2f, 0x11,
353 0x11, 0xac, 0x9c, 0xf3, 0x93, 0xc1, 0x49, 0x1b, 0x94, 0x12, 0x77, 0x07,
354 0xdc, 0xbf, 0xc2, 0xfd, 0x8b, 0xf6, 0xf1, 0x66, 0x1c, 0x7f, 0x07, 0xbf,
355 0x1f, 0xae, 0x27, 0x6c, 0x66, 0xe9, 0xa3, 0x64, 0x7a, 0x96, 0x78, 0x45,
356 0xfe, 0x4b, 0x8c, 0x6f, 0x7f, 0x03, 0x47, 0x3c, 0xd7, 0xf7, 0x63, 0x92,
357 0x58, 0x5b, 0x63, 0x83, 0x03, 0x05, 0xc3, 0x5d, 0x36, 0x62, 0x63, 0x5e,
358 0xcf, 0xfe, 0x0a, 0x29, 0xfa, 0xeb, 0xc8, 0xaf, 0xce, 0x31, 0x07, 0x6a,
359 0x09, 0x41, 0xc0, 0x2d, 0x98, 0x70, 0x05, 0x3b, 0x41, 0xfc, 0x7d, 0x61,
360 0xe0, 0x41, 0x7d, 0x13, 0x41, 0x51, 0x52, 0xb4, 0x78, 0xd5, 0x46, 0x51,
361 0x3b, 0xf1, 0xcd, 0xcc, 0x2e, 0x49, 0x30, 0x8b, 0x2a, 0xd2, 0xe6, 0x69,
362 0xb5, 0x6b, 0x7a, 0xf4, 0xbb, 0xd1, 0xf8, 0x4a, 0xe8, 0x53, 0x10, 0x46,
363 0x85, 0x8d, 0x66, 0x8e, 0x2b, 0xe8, 0x5d, 0xab, 0x7e, 0xfe, 0x5a, 0x79,
364 0xcf, 0xc5, 0x0c, 0x30, 0x9e, 0x98, 0x02, 0xb3, 0xa6, 0xd5, 0xfa, 0x25,
365 0xa8, 0xc8, 0xc1, 0xd9, 0x51, 0x60, 0x57, 0x5d, 0xfe, 0x75, 0x97, 0x05,
366 0xda, 0xbb, 0xc6, 0x6a, 0xbe, 0x5c, 0xa5, 0x65, 0x0a, 0x12, 0x33, 0x1c,
367 0xdf, 0xee, 0x08, 0xa9, 0x13, 0x13, 0x28, 0xce, 0x61, 0x59, 0xd1, 0x4e,
368 0xc7, 0x74, 0xfd, 0x64, 0xde, 0x08, 0xce, 0xda, 0x3f, 0xec, 0xad, 0xc9,
369 0xe1, 0xf9, 0x1f, 0x74, 0xf6, 0x86, 0x37, 0x6a, 0xa0, 0xc8, 0x0b, 0x1b,
370 0x94, 0x98, 0x86, 0x81, 0x3b, 0xfc, 0x47, 0x6c, 0xc9, 0x3e, 0x3c, 0x30,
371 0xc5, 0x9e, 0xb2, 0x32, 0x47, 0xf5, 0x0c, 0x6f,
372
373 /* Second Packet: Handshake */
374 0xe6, /* Long, Handshake, PN Length=2 bytes */
375 0x00, 0x00, 0x00, 0x01, /* Version */
376 0x00, /* DCID */
377 0x04, 0x83, 0xd0, 0x0a, 0x27, /* SCID */
378 0x42, 0x9c, /* Length (668) */
379 0x9c, 0x55, /* PN (0) */
380 0x55, 0xd4, 0x50, 0x02, 0x1a, 0x57, 0x84, 0x22, 0xcd, 0x01, 0xe5, 0x42,
381 0x1b, 0x1e, 0x06, 0xf1, 0x86, 0xe2, 0x90, 0xf8, 0x9c, 0x3d, 0xa2, 0x7c,
382 0xde, 0x2b, 0xc9, 0x2e, 0xcd, 0xa8, 0x4f, 0x5a, 0x20, 0xca, 0x96, 0xb6,
383 0x11, 0x4b, 0xc8, 0x71, 0x32, 0xb5, 0xc7, 0x1a, 0x69, 0x7f, 0x1e, 0x37,
384 0x49, 0xfb, 0x08, 0xce, 0x83, 0x5f, 0x02, 0x6d, 0x8a, 0x8f, 0xe7, 0x5d,
385 0xe1, 0x34, 0x31, 0x22, 0x53, 0x53, 0x32, 0xcb, 0x04, 0x21, 0xce, 0xbc,
386 0xa5, 0x1b, 0xdd, 0x4d, 0xd5, 0x1c, 0xd6, 0x5d, 0x88, 0x29, 0x5a, 0x19,
387 0x71, 0x6a, 0xc2, 0xfa, 0xb7, 0xb4, 0x7d, 0xd1, 0x72, 0x93, 0x8f, 0x7c,
388 0xb5, 0x36, 0x1b, 0xea, 0xf3, 0xf1, 0xd7, 0x6e, 0xd3, 0x91, 0x96, 0x62,
389 0x4d, 0xc6, 0xec, 0xb7, 0xb0, 0xb7, 0x9b, 0x95, 0x8b, 0x14, 0x8d, 0x1a,
390 0x0d, 0xb6, 0x3e, 0xec, 0xfe, 0x3b, 0x51, 0xea, 0x1a, 0x05, 0x14, 0x12,
391 0x93, 0x0e, 0x7e, 0xe6, 0xa2, 0xc5, 0x22, 0x87, 0x65, 0xf8, 0x5d, 0x3c,
392 0x55, 0x18, 0xcb, 0xe9, 0xef, 0x23, 0x43, 0xfe, 0xe8, 0x0d, 0xb2, 0x0f,
393 0xc5, 0xf4, 0xb3, 0xde, 0x0c, 0xea, 0xa4, 0x48, 0x8e, 0xbf, 0x1f, 0xc7,
394 0x99, 0x53, 0x8c, 0xc1, 0x3d, 0xba, 0xf4, 0x8e, 0x8e, 0x02, 0x52, 0xf6,
395 0x1f, 0xcf, 0x1d, 0xaa, 0xb3, 0xcb, 0x08, 0xc2, 0xe1, 0x70, 0x68, 0x74,
396 0x78, 0xa9, 0x30, 0x67, 0xba, 0x2b, 0xea, 0x35, 0x63, 0x47, 0xff, 0x29,
397 0x73, 0x29, 0xc6, 0xe8, 0x08, 0xa9, 0x1e, 0x8f, 0x28, 0x41, 0xa4, 0x24,
398 0x54, 0x26, 0x5f, 0x42, 0x77, 0xb1, 0x2b, 0x3d, 0x65, 0x67, 0x60, 0xa7,
399 0x23, 0x0d, 0xa7, 0xf4, 0xd6, 0xe9, 0x4e, 0x58, 0x43, 0x9f, 0x3c, 0x9e,
400 0x77, 0x61, 0xe5, 0x04, 0x4f, 0x73, 0xc9, 0x10, 0x79, 0xd0, 0xda, 0x3b,
401 0xc6, 0x19, 0x93, 0x9f, 0x48, 0x3b, 0x76, 0x38, 0xa1, 0x72, 0x49, 0x7d,
402 0x86, 0x7f, 0xe8, 0x1b, 0xa9, 0x5b, 0xc0, 0x47, 0xa0, 0x9c, 0x3f, 0x65,
403 0x60, 0x76, 0x59, 0xaf, 0x20, 0x2d, 0x40, 0xa6, 0x80, 0x49, 0x5a, 0x8f,
404 0x09, 0xf8, 0xf6, 0x97, 0xc1, 0xbd, 0xe1, 0x9f, 0x9b, 0xa2, 0x4c, 0x7b,
405 0x88, 0xac, 0xbe, 0x4b, 0x11, 0x28, 0xd7, 0x67, 0xe6, 0xad, 0xaf, 0xd0,
406 0xad, 0x01, 0x29, 0xa4, 0x4a, 0xc4, 0xb8, 0x2e, 0x42, 0x79, 0x24, 0x9e,
407 0xd5, 0x34, 0xae, 0x45, 0xf1, 0x0b, 0x38, 0x4a, 0x76, 0xfb, 0x50, 0xa2,
408 0x99, 0xc9, 0x5b, 0x6d, 0xc0, 0xb7, 0x55, 0xd8, 0x8d, 0x49, 0xdd, 0x1b,
409 0xb8, 0xec, 0x10, 0x57, 0x9e, 0x33, 0xb4, 0x10, 0x16, 0x19, 0xac, 0x69,
410 0xa2, 0x19, 0x1b, 0xd0, 0x77, 0x45, 0xeb, 0x49, 0x5c, 0xc5, 0x7c, 0xbe,
411 0x4b, 0x4a, 0x22, 0x5c, 0x3d, 0x0e, 0x6e, 0xe5, 0x4b, 0x36, 0x06, 0x63,
412 0x03, 0x97, 0xab, 0xed, 0xdc, 0xea, 0x64, 0xc2, 0x70, 0xb6, 0x7e, 0x35,
413 0xfb, 0x13, 0x66, 0x37, 0xa3, 0x3f, 0x28, 0x16, 0x6c, 0xe7, 0xd4, 0xe6,
414 0xca, 0x26, 0x0f, 0x19, 0xdd, 0x02, 0xae, 0xc1, 0xcf, 0x18, 0x7d, 0x56,
415 0xe6, 0x52, 0xf3, 0x37, 0xb5, 0x86, 0x9d, 0x1d, 0x55, 0xb3, 0x95, 0x19,
416 0x19, 0xa5, 0x44, 0x95, 0x81, 0xed, 0x02, 0x18, 0xf1, 0x85, 0x57, 0x78,
417 0x28, 0xc4, 0x9a, 0xba, 0xe8, 0x5e, 0x22, 0x8d, 0xc1, 0x7b, 0x2a, 0x8a,
418 0xc8, 0xb9, 0xdd, 0x82, 0xb2, 0x7b, 0x9f, 0x3d, 0xf5, 0x27, 0x2a, 0x48,
419 0x53, 0xc7, 0xa0, 0x70, 0x0e, 0x9d, 0x61, 0xaa, 0xe2, 0xad, 0x28, 0xf2,
420 0xb4, 0xfc, 0x56, 0x6b, 0x89, 0xe7, 0xf9, 0x51, 0xc9, 0xe9, 0xd3, 0x8a,
421 0x8c, 0x7e, 0x86, 0xdd, 0xba, 0x2f, 0x39, 0xbf, 0x26, 0x62, 0x23, 0xd6,
422 0x98, 0x6d, 0x3e, 0x72, 0xd7, 0x1b, 0xe1, 0x62, 0x94, 0x35, 0xe2, 0x18,
423 0x19, 0x46, 0xb8, 0x2c, 0xb5, 0x8f, 0x8f, 0xb0, 0x5b, 0x76, 0x7b, 0x7e,
424 0xb8, 0xc6, 0xb7, 0xe9, 0x4e, 0x9d, 0x30, 0x68, 0x03, 0x1e, 0x19, 0x73,
425 0xc5, 0x3e, 0x24, 0xe2, 0x95, 0x60, 0x1b, 0x27, 0x93, 0x7c, 0x17, 0xc2,
426 0xc6, 0xa3, 0xbd, 0xbd, 0x70, 0xc6, 0x60, 0x59, 0xc8, 0x5c, 0xd7, 0x9a,
427 0xc4, 0x29, 0xac, 0x0f, 0xaa, 0x0d, 0xa9, 0x92, 0xa3, 0x95, 0xd7, 0x0f,
428 0x6f, 0x74, 0x99, 0x9b, 0xc1, 0xd3, 0x68, 0x6d, 0xac, 0x82, 0x2d, 0x32,
429 0x41, 0x9e, 0x0c, 0xf7, 0x31, 0x59, 0x4c, 0x93, 0x1c, 0x3b, 0x71, 0x69,
430 0xcf, 0xc5, 0xca, 0x2b, 0xdf, 0xe7, 0xaa, 0xfd, 0x1d, 0x71, 0x01, 0x7e,
431 0x1c, 0x70, 0x62, 0x20, 0x61, 0xf8, 0x35, 0xc1, 0x71, 0xe7, 0x02, 0x0d,
432 0x88, 0x44, 0xd9, 0x00, 0xc5, 0xcc, 0x63, 0xe4, 0xf0, 0x86, 0xa7, 0xd0,
433 0xfe, 0xcc, 0xb7, 0x1d, 0xfc, 0x21, 0x61, 0x54, 0x15, 0xea, 0x81, 0x5e,
434 0xc0, 0x31, 0xfa, 0xbf, 0x7d, 0xb9, 0x3b, 0xa2, 0x1e, 0x42, 0x73, 0x05,
435 0x3c, 0xdb, 0x21, 0x59, 0x4f, 0x63,
436
437 /* Third Packet: 1-RTT */
438 0x5f, /* Short, 1-RTT, Spin=0, KP=0, PN Length=2 bytes */
439 0x68, 0x47, /* PN (0) */
440 0xa3, 0x3c, 0xa5, 0x27, 0x5e, 0xf9, 0x8d, 0xec, 0xea, 0x6c, 0x09, 0x18,
441 0x40, 0x80, 0xee, 0x9f, 0x6f, 0x73, 0x5c, 0x49, 0xe3, 0xec, 0xb7, 0x58,
442 0x05, 0x66, 0x8f, 0xa3, 0x52, 0x37, 0xa1, 0x22, 0x1f, 0xc6, 0x92, 0xd6,
443 0x59, 0x04, 0x99, 0xcb, 0x44, 0xef, 0x66, 0x05, 0x2d, 0xd0, 0x85, 0x24,
444 0xbb, 0xe3, 0xa1, 0xd1, 0xbe, 0xf7, 0x54, 0xad, 0x65, 0xf4, 0xd4, 0x59,
445 0x54, 0x87, 0x4e, 0x22, 0x4f, 0x06, 0x07, 0xa7, 0x8a, 0x14, 0x89, 0xd1,
446 0x3f, 0xd3, 0xe4, 0x6f, 0x71, 0x8f, 0x9a, 0xd2, 0x3b, 0x61, 0x0a, 0xba,
447 0x9a, 0x31, 0x56, 0xc7,
448};
449
19571483 450static const QUIC_PKT_HDR rx_script_5a_expect_hdr = {
ec279ac2
HL
451 QUIC_PKT_TYPE_INITIAL,
452 0, /* Spin Bit */
453 0, /* Key Phase */
454 2, /* PN Length */
455 0, /* Partial */
456 1, /* Fixed */
457 1, /* Version */
458 {0, {0}}, /* DCID */
459 {4, {0x83, 0xd0, 0x0a, 0x27}}, /* SCID */
460 {0}, /* PN */
461 NULL, 0, /* Token/Token Len */
462 448, NULL
463};
464
19571483 465static const unsigned char rx_script_5a_body[] = {
ec279ac2
HL
466 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
467 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
468 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
469 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
470 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
471 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
472 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
473 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
474 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
475 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
476 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
477 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
478 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
479 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
480 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
481 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
482 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
483 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
484 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
485 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
486 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
487 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
488 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
489 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
490 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
491 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
492 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
493 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
494 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
495 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x40, 0x5a, 0x02, 0x00,
496 0x00, 0x56, 0x03, 0x03, 0xe2, 0xd2, 0x0a, 0x3b, 0xa2, 0xc4, 0xd2, 0x29,
497 0xc8, 0xe8, 0xba, 0x23, 0x31, 0x88, 0x2c, 0x71, 0xeb, 0xba, 0x42, 0x5f,
498 0x94, 0xe9, 0x0a, 0x90, 0x35, 0x31, 0x1e, 0xca, 0xed, 0xf8, 0x8a, 0x8d,
499 0x00, 0x13, 0x01, 0x00, 0x00, 0x2e, 0x00, 0x2b, 0x00, 0x02, 0x03, 0x04,
500 0x00, 0x33, 0x00, 0x24, 0x00, 0x1d, 0x00, 0x20, 0x96, 0x0b, 0x4b, 0x30,
501 0x66, 0x3a, 0x75, 0x01, 0x4a, 0xdc, 0x2a, 0x75, 0x1f, 0xce, 0x7a, 0x30,
502 0x9d, 0x00, 0xca, 0x20, 0xb4, 0xe0, 0x6b, 0x81, 0x23, 0x18, 0x0b, 0x20,
503 0x1f, 0x54, 0x86, 0x1d,
504};
505
19571483 506static const QUIC_PKT_HDR rx_script_5b_expect_hdr = {
ec279ac2
HL
507 QUIC_PKT_TYPE_HANDSHAKE,
508 0, /* Spin Bit */
509 0, /* Key Phase */
510 2, /* PN Length */
511 0, /* Partial */
512 1, /* Fixed */
513 1, /* Version */
514 {0, {0}}, /* DCID */
515 {4, {0x83, 0xd0, 0x0a, 0x27}}, /* SCID */
516 {0}, /* PN */
517 NULL, 0, /* Token/Token Len */
518 650, NULL
519};
520
19571483 521static const unsigned char rx_script_5b_body[] = {
ec279ac2
HL
522 0x06, 0x00, 0x42, 0x86, 0x08, 0x00, 0x00, 0x7d, 0x00, 0x7b, 0x00, 0x10,
523 0x00, 0x08, 0x00, 0x06, 0x05, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x00, 0x39,
524 0x00, 0x6b, 0x4b, 0x20, 0x0b, 0x1b, 0xe1, 0x1f, 0xd0, 0x78, 0xc0, 0x69,
525 0x72, 0x9c, 0xe2, 0xf7, 0x05, 0x04, 0x80, 0x08, 0x00, 0x00, 0x06, 0x04,
526 0x80, 0x08, 0x00, 0x00, 0x07, 0x04, 0x80, 0x08, 0x00, 0x00, 0x04, 0x04,
527 0x80, 0x0c, 0x00, 0x00, 0x08, 0x02, 0x40, 0x64, 0x09, 0x02, 0x40, 0x64,
528 0x01, 0x04, 0x80, 0x00, 0x75, 0x30, 0x03, 0x02, 0x45, 0xac, 0x0b, 0x01,
529 0x1a, 0x0c, 0x00, 0x02, 0x10, 0x41, 0x94, 0x41, 0x8d, 0x0d, 0xfb, 0x60,
530 0x7b, 0xdc, 0xcc, 0xa2, 0x9c, 0x3e, 0xa5, 0xdf, 0x8d, 0x00, 0x08, 0x2d,
531 0x71, 0x8a, 0x38, 0xdf, 0xdd, 0xe0, 0x03, 0x0e, 0x01, 0x04, 0x0f, 0x04,
532 0x83, 0xd0, 0x0a, 0x27, 0x10, 0x04, 0xad, 0x15, 0x3f, 0xae, 0x20, 0x01,
533 0x00, 0x0b, 0x00, 0x01, 0x8f, 0x00, 0x00, 0x01, 0x8b, 0x00, 0x01, 0x86,
534 0x30, 0x82, 0x01, 0x82, 0x30, 0x82, 0x01, 0x29, 0xa0, 0x03, 0x02, 0x01,
535 0x02, 0x02, 0x14, 0x0a, 0x73, 0x0f, 0x86, 0x18, 0xf2, 0xc3, 0x30, 0x01,
536 0xd2, 0xc0, 0xc1, 0x62, 0x52, 0x13, 0xf1, 0x9c, 0x13, 0x39, 0xb5, 0x30,
537 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30,
538 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0c,
539 0x6d, 0x61, 0x70, 0x61, 0x6b, 0x74, 0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
540 0x30, 0x1e, 0x17, 0x0d, 0x32, 0x32, 0x30, 0x38, 0x30, 0x32, 0x31, 0x32,
541 0x30, 0x30, 0x31, 0x38, 0x5a, 0x17, 0x0d, 0x32, 0x32, 0x30, 0x39, 0x30,
542 0x31, 0x31, 0x32, 0x30, 0x30, 0x31, 0x38, 0x5a, 0x30, 0x17, 0x31, 0x15,
543 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0c, 0x6d, 0x61, 0x70,
544 0x61, 0x6b, 0x74, 0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x30, 0x59, 0x30,
545 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08,
546 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04,
547 0x67, 0xf4, 0xd3, 0x8f, 0x15, 0x6d, 0xee, 0x85, 0xcc, 0x2a, 0x77, 0xfc,
548 0x0b, 0x8f, 0x9f, 0xcf, 0xa9, 0x95, 0x5d, 0x5b, 0xcd, 0xb7, 0x8b, 0xba,
549 0x31, 0x0a, 0x73, 0x62, 0xc5, 0xd0, 0x0e, 0x07, 0x90, 0xae, 0x38, 0x43,
550 0x79, 0xce, 0x5e, 0x33, 0xad, 0x31, 0xbf, 0x9f, 0x2a, 0x56, 0x83, 0xa5,
551 0x24, 0x16, 0xab, 0x0c, 0xf1, 0x64, 0xbe, 0xe4, 0x93, 0xb5, 0x89, 0xd6,
552 0x05, 0xe4, 0xf7, 0x7b, 0xa3, 0x53, 0x30, 0x51, 0x30, 0x1d, 0x06, 0x03,
553 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x02, 0x64, 0x0f, 0x55, 0x69,
554 0x14, 0x91, 0x19, 0xed, 0xf9, 0x1a, 0xe9, 0x1d, 0xa5, 0x5a, 0xd0, 0x48,
555 0x96, 0x9f, 0x60, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18,
556 0x30, 0x16, 0x80, 0x14, 0x02, 0x64, 0x0f, 0x55, 0x69, 0x14, 0x91, 0x19,
557 0xed, 0xf9, 0x1a, 0xe9, 0x1d, 0xa5, 0x5a, 0xd0, 0x48, 0x96, 0x9f, 0x60,
558 0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x05,
559 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48,
560 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x47, 0x00, 0x30, 0x44, 0x02, 0x20,
561 0x0a, 0x82, 0x92, 0x6e, 0xd3, 0xc6, 0x66, 0xd9, 0xd3, 0x75, 0xff, 0x71,
562 0x3b, 0x61, 0x46, 0x21, 0x00, 0xe6, 0x21, 0x5d, 0x9c, 0x86, 0xe9, 0x65,
563 0x40, 0x4f, 0xeb, 0x70, 0x4f, 0x2c, 0xad, 0x00, 0x02, 0x20, 0x08, 0xc2,
564 0x07, 0x5d, 0x16, 0xfc, 0x54, 0x34, 0x2b, 0xb4, 0x18, 0x67, 0x44, 0x81,
565 0xc9, 0xa9, 0x67, 0x2e, 0xce, 0xa1, 0x02, 0x9f, 0x3b, 0xe5, 0x61, 0x16,
566 0x0b, 0x50, 0xf6, 0xa1, 0x50, 0x94, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x4a,
567 0x04, 0x03, 0x00, 0x46, 0x30, 0x44, 0x02, 0x20, 0x7d, 0x57, 0x17, 0x14,
568 0x46, 0x09, 0x95, 0x70, 0x09, 0x45, 0xe8, 0x9e, 0x5c, 0x87, 0x55, 0xd9,
569 0x08, 0xc6, 0x5e, 0x47, 0x73, 0x5e, 0xb1, 0xc9, 0xef, 0xcb, 0xe5, 0x7f,
570 0xcc, 0xb0, 0x28, 0xbc, 0x02, 0x20, 0x5d, 0xe4, 0x2b, 0x83, 0xd9, 0x78,
571 0x75, 0x45, 0xf3, 0x22, 0x2b, 0x38, 0xeb, 0x68, 0xe5, 0x71, 0x5d, 0xcb,
572 0xc3, 0x68, 0xb3, 0x0e, 0x7d, 0x5e, 0x1d, 0xc2, 0x1b, 0x8a, 0x62, 0x80,
573 0x48, 0x3e, 0x14, 0x00, 0x00, 0x20, 0x37, 0xcd, 0x55, 0xca, 0x3f, 0x4b,
574 0xf0, 0x95, 0xf8, 0xe4, 0xfe, 0x59, 0xab, 0xbc, 0xc1, 0x8f, 0x0c, 0x3f,
575 0x41, 0x59, 0xf6, 0x96, 0xdb, 0x75, 0xae, 0xe7, 0x86, 0x1a, 0x92, 0xa7,
576 0x53, 0x0a,
577};
578
19571483 579static const QUIC_PKT_HDR rx_script_5c_expect_hdr = {
ec279ac2
HL
580 QUIC_PKT_TYPE_1RTT,
581 0, /* Spin Bit */
582 0, /* Key Phase */
583 2, /* PN Length */
584 0, /* Partial */
585 1, /* Fixed */
586 0, /* Version */
587 {0, {0}}, /* DCID */
588 {0, {0}}, /* SCID */
589 {0}, /* PN */
590 NULL, 0, /* Token/Token Len */
591 72, NULL
592};
593
19571483 594static const unsigned char rx_script_5c_body[] = {
ec279ac2
HL
595 0x18, 0x03, 0x00, 0x04, 0x92, 0xec, 0xaa, 0xd6, 0x47, 0xd8, 0x8b, 0x56,
596 0x3b, 0x5f, 0x67, 0xe6, 0xb9, 0xb9, 0xca, 0x72, 0xca, 0xf2, 0x49, 0x7d,
597 0x18, 0x02, 0x00, 0x04, 0xa9, 0x6e, 0x9b, 0x84, 0x26, 0x43, 0x00, 0xc7,
598 0x55, 0x71, 0x67, 0x2e, 0x52, 0xdd, 0x47, 0xfd, 0x06, 0x51, 0x33, 0x08,
599 0x18, 0x01, 0x00, 0x04, 0x36, 0xd5, 0x1f, 0x06, 0x4e, 0xbf, 0xb4, 0xc9,
600 0xef, 0x97, 0x1e, 0x9a, 0x3c, 0xab, 0x1e, 0xfc, 0xb7, 0x90, 0xc3, 0x1a,
601};
602
19571483
HL
603static const struct rx_test_op rx_script_5[] = {
604 RX_OP_ADD_RX_DCID(empty_conn_id)
605 RX_OP_PROVIDE_SECRET_INITIAL(rx_script_5_c2s_init_dcid)
606 RX_OP_INJECT_N(5)
ecc920b3 607 RX_OP_CHECK_PKT_FRAMES_OK_N(5a)
19571483
HL
608 RX_OP_CHECK_NO_PKT() /* not got secret for next packet yet */
609 RX_OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_HANDSHAKE,
610 QRL_SUITE_AES128GCM, rx_script_5_handshake_secret)
ecc920b3 611 RX_OP_CHECK_PKT_FRAMES_OK_N(5b)
19571483
HL
612 RX_OP_CHECK_NO_PKT() /* not got secret for next packet yet */
613 RX_OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT,
614 QRL_SUITE_AES128GCM, rx_script_5_1rtt_secret)
ecc920b3 615 RX_OP_CHECK_PKT_FRAMES_OK_N(5c)
19571483 616 RX_OP_CHECK_NO_PKT()
ec279ac2
HL
617
618 /* Try injecting the packet again */
19571483 619 RX_OP_INJECT_N(5)
ec279ac2
HL
620 /*
621 * Initial packet is not output due to receiving a Handshake packet causing
622 * auto-discard of Initial keys
623 */
ecc920b3
RL
624 RX_OP_CHECK_PKT_FRAMES_OK_N(5b)
625 RX_OP_CHECK_PKT_FRAMES_OK_N(5c)
19571483 626 RX_OP_CHECK_NO_PKT()
ec279ac2 627 /* Try again with discarded keys */
19571483
HL
628 RX_OP_DISCARD_EL(QUIC_ENC_LEVEL_HANDSHAKE)
629 RX_OP_INJECT_N(5)
ecc920b3 630 RX_OP_CHECK_PKT_FRAMES_OK_N(5c)
19571483 631 RX_OP_CHECK_NO_PKT()
ec279ac2 632 /* Try again */
19571483 633 RX_OP_INJECT_N(5)
ecc920b3 634 RX_OP_CHECK_PKT_FRAMES_OK_N(5c)
19571483 635 RX_OP_CHECK_NO_PKT()
ec279ac2 636 /* Try again with discarded 1-RTT keys */
19571483
HL
637 RX_OP_DISCARD_EL(QUIC_ENC_LEVEL_1RTT)
638 RX_OP_INJECT_N(5)
639 RX_OP_CHECK_NO_PKT()
ec279ac2
HL
640
641 /* Recreate QRL, test reading packets received before key */
19571483
HL
642 RX_OP_SET_SCID_LEN(0)
643 RX_OP_ADD_RX_DCID(empty_conn_id)
644 RX_OP_INJECT_N(5)
645 RX_OP_CHECK_NO_PKT()
646 RX_OP_PROVIDE_SECRET_INITIAL(rx_script_5_c2s_init_dcid)
ecc920b3 647 RX_OP_CHECK_PKT_FRAMES_OK_N(5a)
19571483
HL
648 RX_OP_CHECK_NO_PKT()
649 RX_OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_HANDSHAKE,
650 QRL_SUITE_AES128GCM, rx_script_5_handshake_secret)
ecc920b3 651 RX_OP_CHECK_PKT_FRAMES_OK_N(5b)
19571483
HL
652 RX_OP_CHECK_NO_PKT()
653 RX_OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT,
654 QRL_SUITE_AES128GCM, rx_script_5_1rtt_secret)
ecc920b3 655 RX_OP_CHECK_PKT_FRAMES_OK_N(5c)
19571483
HL
656 RX_OP_CHECK_NO_PKT()
657
658 RX_OP_DISCARD_EL(QUIC_ENC_LEVEL_HANDSHAKE)
659 RX_OP_DISCARD_EL(QUIC_ENC_LEVEL_1RTT)
660 RX_OP_INJECT_N(5)
661 RX_OP_CHECK_NO_PKT()
662
663 RX_OP_END
ec279ac2
HL
664};
665
666/*
667 * 6. Real World - S2C Multiple Packets
668 * - Initial, Handshake, 1-RTT (AES-256-GCM/SHA384)
669 */
19571483 670static const QUIC_CONN_ID rx_script_6_c2s_init_dcid = {
ec279ac2
HL
671 4, {0xac, 0x88, 0x95, 0xbd}
672};
673
19571483 674static const unsigned char rx_script_6_handshake_secret[48] = {
ec279ac2
HL
675 0xd1, 0x41, 0xb0, 0xf6, 0x0d, 0x8b, 0xbd, 0xe8, 0x5b, 0xa8, 0xff, 0xd7,
676 0x18, 0x9a, 0x23, 0x7b, 0x13, 0x5c, 0x1e, 0x90, 0x1d, 0x08, 0x95, 0xcc,
677 0xc5, 0x8e, 0x73, 0x4e, 0x02, 0x6f, 0x3c, 0xb6, 0x26, 0x77, 0x8d, 0x53,
678 0xc5, 0x62, 0x9f, 0xb5, 0xf0, 0x88, 0xfb, 0xe5, 0x14, 0x71, 0xab, 0xe6,
679};
680
19571483 681static const unsigned char rx_script_6_1rtt_secret[48] = {
ec279ac2
HL
682 0x2d, 0x6b, 0x9d, 0xd4, 0x39, 0xa0, 0xe7, 0xff, 0x17, 0xe2, 0xcb, 0x5c,
683 0x0d, 0x4a, 0xf6, 0x3f, 0xf4, 0xfe, 0xfc, 0xe5, 0x22, 0xfa, 0xf5, 0x5b,
684 0xc0, 0xb2, 0x18, 0xbb, 0x92, 0x4d, 0x35, 0xea, 0x67, 0xa6, 0xe7, 0xc1,
685 0x90, 0x10, 0xc9, 0x14, 0x46, 0xf5, 0x95, 0x57, 0x8b, 0x90, 0x88, 0x5d,
686};
687
19571483 688static const unsigned char rx_script_6_in[] = {
ec279ac2
HL
689 /* First Packet: Initial */
690 0xc5, /* Long, Initial, PN Length=2 bytes */
691 0x00, 0x00, 0x00, 0x01, /* Version */
692 0x00, /* DCID */
693 0x04, 0x36, 0xf4, 0x75, 0x2d, /* SCID */
694 0x00, /* Token Length */
695 0x41, 0xbe, /* Length (446) */
696 0xa9, 0xe2, /* PN (0) */
697 0x83, 0x39, 0x95, 0x8f, 0x8f, 0x8c, 0xa9, 0xaf, 0x10, 0x29, 0x3d, 0xfc,
698 0x56, 0x4a, 0x1c, 0x4b, 0xc9, 0x48, 0xb1, 0xaf, 0x36, 0xd5, 0xac, 0x95,
699 0xbf, 0xfd, 0x2c, 0x4d, 0x70, 0x2e, 0x5b, 0x7c, 0x22, 0x5f, 0x5f, 0xee,
700 0x10, 0x8f, 0xfb, 0x0b, 0x5f, 0x9d, 0x7e, 0x68, 0x2f, 0x94, 0x0b, 0xdb,
701 0xed, 0xef, 0xfa, 0x4e, 0xc6, 0xd5, 0xe7, 0xef, 0xe0, 0x78, 0x3c, 0xdc,
702 0xe9, 0xd8, 0xe8, 0x56, 0x71, 0xd7, 0xe7, 0x6c, 0x7f, 0x5d, 0xaa, 0x7a,
703 0x52, 0x1d, 0x95, 0x7a, 0x80, 0x70, 0x38, 0xc0, 0x8b, 0xa1, 0x2f, 0x09,
704 0x16, 0xd2, 0xec, 0xa3, 0x23, 0x72, 0x45, 0x3c, 0xbd, 0x8c, 0xda, 0xbb,
705 0x37, 0x5a, 0x8d, 0xb2, 0x00, 0x7e, 0x67, 0x0c, 0xa0, 0x32, 0xdd, 0x80,
706 0x07, 0x71, 0xb0, 0x95, 0x21, 0xbc, 0x1e, 0xbd, 0x63, 0x0a, 0x10, 0xe7,
707 0x4b, 0x6e, 0x2e, 0x85, 0x3a, 0x65, 0xf7, 0x06, 0x6e, 0x7e, 0x8f, 0x65,
708 0x8c, 0xb1, 0x93, 0xe9, 0x0d, 0xe8, 0x46, 0xe7, 0xcf, 0xa7, 0xd2, 0x8b,
709 0x15, 0x23, 0xec, 0xc3, 0xec, 0x44, 0xda, 0x62, 0x15, 0x35, 0x34, 0x2f,
710 0x62, 0x77, 0xc8, 0x1f, 0x83, 0x22, 0x00, 0xe5, 0xc0, 0x89, 0xb8, 0x97,
711 0xd2, 0x37, 0x02, 0xea, 0xa2, 0x35, 0xbf, 0x19, 0xf0, 0xba, 0x1d, 0xb7,
712 0xaa, 0x36, 0xbb, 0x11, 0x60, 0xc3, 0x45, 0x1f, 0xe5, 0x18, 0xde, 0x4c,
713 0x01, 0x23, 0x2d, 0x17, 0x78, 0xdd, 0x4c, 0x8a, 0x1e, 0x1b, 0xd4, 0xda,
714 0x56, 0x43, 0x13, 0xa4, 0x4f, 0xfd, 0xd5, 0x92, 0x6a, 0x05, 0x5f, 0x14,
715 0x63, 0x85, 0x7d, 0xf1, 0x31, 0xb8, 0x27, 0x0b, 0xa6, 0xb5, 0x50, 0xca,
716 0x8b, 0x0e, 0xa1, 0x0d, 0xf9, 0xc4, 0xea, 0x6a, 0x6e, 0x4b, 0x6d, 0xdf,
717 0x49, 0xe8, 0x32, 0xf6, 0x85, 0xc4, 0x29, 0x26, 0x32, 0xfb, 0x5e, 0xa8,
718 0x55, 0x6b, 0x67, 0xe9, 0xaa, 0x35, 0x33, 0x90, 0xd8, 0x2a, 0x71, 0x0b,
719 0x6a, 0x48, 0xc4, 0xa3, 0x8b, 0xe0, 0xe7, 0x00, 0x3d, 0xee, 0x30, 0x70,
720 0x84, 0xbd, 0xa3, 0x3c, 0x9e, 0xa3, 0x5c, 0x69, 0xab, 0x55, 0x7b, 0xe2,
721 0xe5, 0x86, 0x13, 0xcb, 0x93, 0x3f, 0xcb, 0x3e, 0x6d, 0xc9, 0xc2, 0x10,
722 0x2b, 0x00, 0x9b, 0x3f, 0x14, 0x4e, 0x04, 0x27, 0xc0, 0xae, 0x1d, 0x48,
723 0x89, 0x3a, 0xf4, 0xac, 0xe0, 0x05, 0x07, 0xc9, 0x74, 0x6e, 0x21, 0x01,
724 0xe9, 0x26, 0xfd, 0xb4, 0xb2, 0x2a, 0xda, 0x72, 0xda, 0xbf, 0x63, 0x9d,
725 0x37, 0xaf, 0x90, 0x05, 0xd6, 0x89, 0xc7, 0xa6, 0x81, 0x4e, 0x2a, 0x30,
726 0xe3, 0x05, 0x88, 0x9f, 0xd0, 0xba, 0x8d, 0xc4, 0x21, 0x52, 0x5a, 0x7a,
727 0xe1, 0xad, 0xd3, 0x88, 0xc2, 0x18, 0xad, 0x4c, 0xb1, 0x66, 0x73, 0x1b,
728 0xf2, 0xd1, 0xb9, 0x43, 0xaa, 0xc4, 0x66, 0xcd, 0x42, 0xfa, 0x80, 0xec,
729 0xa1, 0x7c, 0x45, 0x02, 0x53, 0x45, 0xd5, 0x07, 0xd4, 0x70, 0x12, 0x1b,
730 0x08, 0x05, 0x6e, 0x99, 0x0a, 0xd3, 0x5b, 0x99, 0x6b, 0x65, 0xc4, 0xc0,
731 0x04, 0x1b, 0x75, 0xf2, 0x86, 0x99, 0x09, 0x4a, 0x50, 0x70, 0x00, 0x7a,
732 0x93, 0xaa, 0xe6, 0xf4, 0x03, 0x29, 0x06, 0xa4, 0x30, 0x6d, 0x52, 0xbd,
733 0x60, 0xd1, 0x7e, 0xd6, 0x07, 0xc0, 0x41, 0x01, 0x12, 0x3e, 0x16, 0x94,
734
735 /* Second Packet: Handshake */
736 0xea, /* Long, Handshake, PN Length=2 bytes */
737 0x00, 0x00, 0x00, 0x01, /* Version */
738 0x00, /* DCID */
739 0x04, 0x36, 0xf4, 0x75, 0x2d, /* SCID */
740 0x42, 0xb0, /* Length (688) */
741 0x3a, 0xc5, /* PN (0) */
742 0x3b, 0x8e, 0x4c, 0x01, 0x72, 0x6b, 0xfa, 0xbb, 0xad, 0xf9, 0x9e, 0x21,
743 0xb1, 0xd0, 0x01, 0xf1, 0xd4, 0x67, 0x8d, 0x2c, 0xee, 0x04, 0x60, 0x4a,
744 0xe2, 0xe4, 0xc6, 0x89, 0x01, 0xae, 0x3c, 0x1f, 0xf7, 0xe6, 0xf7, 0xac,
745 0x26, 0xcf, 0x3c, 0x6d, 0x1d, 0xfd, 0x11, 0x02, 0x51, 0x73, 0xb5, 0xe1,
746 0xb2, 0x44, 0x42, 0x32, 0x0f, 0xf5, 0x3d, 0x55, 0x2d, 0x1f, 0x02, 0x29,
747 0x51, 0x35, 0xdb, 0xc7, 0x7a, 0x34, 0x4b, 0xec, 0x60, 0x49, 0xa2, 0x90,
748 0x11, 0xef, 0x5a, 0xa9, 0x1c, 0xf7, 0xd9, 0x21, 0x68, 0x1c, 0x2b, 0xc6,
749 0x57, 0xde, 0xb1, 0x0b, 0x31, 0xed, 0xef, 0x16, 0xba, 0x08, 0xb9, 0xe2,
750 0xd9, 0xd0, 0xd8, 0x1f, 0xc4, 0x32, 0xe8, 0x45, 0x2a, 0x86, 0xe4, 0xd3,
751 0xaf, 0x72, 0x4f, 0x30, 0x01, 0x71, 0x15, 0x9b, 0xa9, 0x55, 0x35, 0xf7,
752 0x39, 0x7e, 0x6a, 0x59, 0x18, 0x4f, 0xe6, 0xdf, 0xb5, 0x0d, 0xc2, 0xe7,
753 0xb2, 0xa1, 0xa6, 0xa3, 0x9c, 0xf0, 0x0d, 0x59, 0x05, 0x49, 0x95, 0xfa,
754 0xcc, 0x72, 0xd7, 0xc0, 0x84, 0x2e, 0xc4, 0x1c, 0xd4, 0xa0, 0xe3, 0x6c,
755 0x5a, 0x8c, 0x94, 0x4d, 0x37, 0x1a, 0x1c, 0x68, 0x93, 0x5f, 0xe5, 0x99,
756 0x27, 0xc6, 0x06, 0xaa, 0x1f, 0x29, 0x17, 0xc5, 0x8c, 0x3d, 0x53, 0xa7,
757 0x05, 0x3a, 0x44, 0x53, 0x86, 0xed, 0x56, 0x99, 0x4c, 0xe2, 0x7b, 0x3a,
758 0x1e, 0x5d, 0x6d, 0xac, 0x78, 0x1e, 0xfa, 0x55, 0x58, 0x6e, 0x72, 0xee,
759 0xf9, 0x33, 0x64, 0x7f, 0x93, 0x3c, 0xfe, 0x18, 0x97, 0x6b, 0x02, 0x74,
760 0x90, 0x0d, 0xba, 0x89, 0xc0, 0x22, 0x0a, 0x0a, 0x37, 0x4c, 0x28, 0x74,
761 0xa7, 0x3a, 0x44, 0x74, 0x42, 0xff, 0xf1, 0xd2, 0x8d, 0x0c, 0xc1, 0xed,
762 0x98, 0x98, 0x8e, 0xa8, 0x6b, 0x95, 0x6a, 0x86, 0x0b, 0xb4, 0x95, 0x58,
763 0x34, 0x12, 0xb0, 0xc0, 0xf8, 0x2d, 0x5b, 0x40, 0x51, 0x80, 0x07, 0x91,
764 0x31, 0x77, 0xd3, 0x06, 0xa5, 0xe5, 0x1f, 0xe2, 0xf8, 0x92, 0xe4, 0x23,
765 0x2b, 0xf0, 0x4c, 0xa9, 0xa5, 0x6c, 0x6f, 0xaf, 0xaf, 0xbf, 0x97, 0xcf,
766 0x46, 0xf2, 0x8d, 0x61, 0x0e, 0x73, 0xcd, 0xc5, 0xde, 0xda, 0x50, 0x82,
767 0x61, 0x6d, 0xb1, 0xa2, 0xbe, 0x6b, 0x99, 0xcd, 0x5b, 0x99, 0x8f, 0x66,
768 0xab, 0x11, 0x78, 0xcc, 0xdb, 0x66, 0x98, 0xca, 0x19, 0x92, 0xf4, 0x05,
769 0xae, 0xe6, 0xf3, 0xe7, 0xf0, 0x30, 0x28, 0x31, 0x74, 0xff, 0xe2, 0xb3,
770 0x3a, 0x4f, 0x79, 0xe7, 0x2a, 0x9f, 0xe3, 0x41, 0xb2, 0x88, 0xc8, 0x8f,
771 0x77, 0x57, 0x42, 0x65, 0xdb, 0x07, 0xf6, 0x5f, 0xb8, 0x34, 0x17, 0xe3,
772 0x8d, 0x22, 0x5b, 0x88, 0x94, 0x60, 0x97, 0x32, 0x3d, 0x8a, 0x51, 0x9d,
773 0xb5, 0xac, 0xd7, 0x99, 0x96, 0x23, 0x6d, 0xc9, 0xab, 0x61, 0x41, 0x8f,
774 0x72, 0x1b, 0xf8, 0x84, 0xd9, 0x57, 0x88, 0x68, 0x3d, 0x73, 0x5f, 0xb1,
775 0x18, 0x5c, 0x3a, 0x35, 0xd2, 0xc5, 0xb7, 0x29, 0xc7, 0x95, 0xdd, 0x21,
776 0xc0, 0x78, 0x49, 0xf3, 0x24, 0xe0, 0x4c, 0x5c, 0x32, 0x08, 0xb7, 0x00,
777 0x43, 0x70, 0x5a, 0x95, 0x23, 0x91, 0xf5, 0xb7, 0x61, 0x85, 0x6f, 0xb3,
778 0xa4, 0x6b, 0x05, 0x9d, 0x39, 0xa3, 0xb1, 0x1c, 0x61, 0xc5, 0xa5, 0xe7,
779 0x9a, 0xe9, 0x5d, 0xaa, 0xca, 0x11, 0xd8, 0x4b, 0xa4, 0x9c, 0x18, 0x4e,
780 0x2b, 0x2d, 0x75, 0xc1, 0x12, 0x20, 0xe4, 0x66, 0xa5, 0x59, 0x67, 0x4b,
781 0xcc, 0x52, 0x2d, 0xfa, 0xaa, 0xa4, 0xe9, 0xfc, 0x79, 0xd7, 0xff, 0x03,
782 0x3e, 0xec, 0xba, 0x97, 0x37, 0x52, 0xc1, 0x57, 0x31, 0x8e, 0x57, 0x0c,
783 0x54, 0x92, 0x9c, 0x25, 0x5c, 0xfa, 0x9f, 0xa5, 0x36, 0x18, 0xd0, 0xaa,
784 0xf3, 0x3b, 0x5b, 0x59, 0xbd, 0x33, 0x5e, 0x7d, 0x74, 0x7c, 0xaf, 0xe9,
785 0x54, 0x80, 0xc4, 0xb4, 0xa1, 0x24, 0x9e, 0x23, 0x0d, 0xbf, 0x4e, 0x0f,
786 0xaf, 0xa5, 0x16, 0xcb, 0x3b, 0xfa, 0x33, 0xa5, 0x68, 0xa6, 0x64, 0x48,
787 0x2f, 0x5e, 0xfa, 0x64, 0x4e, 0xe3, 0x27, 0x4f, 0x13, 0xe6, 0x37, 0xf6,
788 0xb9, 0x63, 0x4b, 0xdc, 0x49, 0x3c, 0x5e, 0x9e, 0x06, 0xea, 0xac, 0xa3,
789 0xdf, 0x6c, 0x49, 0xfb, 0xa1, 0x01, 0x4f, 0x6f, 0x74, 0x1f, 0xd3, 0x26,
790 0xa1, 0x92, 0x3e, 0xe0, 0x73, 0xd6, 0x3b, 0x67, 0x13, 0x53, 0x2e, 0xcb,
791 0xbc, 0x83, 0xd0, 0x6e, 0x28, 0xb1, 0xcb, 0xd9, 0x66, 0xe0, 0x33, 0x59,
792 0x45, 0xd3, 0x13, 0xc2, 0x48, 0xd5, 0x9e, 0x88, 0xba, 0x75, 0x7b, 0xb1,
793 0xfe, 0x6f, 0xec, 0xde, 0xff, 0x14, 0x59, 0x75, 0xbf, 0x1a, 0x74, 0x47,
794 0xc5, 0xd8, 0xe8, 0x1b, 0x3c, 0x86, 0xd7, 0x1f, 0x99, 0x11, 0xd3, 0x29,
795 0xfd, 0x5d, 0x22, 0x7e, 0x03, 0x78, 0xed, 0x62, 0x0e, 0xbe, 0x6d, 0x75,
796 0xf4, 0xa8, 0x6e, 0xc7, 0x21, 0x76, 0xc5, 0xa0, 0x0c, 0xaa, 0x58, 0x78,
797 0x7e, 0x6e, 0xfc, 0x1e, 0x2a, 0x1c, 0xdd, 0xe5, 0x78, 0x08, 0xbd, 0xdb,
798 0xea, 0x8f, 0x8a, 0xa5, 0xbf, 0x93, 0xfe, 0x0f, 0x03, 0xa1, 0xc8, 0x64,
799 0x9f, 0x4a,
800
801 /* Third Packet: 1-RTT */
802 0x48, /* Short, 1-RTT, Spin=0, KP=0, PN Length=2 bytes */
803 0x3e, 0x28, /* PN (0) */
804 0xb9, 0xdb, 0x61, 0xf8, 0x8b, 0x3a, 0xef, 0x26, 0x69, 0xf2, 0x57, 0xc6,
805 0x84, 0x25, 0x6b, 0x77, 0xbe, 0x8c, 0x43, 0x32, 0xf3, 0x9a, 0xd1, 0x85,
806 0x14, 0xbc, 0x89, 0x3b, 0x9c, 0xf3, 0xfc, 0x00, 0xa1, 0x3a, 0xc3, 0xc4,
807 0x1e, 0xdf, 0xd0, 0x11, 0x70, 0xd9, 0x02, 0x7a, 0xd4, 0xef, 0x86, 0x67,
808 0xb1, 0x1e, 0x5d, 0xe3, 0x7f, 0x82, 0x14, 0x52, 0xa5, 0x8a, 0x89, 0xa7,
809 0x98, 0x75, 0x2f, 0x8a, 0x00, 0xf3, 0xbd, 0x49, 0x26, 0x4d, 0x0c, 0xc7,
810 0x38, 0xe7, 0x91, 0x85, 0xc9, 0x21, 0x6a, 0x1c, 0xc4, 0xa3, 0x0e, 0xd8,
811 0xfe, 0xb1, 0x25, 0x1a,
812};
813
19571483 814static const QUIC_PKT_HDR rx_script_6a_expect_hdr = {
ec279ac2
HL
815 QUIC_PKT_TYPE_INITIAL,
816 0, /* Spin Bit */
817 0, /* Key Phase */
818 2, /* PN Length */
819 0, /* Partial */
820 1, /* Fixed */
821 1, /* Version */
822 {0, {0}}, /* DCID */
823 {4, {0x36, 0xf4, 0x75, 0x2d}}, /* SCID */
824 {0}, /* PN */
825 NULL, 0, /* Token/Token Len */
826 428, NULL
827};
828
19571483 829static const unsigned char rx_script_6a_body[] = {
ec279ac2
HL
830 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
831 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
832 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
833 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
834 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
835 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
836 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
837 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
838 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
839 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
840 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
841 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
842 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
843 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
844 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
845 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
846 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
847 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
848 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
849 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
850 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
851 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
852 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
853 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
854 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
855 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
856 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
857 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00,
858 0x40, 0x5a, 0x02, 0x00, 0x00, 0x56, 0x03, 0x03, 0xc3, 0x45, 0xe8, 0xb8,
859 0xf9, 0x7c, 0x9f, 0x5d, 0xcf, 0x66, 0x25, 0xe4, 0x91, 0x0e, 0xb0, 0x5a,
860 0x14, 0xce, 0xaf, 0xea, 0x83, 0x12, 0xde, 0x68, 0xd9, 0x31, 0xf2, 0x23,
861 0x11, 0x3a, 0x15, 0xcb, 0x00, 0x13, 0x02, 0x00, 0x00, 0x2e, 0x00, 0x2b,
862 0x00, 0x02, 0x03, 0x04, 0x00, 0x33, 0x00, 0x24, 0x00, 0x1d, 0x00, 0x20,
863 0xab, 0xd3, 0xc6, 0x9f, 0x36, 0xd3, 0x52, 0x93, 0x87, 0xee, 0x92, 0x01,
864 0xa2, 0xd6, 0x9a, 0x5e, 0x61, 0x43, 0xcc, 0x4a, 0xcc, 0x7a, 0xcd, 0x83,
865 0xb2, 0xd9, 0xad, 0xd1, 0x14, 0xdc, 0x84, 0x61,
866};
867
19571483 868static const QUIC_PKT_HDR rx_script_6b_expect_hdr = {
ec279ac2
HL
869 QUIC_PKT_TYPE_HANDSHAKE,
870 0, /* Spin Bit */
871 0, /* Key Phase */
872 2, /* PN Length */
873 0, /* Partial */
874 1, /* Fixed */
875 1, /* Version */
876 {0, {0}}, /* DCID */
877 {4, {0x36, 0xf4, 0x75, 0x2d}}, /* SCID */
878 {0}, /* PN */
879 NULL, 0, /* Token/Token Len */
880 670, NULL
881};
882
19571483 883static const unsigned char rx_script_6b_body[] = {
ec279ac2
HL
884 0x06, 0x00, 0x42, 0x9a, 0x08, 0x00, 0x00, 0x80, 0x00, 0x7e, 0x00, 0x10,
885 0x00, 0x08, 0x00, 0x06, 0x05, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x00, 0x39,
886 0x00, 0x6e, 0x47, 0xfa, 0x05, 0x5a, 0xe0, 0xec, 0x4a, 0xf3, 0x05, 0x04,
887 0x80, 0x08, 0x00, 0x00, 0x06, 0x04, 0x80, 0x08, 0x00, 0x00, 0x07, 0x04,
888 0x80, 0x08, 0x00, 0x00, 0x04, 0x04, 0x80, 0x0c, 0x00, 0x00, 0x08, 0x02,
889 0x40, 0x64, 0x09, 0x02, 0x40, 0x64, 0x01, 0x04, 0x80, 0x00, 0x75, 0x30,
890 0x03, 0x02, 0x45, 0xac, 0x0b, 0x01, 0x1a, 0x0c, 0x00, 0x02, 0x10, 0x35,
891 0xd7, 0x7d, 0x8b, 0xc5, 0xb1, 0x89, 0xb1, 0x5c, 0x23, 0x74, 0x50, 0xfd,
892 0x47, 0xfe, 0xd2, 0x00, 0x11, 0x96, 0x38, 0x27, 0xde, 0x7d, 0xfb, 0x2b,
893 0x38, 0x56, 0xe5, 0x2a, 0xb8, 0x6b, 0xfa, 0xaa, 0xde, 0x81, 0x0e, 0x01,
894 0x04, 0x0f, 0x04, 0x36, 0xf4, 0x75, 0x2d, 0x10, 0x04, 0xac, 0x88, 0x95,
895 0xbd, 0x20, 0x01, 0x00, 0x0b, 0x00, 0x01, 0x8f, 0x00, 0x00, 0x01, 0x8b,
896 0x00, 0x01, 0x86, 0x30, 0x82, 0x01, 0x82, 0x30, 0x82, 0x01, 0x29, 0xa0,
897 0x03, 0x02, 0x01, 0x02, 0x02, 0x14, 0x0a, 0x73, 0x0f, 0x86, 0x18, 0xf2,
898 0xc3, 0x30, 0x01, 0xd2, 0xc0, 0xc1, 0x62, 0x52, 0x13, 0xf1, 0x9c, 0x13,
899 0x39, 0xb5, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04,
900 0x03, 0x02, 0x30, 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04,
901 0x03, 0x0c, 0x0c, 0x6d, 0x61, 0x70, 0x61, 0x6b, 0x74, 0x2e, 0x6c, 0x6f,
902 0x63, 0x61, 0x6c, 0x30, 0x1e, 0x17, 0x0d, 0x32, 0x32, 0x30, 0x38, 0x30,
903 0x32, 0x31, 0x32, 0x30, 0x30, 0x31, 0x38, 0x5a, 0x17, 0x0d, 0x32, 0x32,
904 0x30, 0x39, 0x30, 0x31, 0x31, 0x32, 0x30, 0x30, 0x31, 0x38, 0x5a, 0x30,
905 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0c,
906 0x6d, 0x61, 0x70, 0x61, 0x6b, 0x74, 0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
907 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02,
908 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03,
909 0x42, 0x00, 0x04, 0x67, 0xf4, 0xd3, 0x8f, 0x15, 0x6d, 0xee, 0x85, 0xcc,
910 0x2a, 0x77, 0xfc, 0x0b, 0x8f, 0x9f, 0xcf, 0xa9, 0x95, 0x5d, 0x5b, 0xcd,
911 0xb7, 0x8b, 0xba, 0x31, 0x0a, 0x73, 0x62, 0xc5, 0xd0, 0x0e, 0x07, 0x90,
912 0xae, 0x38, 0x43, 0x79, 0xce, 0x5e, 0x33, 0xad, 0x31, 0xbf, 0x9f, 0x2a,
913 0x56, 0x83, 0xa5, 0x24, 0x16, 0xab, 0x0c, 0xf1, 0x64, 0xbe, 0xe4, 0x93,
914 0xb5, 0x89, 0xd6, 0x05, 0xe4, 0xf7, 0x7b, 0xa3, 0x53, 0x30, 0x51, 0x30,
915 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x02, 0x64,
916 0x0f, 0x55, 0x69, 0x14, 0x91, 0x19, 0xed, 0xf9, 0x1a, 0xe9, 0x1d, 0xa5,
917 0x5a, 0xd0, 0x48, 0x96, 0x9f, 0x60, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d,
918 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0x02, 0x64, 0x0f, 0x55, 0x69,
919 0x14, 0x91, 0x19, 0xed, 0xf9, 0x1a, 0xe9, 0x1d, 0xa5, 0x5a, 0xd0, 0x48,
920 0x96, 0x9f, 0x60, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01,
921 0xff, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0a, 0x06, 0x08,
922 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x47, 0x00, 0x30,
923 0x44, 0x02, 0x20, 0x0a, 0x82, 0x92, 0x6e, 0xd3, 0xc6, 0x66, 0xd9, 0xd3,
924 0x75, 0xff, 0x71, 0x3b, 0x61, 0x46, 0x21, 0x00, 0xe6, 0x21, 0x5d, 0x9c,
925 0x86, 0xe9, 0x65, 0x40, 0x4f, 0xeb, 0x70, 0x4f, 0x2c, 0xad, 0x00, 0x02,
926 0x20, 0x08, 0xc2, 0x07, 0x5d, 0x16, 0xfc, 0x54, 0x34, 0x2b, 0xb4, 0x18,
927 0x67, 0x44, 0x81, 0xc9, 0xa9, 0x67, 0x2e, 0xce, 0xa1, 0x02, 0x9f, 0x3b,
928 0xe5, 0x61, 0x16, 0x0b, 0x50, 0xf6, 0xa1, 0x50, 0x94, 0x00, 0x00, 0x0f,
929 0x00, 0x00, 0x4b, 0x04, 0x03, 0x00, 0x47, 0x30, 0x45, 0x02, 0x20, 0x78,
930 0x9e, 0xe0, 0x6a, 0x7a, 0xbd, 0xc3, 0x84, 0x3d, 0x25, 0x6a, 0x59, 0x23,
931 0x97, 0x52, 0x64, 0x4e, 0xb6, 0x9f, 0xcc, 0xd3, 0xd7, 0xa9, 0x29, 0x44,
932 0x75, 0x6d, 0x50, 0xfc, 0x22, 0xde, 0xd3, 0x02, 0x21, 0x00, 0xe5, 0x28,
933 0xd6, 0x5a, 0xd1, 0xec, 0x4a, 0xcc, 0x20, 0xb4, 0xea, 0x15, 0xfb, 0x8e,
934 0x73, 0xa8, 0x6b, 0xbb, 0x42, 0x70, 0x90, 0x08, 0x6e, 0x74, 0x6f, 0x5a,
935 0x05, 0xb5, 0x39, 0xee, 0x01, 0x04, 0x14, 0x00, 0x00, 0x30, 0xff, 0x9f,
936 0xb2, 0x1d, 0xcb, 0x4f, 0xfc, 0x7a, 0xac, 0xf4, 0x75, 0x24, 0x83, 0x5f,
937 0x8d, 0xa3, 0x3e, 0x9d, 0xef, 0x43, 0x67, 0x89, 0x5d, 0x55, 0xc7, 0xce,
938 0x80, 0xab, 0xc3, 0xc7, 0x74, 0xc7, 0xb2, 0x91, 0x27, 0xce, 0xd8, 0x5e,
939 0xc4, 0x4e, 0x96, 0x19, 0x68, 0x2d, 0xbe, 0x6f, 0x49, 0xfa,
940};
941
19571483 942static const QUIC_PKT_HDR rx_script_6c_expect_hdr = {
ec279ac2
HL
943 QUIC_PKT_TYPE_1RTT,
944 0, /* Spin Bit */
945 0, /* Key Phase */
946 2, /* PN Length */
947 0, /* Partial */
948 1, /* Fixed */
949 0, /* Version */
950 {0, {0}}, /* DCID */
951 {0, {0}}, /* SCID */
952 {0}, /* PN */
953 NULL, 0, /* Token/Token Len */
954 72, NULL
955};
956
19571483 957static const unsigned char rx_script_6c_body[] = {
ec279ac2
HL
958 0x18, 0x03, 0x00, 0x04, 0xf2, 0x94, 0x49, 0xc3, 0x34, 0xa1, 0xf4, 0x0f,
959 0xcb, 0xb8, 0x03, 0x04, 0x1f, 0xc8, 0x69, 0xb9, 0x3b, 0xd5, 0xc6, 0x93,
960 0x18, 0x02, 0x00, 0x04, 0x9a, 0x4f, 0xec, 0x52, 0xde, 0xd2, 0xc8, 0xb7,
961 0x1c, 0x0c, 0xf3, 0x4e, 0x46, 0xf0, 0x6c, 0x54, 0x34, 0x1b, 0x0d, 0x98,
962 0x18, 0x01, 0x00, 0x04, 0xe3, 0x33, 0x9e, 0x59, 0x00, 0x69, 0xc3, 0xac,
963 0xfc, 0x58, 0x0e, 0xa4, 0xf4, 0xf3, 0x23, 0x1b, 0xd6, 0x8e, 0x5b, 0x08,
964};
965
19571483
HL
966static const struct rx_test_op rx_script_6[] = {
967 RX_OP_ADD_RX_DCID(empty_conn_id)
968 RX_OP_PROVIDE_SECRET_INITIAL(rx_script_6_c2s_init_dcid)
969 RX_OP_INJECT_N(6)
ecc920b3 970 RX_OP_CHECK_PKT_FRAMES_OK_N(6a)
19571483
HL
971 RX_OP_CHECK_NO_PKT() /* not got secret for next packet yet */
972 RX_OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_HANDSHAKE,
973 QRL_SUITE_AES256GCM, rx_script_6_handshake_secret)
ecc920b3 974 RX_OP_CHECK_PKT_FRAMES_OK_N(6b)
19571483
HL
975 RX_OP_CHECK_NO_PKT() /* not got secret for next packet yet */
976 RX_OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT,
977 QRL_SUITE_AES256GCM, rx_script_6_1rtt_secret)
ecc920b3 978 RX_OP_CHECK_PKT_FRAMES_OK_N(6c)
19571483 979 RX_OP_CHECK_NO_PKT()
ec279ac2
HL
980
981 /* Try injecting the packet again */
19571483 982 RX_OP_INJECT_N(6)
ec279ac2
HL
983 /*
984 * Initial packet is not output due to receiving a Handshake packet causing
985 * auto-discard of Initial keys
986 */
ecc920b3
RL
987 RX_OP_CHECK_PKT_FRAMES_OK_N(6b)
988 RX_OP_CHECK_PKT_FRAMES_OK_N(6c)
19571483 989 RX_OP_CHECK_NO_PKT()
ec279ac2 990 /* Try again with discarded keys */
19571483
HL
991 RX_OP_DISCARD_EL(QUIC_ENC_LEVEL_HANDSHAKE)
992 RX_OP_INJECT_N(6)
ecc920b3 993 RX_OP_CHECK_PKT_FRAMES_OK_N(6c)
19571483 994 RX_OP_CHECK_NO_PKT()
ec279ac2 995 /* Try again */
19571483 996 RX_OP_INJECT_N(6)
ecc920b3 997 RX_OP_CHECK_PKT_FRAMES_OK_N(6c)
19571483 998 RX_OP_CHECK_NO_PKT()
ec279ac2 999 /* Try again with discarded 1-RTT keys */
19571483
HL
1000 RX_OP_DISCARD_EL(QUIC_ENC_LEVEL_1RTT)
1001 RX_OP_INJECT_N(6)
1002 RX_OP_CHECK_NO_PKT()
ec279ac2
HL
1003
1004 /* Recreate QRL, test reading packets received before key */
19571483
HL
1005 RX_OP_SET_SCID_LEN(0)
1006 RX_OP_ADD_RX_DCID(empty_conn_id)
1007 RX_OP_INJECT_N(6)
1008 RX_OP_CHECK_NO_PKT()
1009 RX_OP_PROVIDE_SECRET_INITIAL(rx_script_6_c2s_init_dcid)
ecc920b3 1010 RX_OP_CHECK_PKT_FRAMES_OK_N(6a)
19571483
HL
1011 RX_OP_CHECK_NO_PKT()
1012 RX_OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_HANDSHAKE,
1013 QRL_SUITE_AES256GCM, rx_script_6_handshake_secret)
ecc920b3 1014 RX_OP_CHECK_PKT_FRAMES_OK_N(6b)
19571483
HL
1015 RX_OP_CHECK_NO_PKT()
1016 RX_OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT,
1017 QRL_SUITE_AES256GCM, rx_script_6_1rtt_secret)
ecc920b3 1018 RX_OP_CHECK_PKT_FRAMES_OK_N(6c)
19571483
HL
1019 RX_OP_CHECK_NO_PKT()
1020
1021 RX_OP_END
ec279ac2
HL
1022};
1023
1024/*
1025 * 7. Real World - S2C Multiple Packets
1026 * - Initial, Handshake, 1-RTT (ChaCha20-Poly1305)
1027 */
681c4619 1028#ifndef OPENSSL_NO_CHACHA
19571483 1029static const QUIC_CONN_ID rx_script_7_c2s_init_dcid = {
ec279ac2
HL
1030 4, {0xfa, 0x5d, 0xd6, 0x80}
1031};
1032
19571483 1033static const unsigned char rx_script_7_handshake_secret[32] = {
ec279ac2
HL
1034 0x85, 0x44, 0xa4, 0x02, 0x46, 0x5b, 0x2a, 0x92, 0x80, 0x71, 0xfd, 0x11,
1035 0x89, 0x73, 0x84, 0xeb, 0x3e, 0x0d, 0x89, 0x4f, 0x71, 0xdc, 0x9c, 0xdd,
1036 0x55, 0x77, 0x9e, 0x79, 0x7b, 0xeb, 0xfa, 0x86,
1037};
1038
19571483 1039static const unsigned char rx_script_7_1rtt_secret[32] = {
ec279ac2
HL
1040 0x4a, 0x77, 0xb6, 0x0e, 0xfd, 0x90, 0xca, 0xbf, 0xc0, 0x1a, 0x64, 0x9f,
1041 0xc0, 0x03, 0xd3, 0x8d, 0xc5, 0x41, 0x04, 0x50, 0xb1, 0x5b, 0x74, 0xe7,
1042 0xe3, 0x99, 0x0c, 0xdf, 0x74, 0x61, 0x35, 0xe6,
1043};
1044
19571483 1045static const unsigned char rx_script_7_in[] = {
ec279ac2
HL
1046 /* First Packet: Initial */
1047 0xc2, /* Long, Initial, PN Length=2 bytes */
1048 0x00, 0x00, 0x00, 0x01, /* Version */
1049 0x00, /* DCID */
1050 0x04, 0x03, 0x45, 0x0c, 0x7a, /* SCID */
1051 0x00, /* Token Length */
1052 0x41, 0xcb, /* Length (459) */
1053 0x3c, 0xe0, /* PN (0) */
1054 0x85, 0x05, 0xc2, 0x4d, 0x0f, 0xf3, 0x62, 0x51, 0x04, 0x33, 0xfa, 0xb5,
1055 0xa3, 0x02, 0xbd, 0x5c, 0x22, 0x0c, 0x1d, 0xda, 0x06, 0xf1, 0xd7, 0xe0,
1056 0xc8, 0x56, 0xb0, 0x3d, 0xc1, 0x49, 0x8c, 0xc2, 0x88, 0x5a, 0x0e, 0xd5,
1057 0x67, 0x72, 0xec, 0xcc, 0x7a, 0x2b, 0x46, 0x17, 0x49, 0x4b, 0x28, 0x6a,
1058 0x89, 0x71, 0xfd, 0x31, 0x9a, 0xa1, 0x97, 0x64, 0xe2, 0xbf, 0xa0, 0x6d,
1059 0xf6, 0x76, 0x83, 0x28, 0xc4, 0xd5, 0x39, 0x87, 0x22, 0x7c, 0x11, 0x9a,
1060 0x53, 0x66, 0xb4, 0x27, 0xf1, 0xab, 0x6f, 0x49, 0x43, 0x3f, 0x9a, 0x23,
1061 0xd3, 0x53, 0x06, 0xe8, 0x14, 0xfd, 0xc0, 0x67, 0x1f, 0x88, 0x2a, 0xa8,
1062 0xae, 0x5f, 0x05, 0x0a, 0xeb, 0x66, 0x72, 0x8c, 0x46, 0xcc, 0x54, 0x21,
1063 0x5e, 0x14, 0xfe, 0x68, 0xc7, 0xf7, 0x60, 0x67, 0xb5, 0xa7, 0x0d, 0xf4,
1064 0xe1, 0xff, 0x60, 0xe3, 0x11, 0x38, 0x92, 0x90, 0xc2, 0x48, 0x28, 0xbf,
1065 0xf3, 0x85, 0x27, 0xfe, 0xbf, 0x42, 0x26, 0x1a, 0x4e, 0x78, 0xf1, 0xf0,
1066 0x88, 0x16, 0x1b, 0x64, 0x5f, 0x66, 0x02, 0x0b, 0x45, 0x3d, 0x38, 0xd9,
1067 0x09, 0xd5, 0xff, 0xc2, 0x68, 0x02, 0x2c, 0xc4, 0x3f, 0x60, 0x6e, 0x2f,
1068 0x7f, 0x43, 0xf7, 0x1a, 0x37, 0xcc, 0xe0, 0xe0, 0x4b, 0x96, 0xc1, 0xb1,
1069 0x8b, 0x1c, 0x7c, 0x6e, 0x80, 0xe3, 0x92, 0x9b, 0x86, 0x87, 0x1f, 0x9a,
1070 0x6a, 0x62, 0x18, 0xf4, 0x86, 0xc2, 0x3e, 0x33, 0xa3, 0xbf, 0x43, 0x96,
1071 0x6e, 0xff, 0x94, 0xaf, 0x6d, 0x23, 0x5c, 0x42, 0xed, 0xe7, 0xb9, 0x2c,
1072 0x33, 0xb0, 0xc6, 0x3d, 0x44, 0x00, 0x0b, 0xa3, 0x39, 0xa8, 0xeb, 0x8c,
1073 0x81, 0x1a, 0x99, 0x20, 0xbd, 0xfa, 0xf3, 0xf4, 0xf0, 0x11, 0xd8, 0x41,
1074 0x31, 0x8d, 0xdc, 0x0d, 0x00, 0xa6, 0x31, 0x40, 0xc6, 0xc6, 0xad, 0x74,
1075 0x93, 0x62, 0x1c, 0x55, 0xce, 0x5f, 0x8c, 0x5b, 0x3c, 0xcb, 0x25, 0x5e,
1076 0xbf, 0xed, 0xbb, 0x3c, 0x97, 0x4b, 0x62, 0xe0, 0xba, 0xf1, 0xb0, 0x30,
1077 0xbf, 0x35, 0x89, 0x7e, 0x25, 0x61, 0x54, 0x86, 0x52, 0x11, 0x86, 0x90,
1078 0xc3, 0xf5, 0xad, 0xa0, 0x96, 0x30, 0xb2, 0xf0, 0xa6, 0x79, 0x39, 0x1c,
1079 0x51, 0x42, 0xa1, 0x00, 0x6f, 0x55, 0x7d, 0xdc, 0xd0, 0x7c, 0xcf, 0x01,
1080 0x88, 0x03, 0xd7, 0x2d, 0x65, 0x2b, 0x40, 0xee, 0xba, 0x10, 0xd8, 0x0c,
1081 0x85, 0x14, 0xb7, 0x4d, 0x9e, 0x7d, 0x7c, 0xde, 0x7f, 0x0d, 0x0e, 0x3b,
1082 0x3d, 0xe3, 0xd3, 0x63, 0xc2, 0xed, 0xc7, 0x41, 0xaf, 0x05, 0x85, 0x87,
1083 0x46, 0x55, 0x7e, 0xbe, 0x14, 0x5b, 0x98, 0xae, 0x6e, 0x67, 0x1a, 0x65,
1084 0xc6, 0xcf, 0xe1, 0x28, 0x50, 0x6b, 0xb4, 0xf6, 0xba, 0x63, 0xbc, 0xf1,
1085 0xd7, 0xa4, 0x97, 0x2d, 0x4d, 0x04, 0x26, 0x96, 0xec, 0x0c, 0xd4, 0xae,
1086 0x6a, 0xca, 0x7e, 0x65, 0xc5, 0x43, 0x7e, 0xf8, 0x77, 0x61, 0xd0, 0x2c,
1087 0xe5, 0x37, 0x0a, 0xb3, 0x7a, 0x8c, 0x2a, 0xa1, 0xdc, 0x29, 0xdb, 0xec,
1088 0xca, 0xdc, 0xfe, 0xdd, 0x38, 0xd2, 0x13, 0x9f, 0x94, 0x6d, 0x5b, 0x87,
1089 0xf3, 0x15, 0xa8, 0xe5, 0xe9, 0x65, 0x1d, 0x4f, 0x92, 0x1b, 0xf4, 0xa6,
1090 0xa4, 0xd6, 0x22, 0xfc, 0x26, 0x1b, 0x35, 0xa4, 0x1c, 0x88, 0x9f, 0x7d,
1091 0xe0, 0x9a, 0x89, 0x0f, 0x6c, 0xc1, 0xda, 0x6e, 0x45, 0xce, 0x74, 0xb1,
1092 0xff,
1093
1094 /* Second Packet: Handshake */
1095 0xeb, /* Long, Handshake, PN Length=2 bytes */
1096 0x00, 0x00, 0x00, 0x01, /* Version */
1097 0x00, /* DCID */
1098 0x04, 0x03, 0x45, 0x0c, 0x7a, /* SCID */
1099 0x42, 0xa3, /* Length (675) */
1100 0x43, 0x29, /* PN (0) */
1101 0xff, 0xdb, 0xcf, 0x3c, 0x17, 0xcf, 0xdc, 0x42, 0x3a, 0x59, 0x88, 0xdb,
1102 0x13, 0xef, 0x09, 0x3d, 0xf2, 0x24, 0xf3, 0xeb, 0xca, 0xb0, 0xe1, 0xa4,
1103 0x67, 0x64, 0x65, 0x80, 0x5f, 0x73, 0x29, 0x69, 0x29, 0xba, 0x03, 0x77,
1104 0x22, 0xc8, 0xa8, 0xd5, 0x21, 0xf2, 0xa2, 0x30, 0x7f, 0x86, 0x3a, 0x8a,
1105 0xdd, 0x92, 0x33, 0xa6, 0x57, 0x21, 0x39, 0xdd, 0x34, 0xb4, 0x39, 0xa7,
1106 0x6f, 0x0a, 0x14, 0xba, 0x9e, 0x3b, 0x3a, 0x6a, 0x4b, 0xc5, 0xda, 0x44,
1107 0x82, 0xca, 0x52, 0x86, 0x68, 0x8a, 0x0c, 0x5e, 0xeb, 0x1e, 0x81, 0x43,
1108 0x3a, 0x59, 0x2c, 0x26, 0x63, 0xa3, 0x89, 0x92, 0x80, 0xe9, 0x75, 0xc2,
1109 0xdb, 0xb9, 0x58, 0x6d, 0xab, 0xfd, 0x21, 0xe0, 0x35, 0x79, 0x2e, 0x56,
1110 0x7b, 0xfb, 0xb3, 0x7a, 0x05, 0x33, 0x0f, 0x13, 0xe5, 0xef, 0x04, 0x41,
1111 0x69, 0x85, 0x91, 0x24, 0xce, 0xb5, 0x21, 0x8d, 0x0a, 0x13, 0xda, 0xae,
1112 0x86, 0x2f, 0x25, 0x1f, 0x9c, 0x70, 0x8a, 0xaa, 0x05, 0xeb, 0x30, 0x93,
1113 0x50, 0xc1, 0x39, 0xab, 0x99, 0x8a, 0x31, 0xc1, 0xc1, 0x5e, 0x39, 0xcf,
1114 0x64, 0x3f, 0x9f, 0x5c, 0xa5, 0xa1, 0x88, 0xb2, 0x5f, 0x23, 0xcb, 0x76,
1115 0xe5, 0xf3, 0x2d, 0xa0, 0xed, 0xad, 0xcf, 0x30, 0x05, 0x44, 0xdc, 0xa5,
1116 0x81, 0xb1, 0x7f, 0x78, 0x0d, 0x4d, 0x96, 0xa3, 0xcb, 0xcb, 0x45, 0xcf,
1117 0x5f, 0x22, 0xb8, 0x93, 0x2b, 0x16, 0xe0, 0x1c, 0x53, 0x34, 0x76, 0x3b,
1118 0x7b, 0x78, 0xa1, 0x46, 0x40, 0x43, 0x4b, 0x0e, 0x1c, 0xfd, 0xcf, 0x01,
1119 0xf1, 0x2c, 0xee, 0xd0, 0xbd, 0x9f, 0x44, 0xd2, 0xd7, 0x13, 0xf9, 0x65,
1120 0x82, 0xf5, 0x42, 0xec, 0x9f, 0x5d, 0x51, 0x5a, 0x7b, 0xf2, 0x39, 0xbb,
1121 0xa6, 0x19, 0x5c, 0x73, 0x95, 0x65, 0x5b, 0x64, 0x2f, 0xda, 0x50, 0xd0,
1122 0x02, 0x34, 0x3f, 0x35, 0xc1, 0xd6, 0x31, 0x3b, 0xcf, 0x3f, 0x81, 0x8d,
1123 0xe0, 0x40, 0xfd, 0x6d, 0x32, 0x68, 0xa4, 0xf2, 0x4e, 0x3a, 0x4a, 0x42,
1124 0x2c, 0x07, 0x2d, 0x27, 0xa3, 0x34, 0xe7, 0x27, 0x87, 0x80, 0x76, 0xc0,
1125 0xa0, 0x72, 0x05, 0xf2, 0x88, 0x81, 0xe3, 0x32, 0x00, 0x76, 0x8d, 0x24,
1126 0x5c, 0x97, 0x2d, 0xd6, 0xb8, 0x34, 0xf8, 0x1c, 0x1a, 0x6d, 0xc7, 0x3f,
1127 0xcf, 0x56, 0xae, 0xec, 0x26, 0x74, 0x53, 0x69, 0xcd, 0x7a, 0x97, 0x29,
1128 0xab, 0x12, 0x7d, 0x75, 0xf8, 0x8d, 0x5b, 0xc0, 0x77, 0x20, 0xb6, 0x6a,
1129 0x0b, 0xce, 0x98, 0x50, 0xca, 0x47, 0x42, 0x1e, 0x5d, 0xc3, 0x24, 0x5a,
1130 0x47, 0x48, 0x3b, 0xa0, 0x9e, 0x43, 0xe9, 0x8d, 0x18, 0x23, 0xda, 0x6f,
1131 0x8c, 0xda, 0xd0, 0x3e, 0xdb, 0x37, 0xff, 0xfc, 0x7e, 0x17, 0xbe, 0x42,
1132 0xfd, 0xdb, 0x51, 0xb1, 0xa4, 0xfd, 0x9a, 0x20, 0x27, 0x24, 0x17, 0x04,
1133 0x70, 0xb6, 0x21, 0x87, 0x88, 0xe9, 0xda, 0x63, 0xcb, 0xcb, 0x1d, 0xaf,
1134 0x4a, 0x46, 0x76, 0x88, 0xa1, 0xf8, 0x48, 0x6c, 0x06, 0xb4, 0x62, 0x1a,
1135 0x67, 0x18, 0xb0, 0x1d, 0x58, 0x6a, 0xfe, 0x1f, 0xf1, 0x48, 0xff, 0xcb,
1136 0xa4, 0xd1, 0xa8, 0x12, 0x1f, 0x45, 0x94, 0x2f, 0x55, 0x80, 0x6a, 0x06,
1137 0xcc, 0x7b, 0xb0, 0xcc, 0xb8, 0x06, 0x52, 0x16, 0xe3, 0x6e, 0x7e, 0xb0,
1138 0x42, 0xfd, 0x3b, 0x7e, 0x0a, 0x42, 0x7b, 0x73, 0xaf, 0x2c, 0xf3, 0xbd,
1139 0xe5, 0x72, 0x8c, 0x16, 0xb2, 0xd7, 0x7a, 0x11, 0xb6, 0x9f, 0xd1, 0x69,
1140 0xc1, 0x1a, 0xe0, 0x26, 0x26, 0x13, 0xe2, 0x75, 0xf5, 0x74, 0xae, 0x3f,
1141 0xee, 0x1e, 0x09, 0x63, 0x5a, 0x30, 0x19, 0xa5, 0x59, 0x48, 0x90, 0x9b,
1142 0x46, 0x56, 0xd8, 0x6f, 0x6b, 0x76, 0x82, 0x32, 0xc7, 0x29, 0x76, 0x2e,
1143 0x32, 0xb6, 0x23, 0x99, 0xeb, 0x92, 0x5d, 0xc4, 0x4c, 0xa1, 0xe9, 0x26,
1144 0x37, 0x9a, 0x7d, 0x4c, 0x16, 0x9c, 0x18, 0xe9, 0xc0, 0xff, 0x48, 0x79,
1145 0xb1, 0x7b, 0x0b, 0x1e, 0x6f, 0xb1, 0x77, 0xa5, 0xd2, 0xc6, 0x9a, 0xa9,
1146 0xfc, 0xd1, 0x0f, 0x69, 0xf3, 0xe0, 0x49, 0x70, 0x57, 0x80, 0x86, 0xa7,
1147 0x3f, 0x54, 0xa8, 0x60, 0xfb, 0xe4, 0x06, 0xa3, 0x13, 0xb9, 0x2f, 0xa7,
1148 0x37, 0x80, 0x0c, 0x43, 0xac, 0x2f, 0xae, 0x6e, 0x62, 0x2b, 0x53, 0xe4,
1149 0xfe, 0x58, 0xd7, 0x8b, 0x96, 0xdc, 0xe6, 0xd3, 0x86, 0xb8, 0xd6, 0x42,
1150 0x5b, 0x68, 0x03, 0x48, 0x3f, 0xcd, 0xee, 0x39, 0x8b, 0xc4, 0x53, 0x30,
1151 0x87, 0x48, 0x2a, 0x01, 0x9d, 0x6f, 0x8e, 0x36, 0x75, 0x73, 0xef, 0x77,
1152 0x3a, 0x82, 0xd8, 0x4c, 0x0e, 0x7f, 0xb3, 0x8f, 0x16, 0xd1, 0x10, 0xcf,
1153 0x2f, 0xa3, 0xdf, 0x65, 0xba, 0x91, 0x79, 0xf6, 0x93, 0x60, 0x08, 0xe5,
1154 0xdb, 0x73, 0x02, 0x7a, 0x0b, 0x0e, 0xcc, 0x3b, 0x1f, 0x08, 0x2d, 0x51,
1155 0x3e, 0x87, 0x48, 0xd3, 0xd3, 0x75, 0xc2, 0x28, 0xa3, 0xf3, 0x02, 0xde,
1156 0x8f, 0xa6, 0xbd, 0xb3, 0x19, 0xa0, 0xdb, 0x48, 0x51, 0x03, 0x5f, 0x98,
1157 0xbe,
1158
1159 /* Third Packet: 1-RTT */
1160 0x5c, /* Short, 1-RTT, Spin=0, KP=0, PN Length=2 bytes */
1161 0x4f, 0x33, /* PN (0) */
1162 0x16, 0x75, 0x98, 0x67, 0x04, 0x16, 0x61, 0xe3, 0x00, 0xb7, 0x9d, 0x5c,
1163 0x53, 0x4c, 0x26, 0x90, 0x92, 0x8e, 0x0e, 0xc0, 0x9c, 0x6d, 0x8b, 0xac,
1164 0x15, 0x6d, 0x89, 0x74, 0x2f, 0xe7, 0x84, 0xe3, 0x46, 0x46, 0x8c, 0xc1,
1165 0x21, 0x7c, 0x44, 0xa5, 0x00, 0x29, 0xca, 0xf2, 0x11, 0x18, 0xe0, 0x04,
1166 0x40, 0x55, 0xd2, 0xa7, 0xe5, 0x9d, 0x22, 0xa2, 0x2a, 0x6c, 0x03, 0x87,
1167 0xa3, 0xa3, 0xfa, 0xf5, 0x6c, 0xd7, 0x7d, 0xae, 0x3f, 0x28, 0x01, 0xae,
1168 0x06, 0x11, 0x69, 0x67, 0x90, 0x57, 0x5a, 0xd0, 0xeb, 0xdd, 0xac, 0xbd,
1169 0x7f, 0x33, 0x86, 0xbb,
1170};
1171
19571483 1172static const QUIC_PKT_HDR rx_script_7a_expect_hdr = {
ec279ac2
HL
1173 QUIC_PKT_TYPE_INITIAL,
1174 0, /* Spin Bit */
1175 0, /* Key Phase */
1176 2, /* PN Length */
1177 0, /* Partial */
1178 1, /* Fixed */
1179 1, /* Version */
1180 {0, {0}}, /* DCID */
1181 {4, {0x03, 0x45, 0x0c, 0x7a}}, /* SCID */
1182 {0}, /* PN */
1183 NULL, 0, /* Token/Token Len */
1184 441, NULL
1185};
1186
19571483 1187static const unsigned char rx_script_7a_body[] = {
ec279ac2
HL
1188 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1189 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1190 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1191 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1192 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1193 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1194 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1195 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1196 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1197 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1198 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1199 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1200 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1201 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1202 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1203 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1204 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1205 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1206 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1207 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1208 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1209 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1210 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1211 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1212 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1213 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1214 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1215 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1216 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
1217 0x00, 0x40, 0x5a, 0x02, 0x00, 0x00, 0x56, 0x03, 0x03, 0xd5, 0xfb, 0x6a,
1218 0x81, 0x1c, 0xdb, 0xa2, 0x5c, 0x11, 0x31, 0xda, 0x15, 0x28, 0x97, 0x94,
1219 0x83, 0xfd, 0x9d, 0x91, 0x0e, 0x87, 0x71, 0x46, 0x64, 0xb4, 0xd9, 0x9e,
1220 0xbd, 0xa8, 0x48, 0x32, 0xbf, 0x00, 0x13, 0x03, 0x00, 0x00, 0x2e, 0x00,
1221 0x2b, 0x00, 0x02, 0x03, 0x04, 0x00, 0x33, 0x00, 0x24, 0x00, 0x1d, 0x00,
1222 0x20, 0xef, 0xbb, 0x46, 0xe9, 0xb4, 0xf6, 0x54, 0xc4, 0x07, 0x71, 0xdc,
1223 0x50, 0xd5, 0x69, 0x40, 0xbc, 0x85, 0x7f, 0xf9, 0x48, 0x14, 0xe3, 0xd6,
1224 0x08, 0xa9, 0x0b, 0xfd, 0xbe, 0xf1, 0x57, 0x21, 0x34,
1225};
1226
19571483 1227static const QUIC_PKT_HDR rx_script_7b_expect_hdr = {
ec279ac2
HL
1228 QUIC_PKT_TYPE_HANDSHAKE,
1229 0, /* Spin Bit */
1230 0, /* Key Phase */
1231 2, /* PN Length */
1232 0, /* Partial */
1233 1, /* Fixed */
1234 1, /* Version */
1235 {0, {0}}, /* DCID */
1236 {4, {0x03, 0x45, 0x0c, 0x7a}}, /* SCID */
1237 {0}, /* PN */
1238 NULL, 0, /* Token/Token Len */
1239 657, NULL
1240};
1241
19571483 1242static const unsigned char rx_script_7b_body[] = {
ec279ac2
HL
1243 0x06, 0x00, 0x42, 0x8d, 0x08, 0x00, 0x00, 0x82, 0x00, 0x80, 0x00, 0x10,
1244 0x00, 0x08, 0x00, 0x06, 0x05, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x00, 0x39,
1245 0x00, 0x70, 0x46, 0x0a, 0x0d, 0xdc, 0x59, 0xf0, 0x4e, 0xb2, 0x2c, 0xac,
1246 0x69, 0x6a, 0xc9, 0x77, 0xa9, 0x99, 0x05, 0x04, 0x80, 0x08, 0x00, 0x00,
1247 0x06, 0x04, 0x80, 0x08, 0x00, 0x00, 0x07, 0x04, 0x80, 0x08, 0x00, 0x00,
1248 0x04, 0x04, 0x80, 0x0c, 0x00, 0x00, 0x08, 0x02, 0x40, 0x64, 0x09, 0x02,
1249 0x40, 0x64, 0x01, 0x04, 0x80, 0x00, 0x75, 0x30, 0x03, 0x02, 0x45, 0xac,
1250 0x0b, 0x01, 0x1a, 0x0c, 0x00, 0x02, 0x10, 0x42, 0xf0, 0xed, 0x09, 0x07,
1251 0x5b, 0xd9, 0x5a, 0xb2, 0x39, 0x5d, 0x73, 0x2c, 0x57, 0x1f, 0x50, 0x00,
1252 0x0b, 0xe0, 0x3e, 0xf3, 0xd6, 0x91, 0x6f, 0x9c, 0xcc, 0x31, 0xf7, 0xa5,
1253 0x0e, 0x01, 0x04, 0x0f, 0x04, 0x03, 0x45, 0x0c, 0x7a, 0x10, 0x04, 0xfa,
1254 0x5d, 0xd6, 0x80, 0x20, 0x01, 0x00, 0x0b, 0x00, 0x01, 0x8f, 0x00, 0x00,
1255 0x01, 0x8b, 0x00, 0x01, 0x86, 0x30, 0x82, 0x01, 0x82, 0x30, 0x82, 0x01,
1256 0x29, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x14, 0x0a, 0x73, 0x0f, 0x86,
1257 0x18, 0xf2, 0xc3, 0x30, 0x01, 0xd2, 0xc0, 0xc1, 0x62, 0x52, 0x13, 0xf1,
1258 0x9c, 0x13, 0x39, 0xb5, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce,
1259 0x3d, 0x04, 0x03, 0x02, 0x30, 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03,
1260 0x55, 0x04, 0x03, 0x0c, 0x0c, 0x6d, 0x61, 0x70, 0x61, 0x6b, 0x74, 0x2e,
1261 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x30, 0x1e, 0x17, 0x0d, 0x32, 0x32, 0x30,
1262 0x38, 0x30, 0x32, 0x31, 0x32, 0x30, 0x30, 0x31, 0x38, 0x5a, 0x17, 0x0d,
1263 0x32, 0x32, 0x30, 0x39, 0x30, 0x31, 0x31, 0x32, 0x30, 0x30, 0x31, 0x38,
1264 0x5a, 0x30, 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03,
1265 0x0c, 0x0c, 0x6d, 0x61, 0x70, 0x61, 0x6b, 0x74, 0x2e, 0x6c, 0x6f, 0x63,
1266 0x61, 0x6c, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce,
1267 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01,
1268 0x07, 0x03, 0x42, 0x00, 0x04, 0x67, 0xf4, 0xd3, 0x8f, 0x15, 0x6d, 0xee,
1269 0x85, 0xcc, 0x2a, 0x77, 0xfc, 0x0b, 0x8f, 0x9f, 0xcf, 0xa9, 0x95, 0x5d,
1270 0x5b, 0xcd, 0xb7, 0x8b, 0xba, 0x31, 0x0a, 0x73, 0x62, 0xc5, 0xd0, 0x0e,
1271 0x07, 0x90, 0xae, 0x38, 0x43, 0x79, 0xce, 0x5e, 0x33, 0xad, 0x31, 0xbf,
1272 0x9f, 0x2a, 0x56, 0x83, 0xa5, 0x24, 0x16, 0xab, 0x0c, 0xf1, 0x64, 0xbe,
1273 0xe4, 0x93, 0xb5, 0x89, 0xd6, 0x05, 0xe4, 0xf7, 0x7b, 0xa3, 0x53, 0x30,
1274 0x51, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14,
1275 0x02, 0x64, 0x0f, 0x55, 0x69, 0x14, 0x91, 0x19, 0xed, 0xf9, 0x1a, 0xe9,
1276 0x1d, 0xa5, 0x5a, 0xd0, 0x48, 0x96, 0x9f, 0x60, 0x30, 0x1f, 0x06, 0x03,
1277 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0x02, 0x64, 0x0f,
1278 0x55, 0x69, 0x14, 0x91, 0x19, 0xed, 0xf9, 0x1a, 0xe9, 0x1d, 0xa5, 0x5a,
1279 0xd0, 0x48, 0x96, 0x9f, 0x60, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d, 0x13,
1280 0x01, 0x01, 0xff, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0a,
1281 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x47,
1282 0x00, 0x30, 0x44, 0x02, 0x20, 0x0a, 0x82, 0x92, 0x6e, 0xd3, 0xc6, 0x66,
1283 0xd9, 0xd3, 0x75, 0xff, 0x71, 0x3b, 0x61, 0x46, 0x21, 0x00, 0xe6, 0x21,
1284 0x5d, 0x9c, 0x86, 0xe9, 0x65, 0x40, 0x4f, 0xeb, 0x70, 0x4f, 0x2c, 0xad,
1285 0x00, 0x02, 0x20, 0x08, 0xc2, 0x07, 0x5d, 0x16, 0xfc, 0x54, 0x34, 0x2b,
1286 0xb4, 0x18, 0x67, 0x44, 0x81, 0xc9, 0xa9, 0x67, 0x2e, 0xce, 0xa1, 0x02,
1287 0x9f, 0x3b, 0xe5, 0x61, 0x16, 0x0b, 0x50, 0xf6, 0xa1, 0x50, 0x94, 0x00,
1288 0x00, 0x0f, 0x00, 0x00, 0x4c, 0x04, 0x03, 0x00, 0x48, 0x30, 0x46, 0x02,
1289 0x21, 0x00, 0xaa, 0x18, 0x61, 0x93, 0xdf, 0xbb, 0x79, 0xe7, 0x34, 0x7e,
1290 0x2e, 0x61, 0x13, 0x8c, 0xa0, 0x33, 0xfb, 0x33, 0xca, 0xfc, 0xd2, 0x45,
1291 0xb0, 0xc7, 0x89, 0x3d, 0xf1, 0xd6, 0x54, 0x94, 0x05, 0xb6, 0x02, 0x21,
1292 0x00, 0xef, 0x6c, 0xb6, 0xf2, 0x00, 0xb2, 0x32, 0xb1, 0xf3, 0x3f, 0x59,
1293 0xf5, 0xc8, 0x18, 0xbe, 0x39, 0xbb, 0x27, 0xf8, 0x67, 0xac, 0xcb, 0x63,
1294 0xa4, 0x29, 0xfb, 0x8e, 0x88, 0x0f, 0xe5, 0xe9, 0x7e, 0x14, 0x00, 0x00,
1295 0x20, 0xfc, 0x2c, 0x4c, 0xa7, 0x77, 0x24, 0x79, 0x29, 0xa8, 0x82, 0x1a,
1296 0x4d, 0x58, 0x9d, 0x82, 0xe2, 0x09, 0x36, 0x63, 0x0e, 0x0b, 0x55, 0x51,
1297 0x80, 0x93, 0x40, 0xda, 0x41, 0x33, 0x08, 0x10, 0x2c,
1298};
1299
19571483 1300static const QUIC_PKT_HDR rx_script_7c_expect_hdr = {
ec279ac2
HL
1301 QUIC_PKT_TYPE_1RTT,
1302 0, /* Spin Bit */
1303 0, /* Key Phase */
1304 2, /* PN Length */
1305 0, /* Partial */
1306 1, /* Fixed */
1307 0, /* Version */
1308 {0, {0}}, /* DCID */
1309 {0, {0}}, /* SCID */
1310 {0}, /* PN */
1311 NULL, 0, /* Token/Token Len */
1312 72, NULL
1313};
1314
19571483 1315static const unsigned char rx_script_7c_body[] = {
ec279ac2
HL
1316 0x18, 0x03, 0x00, 0x04, 0xf7, 0x75, 0x72, 0xa2, 0xfd, 0x17, 0xd4, 0x82,
1317 0x8e, 0xe9, 0x5b, 0xce, 0xed, 0xec, 0x88, 0xb9, 0x73, 0xbf, 0x36, 0x9f,
1318 0x18, 0x02, 0x00, 0x04, 0x5f, 0x43, 0x96, 0xe4, 0x15, 0xdc, 0x56, 0x6b,
1319 0x67, 0x4c, 0x36, 0xb2, 0xe2, 0x77, 0xdc, 0x6e, 0xb9, 0x2c, 0x0d, 0x79,
1320 0x18, 0x01, 0x00, 0x04, 0xcb, 0x83, 0x4a, 0xf4, 0x8d, 0x7b, 0x69, 0x90,
1321 0xaf, 0x0d, 0xd2, 0x38, 0xa4, 0xf1, 0x94, 0xff, 0x63, 0x24, 0xd3, 0x7a,
1322};
1323
19571483
HL
1324static const struct rx_test_op rx_script_7[] = {
1325 RX_OP_ADD_RX_DCID(empty_conn_id)
1326 RX_OP_PROVIDE_SECRET_INITIAL(rx_script_7_c2s_init_dcid)
1327 RX_OP_INJECT_N(7)
ecc920b3 1328 RX_OP_CHECK_PKT_FRAMES_OK_N(7a)
19571483
HL
1329 RX_OP_CHECK_NO_PKT() /* not got secret for next packet yet */
1330 RX_OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_HANDSHAKE,
1331 QRL_SUITE_CHACHA20POLY1305, rx_script_7_handshake_secret)
ecc920b3 1332 RX_OP_CHECK_PKT_FRAMES_OK_N(7b)
19571483
HL
1333 RX_OP_CHECK_NO_PKT() /* not got secret for next packet yet */
1334 RX_OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT,
1335 QRL_SUITE_CHACHA20POLY1305, rx_script_7_1rtt_secret)
ecc920b3 1336 RX_OP_CHECK_PKT_FRAMES_OK_N(7c)
19571483 1337 RX_OP_CHECK_NO_PKT()
ec279ac2
HL
1338
1339 /* Try injecting the packet again */
19571483 1340 RX_OP_INJECT_N(7)
ec279ac2
HL
1341 /*
1342 * Initial packet is not output due to receiving a Handshake packet causing
1343 * auto-discard of Initial keys
1344 */
ecc920b3
RL
1345 RX_OP_CHECK_PKT_FRAMES_OK_N(7b)
1346 RX_OP_CHECK_PKT_FRAMES_OK_N(7c)
19571483 1347 RX_OP_CHECK_NO_PKT()
ec279ac2 1348 /* Try again with discarded keys */
19571483
HL
1349 RX_OP_DISCARD_EL(QUIC_ENC_LEVEL_HANDSHAKE)
1350 RX_OP_INJECT_N(7)
ecc920b3 1351 RX_OP_CHECK_PKT_FRAMES_OK_N(7c)
19571483 1352 RX_OP_CHECK_NO_PKT()
ec279ac2 1353 /* Try again */
19571483 1354 RX_OP_INJECT_N(7)
ecc920b3 1355 RX_OP_CHECK_PKT_FRAMES_OK_N(7c)
19571483 1356 RX_OP_CHECK_NO_PKT()
ec279ac2 1357 /* Try again with discarded 1-RTT keys */
19571483
HL
1358 RX_OP_DISCARD_EL(QUIC_ENC_LEVEL_1RTT)
1359 RX_OP_INJECT_N(7)
1360 RX_OP_CHECK_NO_PKT()
ec279ac2
HL
1361
1362 /* Recreate QRL, test reading packets received before key */
19571483
HL
1363 RX_OP_SET_SCID_LEN(0)
1364 RX_OP_ADD_RX_DCID(empty_conn_id)
1365 RX_OP_INJECT_N(7)
1366 RX_OP_CHECK_NO_PKT()
1367 RX_OP_PROVIDE_SECRET_INITIAL(rx_script_7_c2s_init_dcid)
ecc920b3 1368 RX_OP_CHECK_PKT_FRAMES_OK_N(7a)
19571483
HL
1369 RX_OP_CHECK_NO_PKT()
1370 RX_OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_HANDSHAKE,
1371 QRL_SUITE_CHACHA20POLY1305, rx_script_7_handshake_secret)
ecc920b3 1372 RX_OP_CHECK_PKT_FRAMES_OK_N(7b)
19571483
HL
1373 RX_OP_CHECK_NO_PKT()
1374 RX_OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT,
1375 QRL_SUITE_CHACHA20POLY1305, rx_script_7_1rtt_secret)
ecc920b3 1376 RX_OP_CHECK_PKT_FRAMES_OK_N(7c)
19571483
HL
1377 RX_OP_CHECK_NO_PKT()
1378
1379 RX_OP_END
1380};
681c4619 1381#endif /* !defined(OPENSSL_NO_CHACHA) */
19571483 1382
948c656c
HL
1383/*
1384 * 8. Real World - S2C Multiple Packets with Peer Initiated Key Phase Update
1385 */
1386static const unsigned char rx_script_8_1rtt_secret[32] = {
1387 0x5f, 0x1f, 0x47, 0xea, 0xc3, 0xb2, 0xce, 0x73, 0xfb, 0xa2, 0x9f, 0xac,
1388 0xc3, 0xa0, 0xfe, 0x9b, 0xf3, 0xc0, 0xde, 0x5d, 0x33, 0x11, 0x1c, 0x70,
1389 0xdd, 0xb4, 0x06, 0xcc, 0xdf, 0x7d, 0xe9, 0x9a
1390};
1391
1392static const unsigned char rx_script_8a_in[] = {
1393 0x51, /* Short, 1-RTT, PN Length=2 bytes, KP=0 */
1394 0xcb, 0xf4, /* PN (4) */
1395 0x3f, 0x68, 0x7b, 0xa8, 0x2b, 0xb9, 0xfa, 0x7d, 0xe4, 0x6b, 0x20, 0x48,
1396 0xd1, 0x3c, 0xcb, 0x4b, 0xef, 0xb1, 0xfd, 0x5e, 0x1b, 0x19, 0x83, 0xa9,
1397 0x47, 0x62, 0xc1, 0x6e, 0xef, 0x27, 0xc3, 0x9b, 0x8f, 0x3f, 0xce, 0x11,
1398 0x68, 0xf5, 0x73, 0x0d, 0xf2, 0xdc, 0xe0, 0x28, 0x28, 0x79, 0xa6, 0x39,
1399 0xc3, 0xb9, 0xd3,
1400};
1401
1402static const QUIC_PKT_HDR rx_script_8a_expect_hdr = {
1403 QUIC_PKT_TYPE_1RTT,
1404 0, /* Spin Bit */
1405 0, /* Key Phase */
1406 2, /* PN Length */
1407 0, /* Partial */
1408 1, /* Fixed */
1409 0, /* Version */
1410 {0, {0}}, /* DCID */
1411 {0, {0}}, /* SCID */
1412 {0, 4}, /* PN */
1413 NULL, 0, /* Token/Token Len */
1414 35, NULL
1415};
1416
1417static const unsigned char rx_script_8a_body[] = {
1418 0x02, 0x03, 0x06, 0x00, 0x03, 0x0c, 0x00, 0x1b, 0x49, 0x27, 0x6d, 0x20,
1419 0x68, 0x61, 0x76, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x20, 0x77, 0x6f, 0x6e,
1420 0x64, 0x65, 0x72, 0x66, 0x75, 0x6c, 0x20, 0x74, 0x69, 0x6d, 0x65
1421};
1422
1423static const unsigned char rx_script_8b_in[] = {
1424 0x52, /* Short, 1-RTT, PN Length=2 bytes, KP=1 */
1425 0x21, 0x8e, /* PN (5) */
1426 0xa2, 0x6a, 0x9c, 0x83, 0x24, 0x48, 0xae, 0x60, 0x1e, 0xc2, 0xa5, 0x91,
1427 0xfa, 0xe5, 0xf2, 0x05, 0x14, 0x37, 0x04, 0x6a, 0xa8, 0xae, 0x06, 0x58,
1428 0xd7, 0x85, 0x48, 0xd7, 0x3b, 0x85, 0x9e, 0x5a, 0xb3, 0x46, 0x89, 0x1b,
1429 0x4b, 0x6e, 0x1d, 0xd1, 0xfc, 0xb7, 0x47, 0xda, 0x6a, 0x64, 0x4b, 0x8e,
1430 0xf2, 0x69, 0x16,
1431};
1432
1433static const QUIC_PKT_HDR rx_script_8b_expect_hdr = {
1434 QUIC_PKT_TYPE_1RTT,
1435 0, /* Spin Bit */
1436 1, /* Key Phase */
1437 2, /* PN Length */
1438 0, /* Partial */
1439 1, /* Fixed */
1440 0, /* Version */
1441 {0, {0}}, /* DCID */
1442 {0, {0}}, /* SCID */
1443 {0, 5}, /* PN */
1444 NULL, 0, /* Token/Token Len */
1445 35, NULL
1446};
1447
1448static const unsigned char rx_script_8b_body[] = {
1449 0x02, 0x04, 0x03, 0x00, 0x00, 0x0c, 0x00, 0x36, 0x49, 0x27, 0x6d, 0x20,
1450 0x68, 0x61, 0x76, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x20, 0x77, 0x6f, 0x6e,
1451 0x64, 0x65, 0x72, 0x66, 0x75, 0x6c, 0x20, 0x74, 0x69, 0x6d, 0x65,
1452};
1453
1454static const unsigned char rx_script_8c_in[] = {
1455 0x5b, /* Short, 1-RTT, PN Length=2 bytes, KP=0 */
1456 0x98, 0xd6, /* PN (3) */
1457 0x3c, 0x6f, 0x94, 0x20, 0x5e, 0xfc, 0x5b, 0x3a, 0x4a, 0x65, 0x1a, 0x9a,
1458 0x6c, 0x00, 0x52, 0xb6, 0x0c, 0x9b, 0x07, 0xf9, 0x6f, 0xbc, 0x3d, 0xb4,
1459 0x57, 0xe0, 0x15, 0x74, 0xfe, 0x76, 0xea, 0x1f, 0x23, 0xae, 0x22, 0x62,
1460 0xb7, 0x90, 0x94, 0x89, 0x38, 0x9b, 0x5b, 0x47, 0xed,
1461};
1462
1463static const QUIC_PKT_HDR rx_script_8c_expect_hdr = {
1464 QUIC_PKT_TYPE_1RTT,
1465 0, /* Spin Bit */
1466 0, /* Key Phase */
1467 2, /* PN Length */
1468 0, /* Partial */
1469 1, /* Fixed */
1470 0, /* Version */
1471 {0, {0}}, /* DCID */
1472 {0, {0}}, /* SCID */
1473 {0, 3}, /* PN */
1474 NULL, 0, /* Token/Token Len */
1475 29, NULL
1476};
1477
1478static const unsigned char rx_script_8c_body[] = {
1479 0x08, 0x00, 0x49, 0x27, 0x6d, 0x20, 0x68, 0x61, 0x76, 0x69, 0x6e, 0x67,
1480 0x20, 0x61, 0x20, 0x77, 0x6f, 0x6e, 0x64, 0x65, 0x72, 0x66, 0x75, 0x6c,
1481 0x20, 0x74, 0x69, 0x6d, 0x65,
1482};
1483
1484static const unsigned char rx_script_8d_in[] = {
1485 0x55, /* Short, 1-RTT, PN Length=2 bytes, KP=1 */
1486 0x98, 0x20, /* PN (6) */
1487 0x45, 0x53, 0x05, 0x29, 0x30, 0x42, 0x29, 0x02, 0xf2, 0xa7, 0x27, 0xd6,
1488 0xb0, 0xb7, 0x30, 0xad, 0x45, 0xd8, 0x73, 0xd7, 0xe3, 0x65, 0xee, 0xd9,
1489 0x35, 0x33, 0x03, 0x3a, 0x35, 0x0b, 0x59, 0xa7, 0xbc, 0x23, 0x37, 0xc2,
1490 0x5e, 0x13, 0x88, 0x18, 0x79, 0x94, 0x6c, 0x15, 0xe3, 0x1f, 0x0d, 0xd1,
1491 0xc3, 0xfa, 0x40, 0xff,
1492};
1493
1494static const QUIC_PKT_HDR rx_script_8d_expect_hdr = {
1495 QUIC_PKT_TYPE_1RTT,
1496 0, /* Spin Bit */
1497 1, /* Key Phase */
1498 2, /* PN Length */
1499 0, /* Partial */
1500 1, /* Fixed */
1501 0, /* Version */
1502 {0, {0}}, /* DCID */
1503 {0, {0}}, /* SCID */
1504 {0, 6}, /* PN */
1505 NULL, 0, /* Token/Token Len */
1506 36, NULL
1507};
1508
1509static const unsigned char rx_script_8d_body[] = {
1510 0x02, 0x05, 0x03, 0x00, 0x00, 0x0c, 0x00, 0x40, 0x51, 0x49, 0x27, 0x6d,
1511 0x20, 0x68, 0x61, 0x76, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x20, 0x77, 0x6f,
1512 0x6e, 0x64, 0x65, 0x72, 0x66, 0x75, 0x6c, 0x20, 0x74, 0x69, 0x6d, 0x65,
1513};
1514
1515static const unsigned char rx_script_8e_in[] = {
1516 0x55, /* Short, 1-RTTT, PN Length=2 bytes, KP=0 */
1517 0x76, 0x25, /* PN (10) */
1518 0x1c, 0x0d, 0x70, 0x4c, 0x2b, 0xc5, 0x7d, 0x7b, 0x77, 0x64, 0x03, 0x27,
1519 0xb3, 0x5d, 0x83, 0x9e, 0x35, 0x05, 0x10, 0xd2, 0xa4, 0x5c, 0x83, 0xd6,
1520 0x94, 0x12, 0x18, 0xc5, 0xb3, 0x0f, 0x0a, 0xb1, 0x8a, 0x82, 0x9f, 0xd6,
1521 0xa9, 0xab, 0x40, 0xc1, 0x05, 0xe8, 0x1b, 0x74, 0xaa, 0x8e, 0xd6, 0x8b,
1522 0xa5, 0xa3, 0x77, 0x79,
1523};
1524
1525static const QUIC_PKT_HDR rx_script_8e_expect_hdr = {
1526 QUIC_PKT_TYPE_1RTT,
1527 0, /* Spin Bit */
1528 0, /* Key Phase */
1529 2, /* PN Length */
1530 0, /* Partial */
1531 1, /* Fixed */
1532 0, /* Version */
1533 {0, {0}}, /* DCID */
1534 {0, {0}}, /* SCID */
1535 {0, 10}, /* PN */
1536 NULL, 0, /* Token/Token Len */
1537 36, NULL
1538};
1539
1540static const unsigned char rx_script_8e_body[] = {
1541 0x02, 0x09, 0x04, 0x00, 0x00, 0x0c, 0x00, 0x40, 0xbd, 0x49, 0x27, 0x6d,
1542 0x20, 0x68, 0x61, 0x76, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x20, 0x77, 0x6f,
1543 0x6e, 0x64, 0x65, 0x72, 0x66, 0x75, 0x6c, 0x20, 0x74, 0x69, 0x6d, 0x65,
1544};
1545
1546static const unsigned char rx_script_8f_in[] = {
1547 0x48, /* Short, 1-RTT, PN Length=2 Bytes, KP=1 */
1548 0x4d, 0xf6, /* PN (15) */
1549 0x42, 0x86, 0xa1, 0xfa, 0x69, 0x6b, 0x1a, 0x45, 0xf2, 0xcd, 0xf6, 0x92,
1550 0xe1, 0xe6, 0x1a, 0x49, 0x37, 0xd7, 0x10, 0xae, 0x09, 0xbd
1551};
1552
1553static const QUIC_PKT_HDR rx_script_8f_expect_hdr = {
1554 QUIC_PKT_TYPE_1RTT,
1555 0, /* Spin Bit */
1556 1, /* Key Phase */
1557 2, /* PN Length */
1558 0, /* Partial */
1559 1, /* Fixed */
1560 0, /* Version */
1561 {0, {0}}, /* DCID */
1562 {0, {0}}, /* SCID */
1563 {0, 15}, /* PN */
1564 NULL, 0, /* Token/Token Len */
1565 6, NULL
1566};
1567
1568static const unsigned char rx_script_8f_body[] = {
1569 0x02, 0x0e, 0x4c, 0x54, 0x00, 0x02
1570};
1571
1572static const struct rx_test_op rx_script_8[] = {
1573 RX_OP_ADD_RX_DCID(empty_conn_id)
1574 /* Inject before we get the keys */
1575 RX_OP_INJECT_N(8a)
1576 /* Nothing yet */
1577 RX_OP_CHECK_NO_PKT()
1578 /* Provide keys */
1579 RX_OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT,
1580 QRL_SUITE_AES128GCM, rx_script_8_1rtt_secret)
1581 /* Now the injected packet is successfully returned */
ecc920b3 1582 RX_OP_CHECK_PKT_FRAMES_OK_N(8a)
948c656c
HL
1583 RX_OP_CHECK_NO_PKT()
1584 RX_OP_CHECK_KEY_EPOCH(0)
1585
1586 /* Packet with new key phase */
1587 RX_OP_INJECT_N(8b)
1588 /* Packet is successfully decrypted and returned */
ecc920b3 1589 RX_OP_CHECK_PKT_FRAMES_OK_N(8b)
948c656c
HL
1590 RX_OP_CHECK_NO_PKT()
1591 /* Key epoch has increased */
1592 RX_OP_CHECK_KEY_EPOCH(1)
1593
1594 /*
1595 * Now inject an old packet with the old keys (perhaps reordered in
1596 * network).
1597 */
1598 RX_OP_INJECT_N(8c)
1599 /* Should still be decrypted OK */
ecc920b3 1600 RX_OP_CHECK_PKT_FRAMES_OK_N(8c)
948c656c
HL
1601 RX_OP_CHECK_NO_PKT()
1602 /* Epoch has not changed */
1603 RX_OP_CHECK_KEY_EPOCH(1)
1604
1605 /* Another packet with the new keys. */
1606 RX_OP_INJECT_N(8d)
ecc920b3 1607 RX_OP_CHECK_PKT_FRAMES_OK_N(8d)
948c656c
HL
1608 RX_OP_CHECK_NO_PKT()
1609 RX_OP_CHECK_KEY_EPOCH(1)
1610
1611 /* We can inject the old packet multiple times and it still works */
1612 RX_OP_INJECT_N(8c)
ecc920b3 1613 RX_OP_CHECK_PKT_FRAMES_OK_N(8c)
948c656c
HL
1614 RX_OP_CHECK_NO_PKT()
1615 RX_OP_CHECK_KEY_EPOCH(1)
1616
1617 /* Until we move from UPDATING to COOLDOWN */
1618 RX_OP_KEY_UPDATE_TIMEOUT(0)
1619 RX_OP_INJECT_N(8c)
1620 RX_OP_CHECK_NO_PKT()
1621 RX_OP_CHECK_KEY_EPOCH(1)
1622
1623 /*
1624 * Injecting a packet from the next epoch (epoch 2) while in COOLDOWN
1625 * doesn't work
1626 */
1627 RX_OP_INJECT_N(8e)
1628 RX_OP_CHECK_NO_PKT()
1629 RX_OP_CHECK_KEY_EPOCH(1)
1630
1631 /* Move from COOLDOWN to NORMAL and try again */
1632 RX_OP_KEY_UPDATE_TIMEOUT(1)
1633 RX_OP_INJECT_N(8e)
ecc920b3 1634 RX_OP_CHECK_PKT_FRAMES_OK_N(8e)
948c656c
HL
1635 RX_OP_CHECK_NO_PKT()
1636 RX_OP_CHECK_KEY_EPOCH(2)
1637
1638 /* Can still receive old packet */
1639 RX_OP_INJECT_N(8d)
ecc920b3 1640 RX_OP_CHECK_PKT_FRAMES_OK_N(8d)
948c656c
HL
1641 RX_OP_CHECK_NO_PKT()
1642 RX_OP_CHECK_KEY_EPOCH(2)
1643
1644 /* Move straight from UPDATING to NORMAL */
1645 RX_OP_KEY_UPDATE_TIMEOUT(1)
1646
1647 /* Try a packet from epoch 3 */
1648 RX_OP_INJECT_N(8f)
ecc920b3 1649 RX_OP_CHECK_PKT_FRAMES_OK_N(8f)
948c656c
HL
1650 RX_OP_CHECK_NO_PKT()
1651 RX_OP_CHECK_KEY_EPOCH(3)
1652
1653 RX_OP_END
1654};
1655
19571483
HL
1656static const struct rx_test_op *rx_scripts[] = {
1657 rx_script_1,
681c4619 1658#ifndef OPENSSL_NO_CHACHA
19571483 1659 rx_script_2,
681c4619 1660#endif
19571483
HL
1661 rx_script_3,
1662 rx_script_4,
1663 rx_script_5,
1664 rx_script_6,
681c4619 1665#ifndef OPENSSL_NO_CHACHA
948c656c 1666 rx_script_7,
681c4619 1667#endif
948c656c 1668 rx_script_8
ec279ac2
HL
1669};
1670
1671static int cmp_pkt_hdr(const QUIC_PKT_HDR *a, const QUIC_PKT_HDR *b,
1672 const unsigned char *b_data, size_t b_len,
1673 int cmp_data)
1674{
1675 int ok = 1;
1676
1677 if (b_data == NULL) {
1678 b_data = b->data;
1679 b_len = b->len;
1680 }
1681
1682 if (!TEST_int_eq(a->type, b->type)
1683 || !TEST_int_eq(a->spin_bit, b->spin_bit)
1684 || !TEST_int_eq(a->key_phase, b->key_phase)
1685 || !TEST_int_eq(a->pn_len, b->pn_len)
1686 || !TEST_int_eq(a->partial, b->partial)
1687 || !TEST_int_eq(a->fixed, b->fixed)
1688 || !TEST_uint_eq(a->version, b->version)
1689 || !TEST_true(ossl_quic_conn_id_eq(&a->dst_conn_id, &b->dst_conn_id))
1690 || !TEST_true(ossl_quic_conn_id_eq(&a->src_conn_id, &b->src_conn_id))
1691 || !TEST_mem_eq(a->pn, sizeof(a->pn), b->pn, sizeof(b->pn))
1692 || !TEST_size_t_eq(a->token_len, b->token_len)
1693 || !TEST_uint64_t_eq(a->len, b->len))
1694 ok = 0;
1695
1696 if (a->token_len > 0 && b->token_len > 0
1697 && !TEST_mem_eq(a->token, a->token_len, b->token, b->token_len))
1698 ok = 0;
1699
1700 if ((a->token_len == 0 && !TEST_ptr_null(a->token))
1701 || (b->token_len == 0 && !TEST_ptr_null(b->token)))
1702 ok = 0;
1703
1704 if (cmp_data && !TEST_mem_eq(a->data, a->len, b_data, b_len))
1705 ok = 0;
1706
1707 return ok;
1708}
1709
19571483 1710struct rx_state {
ecc920b3
RL
1711 QUIC_DEMUX *demux;
1712
1713 /* OSSL_QRX with necessary data */
1714 OSSL_QRX *qrx;
1715 OSSL_QRX_ARGS args;
1716
1717 /* OSSL_ACKM with necessary data */
1718 OSSL_ACKM *ackm;
1719 OSSL_CC_DATA *ccdata;
1720 OSSL_STATM statm; /* NOT the state machine! */
1721
1722 /* Used for the RX depacketizer, and wraps the |qrx| and |ackm| */
1723 SSL_CTX *quic_ssl_ctx;
1724 QUIC_CONNECTION *quic_conn;
ec279ac2
HL
1725};
1726
19571483 1727static void rx_state_teardown(struct rx_state *s)
ec279ac2 1728{
ecc920b3
RL
1729 if (s->ackm != NULL) {
1730 ossl_ackm_free(s->ackm);
1731 ossl_quic_conn_set_ackm(s->quic_conn, NULL);
1732 s->ackm = NULL;
1733 }
1734 if (s->ccdata != NULL) {
1735 ossl_cc_dummy_method.free(s->ccdata);
1736 s->ccdata = NULL;
1737 }
1738
19571483
HL
1739 if (s->qrx != NULL) {
1740 ossl_qrx_free(s->qrx);
ecc920b3 1741 ossl_quic_conn_set_qrx(s->quic_conn, NULL);
19571483 1742 s->qrx = NULL;
ec279ac2
HL
1743 }
1744
ecc920b3
RL
1745 if (s->quic_conn != NULL) {
1746 SSL_free((SSL *)s->quic_conn);
1747 s->quic_conn = NULL;
1748 }
1749 if (s->quic_ssl_ctx != NULL) {
1750 SSL_CTX_free(s->quic_ssl_ctx);
1751 s->quic_ssl_ctx = NULL;
1752 }
1753
ec279ac2
HL
1754 if (s->demux != NULL) {
1755 ossl_quic_demux_free(s->demux);
1756 s->demux = NULL;
1757 }
1758}
1759
948c656c
HL
1760static uint64_t time_counter = 0;
1761
ecc920b3
RL
1762static OSSL_TIME fake_now(void *ignored)
1763{
1764 OSSL_TIME f = {0};
1765
1766 return f;
1767}
1768
948c656c
HL
1769static OSSL_TIME expected_time(uint64_t counter)
1770{
1771 return ossl_time_multiply(ossl_ticks2time(OSSL_TIME_MS), counter);
1772}
1773
1774static OSSL_TIME fake_time(void *arg)
1775{
1776 return expected_time(++time_counter);
1777}
1778
19571483 1779static int rx_state_ensure(struct rx_state *s)
ec279ac2
HL
1780{
1781 if (s->demux == NULL
1782 && !TEST_ptr(s->demux = ossl_quic_demux_new(NULL,
1783 s->args.short_conn_id_len,
948c656c
HL
1784 1500,
1785 fake_time,
1786 NULL)))
ec279ac2
HL
1787 return 0;
1788
0ff98137
HL
1789 s->args.demux = s->demux;
1790 s->args.max_deferred = 32;
ec279ac2 1791
ecc920b3 1792 /* Initialise OSSL_QRX */
19571483
HL
1793 if (s->qrx == NULL
1794 && !TEST_ptr(s->qrx = ossl_qrx_new(&s->args)))
ec279ac2
HL
1795 return 0;
1796
1797 return 1;
1798}
1799
ecc920b3
RL
1800static int rx_state_ensure_for_frames(struct rx_state *s)
1801{
1802 SSL *qs;
1803
1804 if (!rx_state_ensure(s))
1805 return 0;
1806
1807 /* Initialise ACK manager and congestion controller. */
1808 if ((s->ccdata == NULL
1809 && !TEST_ptr(s->ccdata = ossl_cc_dummy_method.new(NULL, NULL, NULL)))
1810 || (s->ackm == NULL
1811 && !TEST_ptr(s->ackm = ossl_ackm_new(fake_now, NULL, &s->statm,
1812 &ossl_cc_dummy_method,
1813 s->ccdata))))
1814 return 0;
1815
1816 if (s->quic_conn == NULL
1817 && (!TEST_ptr(s->quic_ssl_ctx
1818 = SSL_CTX_new_ex(NULL, NULL, OSSL_QUIC_client_method()))
1819 || !TEST_ptr(qs = SSL_new(s->quic_ssl_ctx))
1820 || !TEST_ptr(s->quic_conn = ossl_quic_conn_from_ssl(qs))
1821 || !TEST_true(ossl_quic_conn_set_qrx(s->quic_conn, s->qrx))
1822 || !TEST_true(ossl_quic_conn_set_ackm(s->quic_conn, s->ackm))))
1823 return 0;
1824 return 1;
1825}
1826
19571483 1827static int rx_run_script(const struct rx_test_op *script)
ec279ac2
HL
1828{
1829 int testresult = 0, pkt_outstanding = 0;
19571483 1830 struct rx_state s = {0};
ec279ac2 1831 size_t i;
19571483
HL
1832 OSSL_QRX_PKT pkt = {0};
1833 const struct rx_test_op *op = script;
ec279ac2 1834
19571483 1835 for (; op->op != RX_TEST_OP_END; ++op)
ec279ac2 1836 switch (op->op) {
19571483
HL
1837 case RX_TEST_OP_SET_SCID_LEN:
1838 rx_state_teardown(&s);
ec279ac2
HL
1839 s.args.short_conn_id_len = op->enc_level;
1840 break;
19571483
HL
1841 case RX_TEST_OP_SET_INIT_LARGEST_PN:
1842 rx_state_teardown(&s);
ec279ac2 1843 for (i = 0; i < QUIC_PN_SPACE_NUM; ++i)
19571483 1844 s.args.init_largest_pn[i] = op->largest_pn;
ec279ac2 1845 break;
19571483
HL
1846 case RX_TEST_OP_ADD_RX_DCID:
1847 if (!TEST_true(rx_state_ensure(&s)))
ec279ac2 1848 goto err;
19571483 1849 if (!TEST_true(ossl_qrx_add_dst_conn_id(s.qrx, op->dcid)))
ec279ac2
HL
1850 goto err;
1851 break;
19571483
HL
1852 case RX_TEST_OP_PROVIDE_SECRET:
1853 if (!TEST_true(rx_state_ensure(&s)))
ec279ac2 1854 goto err;
19571483
HL
1855 if (!TEST_true(ossl_qrx_provide_secret(s.qrx, op->enc_level,
1856 op->suite_id, NULL,
1857 op->buf,
1858 op->buf_len)))
ec279ac2
HL
1859 goto err;
1860 break;
19571483
HL
1861 case RX_TEST_OP_PROVIDE_SECRET_INITIAL:
1862 if (!TEST_true(rx_state_ensure(&s)))
ec279ac2 1863 goto err;
19571483
HL
1864 if (!TEST_true(ossl_quic_provide_initial_secret(NULL, NULL,
1865 op->dcid, 0,
1866 s.qrx, NULL)))
ec279ac2
HL
1867 goto err;
1868 break;
19571483
HL
1869 case RX_TEST_OP_DISCARD_EL:
1870 if (!TEST_true(rx_state_ensure(&s)))
ec279ac2 1871 goto err;
19571483 1872 if (!TEST_true(ossl_qrx_discard_enc_level(s.qrx, op->enc_level)))
ec279ac2
HL
1873 goto err;
1874 break;
19571483
HL
1875 case RX_TEST_OP_INJECT:
1876 if (!TEST_true(rx_state_ensure(&s)))
ec279ac2
HL
1877 goto err;
1878 if (!TEST_true(ossl_quic_demux_inject(s.demux,
1879 op->buf, op->buf_len,
1880 NULL, NULL)))
1881 goto err;
1882 break;
19571483
HL
1883 case RX_TEST_OP_CHECK_PKT:
1884 if (!TEST_true(rx_state_ensure(&s)))
ec279ac2
HL
1885 goto err;
1886
19571483 1887 if (!TEST_true(ossl_qrx_read_pkt(s.qrx, &pkt)))
ec279ac2
HL
1888 goto err;
1889
1890 pkt_outstanding = 1;
1891 if (!TEST_ptr(pkt.hdr))
1892 goto err;
1893
1894 if (!TEST_mem_eq(pkt.hdr->data, pkt.hdr->len,
1895 op->buf, op->buf_len))
1896 goto err;
1897
1898 if (!TEST_true(cmp_pkt_hdr(pkt.hdr, op->hdr,
1899 op->buf, op->buf_len, 1)))
1900 goto err;
1901
ecc920b3
RL
1902 switch (op->subop) {
1903 case RX_TEST_OP_CHECK_PKT_FRAMES_OK:
1904 if (!TEST_true(rx_state_ensure_for_frames(&s)))
1905 goto err;
1906 pkt_outstanding = 0;
1907 if (!TEST_true(ossl_quic_handle_frames(s.quic_conn, &pkt)))
1908 goto err;
1909 break;
1910 case RX_TEST_OP_CHECK_PKT_FRAMES_INVALID:
1911 if (!TEST_true(rx_state_ensure_for_frames(&s)))
1912 goto err;
1913 pkt_outstanding = 0;
1914 if (!TEST_false(ossl_quic_handle_frames(s.quic_conn, &pkt)))
1915 goto err;
1916 break;
1917 default:
1918 pkt_outstanding = 0;
1919 ossl_qrx_release_pkt(s.qrx, pkt.handle);
1920 break;
1921 }
ec279ac2 1922 break;
19571483
HL
1923 case RX_TEST_OP_CHECK_NO_PKT:
1924 if (!TEST_true(rx_state_ensure(&s)))
ec279ac2
HL
1925 goto err;
1926
19571483 1927 if (!TEST_false(ossl_qrx_read_pkt(s.qrx, &pkt)))
ec279ac2
HL
1928 goto err;
1929
948c656c
HL
1930 break;
1931 case RX_TEST_OP_CHECK_KEY_EPOCH:
1932 if (!TEST_true(rx_state_ensure(&s)))
1933 goto err;
1934
1935 if (!TEST_uint64_t_eq(ossl_qrx_get_key_epoch(s.qrx),
1936 op->largest_pn))
1937 goto err;
1938
1939 break;
1940 case RX_TEST_OP_KEY_UPDATE_TIMEOUT:
1941 if (!TEST_true(rx_state_ensure(&s)))
1942 goto err;
1943
1944 if (!TEST_true(ossl_qrx_key_update_timeout(s.qrx,
1945 op->enc_level)))
1946 goto err;
1947
1948 break;
1949 case RX_TEST_OP_SET_INIT_KEY_PHASE:
1950 rx_state_teardown(&s);
1951 s.args.init_key_phase_bit = (unsigned char)op->enc_level;
ec279ac2
HL
1952 break;
1953 default:
1954 OPENSSL_assert(0);
1955 goto err;
1956 }
1957
1958 testresult = 1;
1959err:
1960 if (pkt_outstanding)
19571483
HL
1961 ossl_qrx_release_pkt(s.qrx, pkt.handle);
1962 rx_state_teardown(&s);
ec279ac2
HL
1963 return testresult;
1964}
1965
19571483 1966static int test_rx_script(int idx)
ec279ac2 1967{
19571483 1968 return rx_run_script(rx_scripts[idx]);
ec279ac2
HL
1969}
1970
1971/* Packet Header Tests */
1972struct pkt_hdr_test {
1973 QUIC_PKT_HDR hdr;
1974 const unsigned char *expected;
1975 size_t expected_len;
1976 const unsigned char *payload;
1977 size_t payload_len;
1978 size_t short_conn_id_len;
1979 /*
1980 * Minimum number of bytes which should be required for a successful decode.
1981 * SIZE_MAX if should never decode successfully.
1982 */
1983 size_t min_success_len;
1984 size_t pn_offset, sample_offset;
1985};
1986
1987/* Packet Header Test 1: INITIAL With SCID */
1988static const unsigned char pkt_hdr_test_1_expected[] = {
1989 0xc1, /* Long|Fixed, Type=Initial, PN Len=2 */
1990 0x00, 0x00, 0x00, 0x01, /* Version */
1991 0x00, /* DCID Length */
1992 0x08, 0xf0, 0x67, 0xa5, 0x50, 0x2a, 0x42, 0x62, 0xb5, /* SCID Length, SCID */
1993 0x00, /* Token Length */
1994 0x15, /* Length=21 */
1995 0x33, 0x44, /* Encoded PN */
1996 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* Payload */
1997 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
1998 0x20, 0x21, 0x22
1999};
2000
2001static const unsigned char pkt_hdr_test_1_payload[] = {
2002 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
2003 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
2004 0x20, 0x21, 0x22
2005};
2006
2007static const struct pkt_hdr_test pkt_hdr_test_1 = {
2008 {
2009 QUIC_PKT_TYPE_INITIAL, /* type */
2010 0, /* spin bit */
2011 0, /* key phase */
2012 2, /* PN length */
2013 0, /* partial */
2014 1, /* fixed */
2015 1, /* version */
2016 { 0, {0} }, /* DCID */
2017 { 8, {0xf0, 0x67, 0xa5, 0x50, 0x2a, 0x42, 0x62, 0xb5 } }, /* SCID */
2018 { 0x33, 0x44 }, /* PN */
2019 NULL, 0, /* Token/Token Len */
2020 19, NULL /* Len/Data */
2021 },
2022 pkt_hdr_test_1_expected, OSSL_NELEM(pkt_hdr_test_1_expected),
2023 pkt_hdr_test_1_payload, OSSL_NELEM(pkt_hdr_test_1_payload),
2024 0, sizeof(pkt_hdr_test_1_expected),
2025 17, 21
2026};
2027
2028/* Packet Header Test 2: INITIAL With SCID and Token */
2029static const unsigned char pkt_hdr_test_2_expected[] = {
2030 0xc1, /* Long|Fixed, Type=Initial, PN Len=2 */
2031 0x00, 0x00, 0x00, 0x01, /* Version */
2032 0x00, /* DCID Length */
2033 0x08, 0xf0, 0x67, 0xa5, 0x50, 0x2a, 0x42, 0x62, 0xb5, /* SCID Length, SCID */
2034 0x07, /* Token Length */
2035 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
2036 0x15, /* Length=21 */
2037 0x33, 0x44, /* Encoded PN */
2038 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* Payload */
2039 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
2040 0x20, 0x21, 0x22
2041};
2042
2043static const unsigned char pkt_hdr_test_2_payload[] = {
2044 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
2045 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
2046 0x20, 0x21, 0x22
2047};
2048
2049static const unsigned char pkt_hdr_test_2_token[] = {
2050 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96
2051};
2052
2053static const struct pkt_hdr_test pkt_hdr_test_2 = {
2054 {
2055 QUIC_PKT_TYPE_INITIAL, /* type */
2056 0, /* spin bit */
2057 0, /* key phase */
2058 2, /* PN length */
2059 0, /* partial */
2060 1, /* fixed */
2061 1, /* version */
2062 { 0, {0} }, /* DCID */
2063 { 8, {0xf0, 0x67, 0xa5, 0x50, 0x2a, 0x42, 0x62, 0xb5 } }, /* SCID */
2064 { 0x33, 0x44 }, /* PN */
2065 pkt_hdr_test_2_token, sizeof(pkt_hdr_test_2_token), /* Token */
2066 19, NULL /* Len/Data */
2067 },
2068 pkt_hdr_test_2_expected, OSSL_NELEM(pkt_hdr_test_2_expected),
2069 pkt_hdr_test_2_payload, OSSL_NELEM(pkt_hdr_test_2_payload),
2070 0, sizeof(pkt_hdr_test_2_expected),
2071 24, 28
2072};
2073
2074/* Packet Header Test 3: INITIAL With DCID and SCID and Token */
2075static const unsigned char pkt_hdr_test_3_expected[] = {
2076 0xc1, /* Long|Fixed, Type=Initial, PN Len=2 */
2077 0x00, 0x00, 0x00, 0x01, /* Version */
2078 0x03, /* DCID Length */
2079 0x70, 0x71, 0x72, /* DCID */
2080 0x08, 0xf0, 0x67, 0xa5, 0x50, 0x2a, 0x42, 0x62, 0xb5, /* SCID Length, SCID */
2081 0x06, /* Token Length */
2082 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
2083 0x15, /* Length=21 */
2084 0x33, 0x44, /* Encoded PN */
2085 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* Payload */
2086 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
2087 0x20, 0x21, 0x22
2088};
2089
2090static const unsigned char pkt_hdr_test_3_payload[] = {
2091 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
2092 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
2093 0x20, 0x21, 0x22
2094};
2095
2096static const unsigned char pkt_hdr_test_3_token[] = {
2097 0x91, 0x92, 0x93, 0x94, 0x95, 0x96
2098};
2099
2100static const struct pkt_hdr_test pkt_hdr_test_3 = {
2101 {
2102 QUIC_PKT_TYPE_INITIAL, /* type */
2103 0, /* spin bit */
2104 0, /* key phase */
2105 2, /* PN length */
2106 0, /* partial */
2107 1, /* fixed */
2108 1, /* version */
2109 { 3, {0x70, 0x71, 0x72} }, /* DCID */
2110 { 8, {0xf0, 0x67, 0xa5, 0x50, 0x2a, 0x42, 0x62, 0xb5 } }, /* SCID */
2111 { 0x33, 0x44 }, /* PN */
2112 pkt_hdr_test_3_token, sizeof(pkt_hdr_test_3_token), /* Token */
2113 19, NULL /* Len/Data */
2114 },
2115 pkt_hdr_test_3_expected, OSSL_NELEM(pkt_hdr_test_3_expected),
2116 pkt_hdr_test_3_payload, OSSL_NELEM(pkt_hdr_test_3_payload),
2117 0, sizeof(pkt_hdr_test_3_expected),
2118 26, 30
2119};
2120
2121/* Packet Header Test 4: 0-RTT */
2122static const unsigned char pkt_hdr_test_4_expected[] = {
2123 0xd0, /* Long|Fixed, Type=0-RTT, PN Len=1 */
2124 0x00, 0x00, 0x00, 0x01, /* Version */
2125 0x03, /* DCID Length */
2126 0x70, 0x71, 0x72, /* DCID */
2127 0x08, 0xf0, 0x67, 0xa5, 0x50, 0x2a, 0x42, 0x62, 0xb5, /* SCID Length, SCID */
2128 0x14, /* Length=20 */
2129 0x33, /* Encoded PN */
2130 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* Payload */
2131 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
2132 0x20, 0x21, 0x22
2133};
2134
2135static const unsigned char pkt_hdr_test_4_payload[] = {
2136 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
2137 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
2138 0x20, 0x21, 0x22
2139};
2140
2141static const struct pkt_hdr_test pkt_hdr_test_4 = {
2142 {
2143 QUIC_PKT_TYPE_0RTT, /* type */
2144 0, /* spin bit */
2145 0, /* key phase */
2146 1, /* PN length */
2147 0, /* partial */
2148 1, /* fixed */
2149 1, /* version */
2150 { 3, {0x70, 0x71, 0x72} }, /* DCID */
2151 { 8, {0xf0, 0x67, 0xa5, 0x50, 0x2a, 0x42, 0x62, 0xb5 } }, /* SCID */
2152 { 0x33 }, /* PN */
2153 NULL, 0, /* Token */
2154 19, NULL /* Len/Data */
2155 },
2156 pkt_hdr_test_4_expected, OSSL_NELEM(pkt_hdr_test_4_expected),
2157 pkt_hdr_test_4_payload, OSSL_NELEM(pkt_hdr_test_4_payload),
2158 0, sizeof(pkt_hdr_test_4_expected),
2159 19, 23
2160};
2161
2162/* Packet Header Test 5: Handshake */
2163static const unsigned char pkt_hdr_test_5_expected[] = {
2164 0xe0, /* Long|Fixed, Type=Handshake, PN Len=1 */
2165 0x00, 0x00, 0x00, 0x01, /* Version */
2166 0x03, /* DCID Length */
2167 0x70, 0x71, 0x72, /* DCID */
2168 0x08, 0xf0, 0x67, 0xa5, 0x50, 0x2a, 0x42, 0x62, 0xb5, /* SCID Length, SCID */
2169 0x14, /* Length=20 */
2170 0x33, /* Encoded PN */
2171 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* Payload */
2172 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
2173 0x20, 0x21, 0x22
2174};
2175
2176static const unsigned char pkt_hdr_test_5_payload[] = {
2177 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
2178 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
2179 0x20, 0x21, 0x22
2180};
2181
2182static const struct pkt_hdr_test pkt_hdr_test_5 = {
2183 {
2184 QUIC_PKT_TYPE_HANDSHAKE, /* type */
2185 0, /* spin bit */
2186 0, /* key phase */
2187 1, /* PN length */
2188 0, /* partial */
2189 1, /* fixed */
2190 1, /* version */
2191 { 3, {0x70, 0x71, 0x72} }, /* DCID */
2192 { 8, {0xf0, 0x67, 0xa5, 0x50, 0x2a, 0x42, 0x62, 0xb5 } }, /* SCID */
2193 { 0x33 }, /* PN */
2194 NULL, 0, /* Token */
2195 19, NULL /* Len/Data */
2196 },
2197 pkt_hdr_test_5_expected, OSSL_NELEM(pkt_hdr_test_5_expected),
2198 pkt_hdr_test_5_payload, OSSL_NELEM(pkt_hdr_test_5_payload),
2199 0, sizeof(pkt_hdr_test_5_expected),
2200 19, 23
2201};
2202
2203/* Packet Header Test 6: Retry */
2204static const unsigned char pkt_hdr_test_6_expected[] = {
2205 0xf0, /* Long|Fixed, Type=Retry */
2206 0x00, 0x00, 0x00, 0x01, /* Version */
2207 0x03, /* DCID Length */
2208 0x70, 0x71, 0x72, /* DCID */
2209 0x08, 0xf0, 0x67, 0xa5, 0x50, 0x2a, 0x42, 0x62, 0xb5, /* SCID Length, SCID */
2210 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* Retry Token */
2211 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
2212 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f /* Retry Integrity Tag */
2213};
2214
2215static const unsigned char pkt_hdr_test_6_payload[] = {
2216 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* Retry Token */
2217 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
2218 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f /* Retry Integrity Tag */
2219};
2220
2221static const struct pkt_hdr_test pkt_hdr_test_6 = {
2222 {
2223 QUIC_PKT_TYPE_RETRY, /* type */
2224 0, /* spin bit */
2225 0, /* key phase */
2226 0, /* PN length */
2227 0, /* partial */
2228 1, /* fixed */
2229 1, /* version */
2230 { 3, {0x70, 0x71, 0x72} }, /* DCID */
2231 { 8, {0xf0, 0x67, 0xa5, 0x50, 0x2a, 0x42, 0x62, 0xb5 } }, /* SCID */
2232 { 0 }, /* PN */
2233 NULL, 0, /* Token */
2234 24, NULL /* Len/Data */
2235 },
2236 pkt_hdr_test_6_expected, OSSL_NELEM(pkt_hdr_test_6_expected),
2237 pkt_hdr_test_6_payload, OSSL_NELEM(pkt_hdr_test_6_payload),
2238 0, 21,
2239 SIZE_MAX, SIZE_MAX
2240};
2241
2242/* Packet Header Test 7: 1-RTT */
2243static const unsigned char pkt_hdr_test_7_expected[] = {
2244 0x42, /* Short|Fixed, Type=1-RTT, PN Len=3 */
2245 0x70, 0x71, 0x72, /* DCID */
2246 0x50, 0x51, 0x52, /* PN */
2247 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
2248 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1
2249};
2250
2251static const unsigned char pkt_hdr_test_7_payload[] = {
2252 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
2253 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1
2254};
2255
2256static const struct pkt_hdr_test pkt_hdr_test_7 = {
2257 {
2258 QUIC_PKT_TYPE_1RTT, /* type */
2259 0, /* spin bit */
2260 0, /* key phase */
2261 3, /* PN length */
2262 0, /* partial */
2263 1, /* fixed */
2264 0, /* version */
2265 { 3, {0x70, 0x71, 0x72} }, /* DCID */
2266 { 0, {0} }, /* SCID */
2267 { 0x50, 0x51, 0x52 }, /* PN */
2268 NULL, 0, /* Token */
2269 18, NULL /* Len/Data */
2270 },
2271 pkt_hdr_test_7_expected, OSSL_NELEM(pkt_hdr_test_7_expected),
2272 pkt_hdr_test_7_payload, OSSL_NELEM(pkt_hdr_test_7_payload),
2273 3, 21,
2274 4, 8
2275};
2276
2277/* Packet Header Test 8: 1-RTT with Spin Bit */
2278static const unsigned char pkt_hdr_test_8_expected[] = {
2279 0x62, /* Short|Fixed, Type=1-RTT, PN Len=3, Spin=1 */
2280 0x70, 0x71, 0x72, /* DCID */
2281 0x50, 0x51, 0x52, /* PN */
2282 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
2283 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1
2284};
2285
2286static const unsigned char pkt_hdr_test_8_payload[] = {
2287 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
2288 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1
2289};
2290
2291static const struct pkt_hdr_test pkt_hdr_test_8 = {
2292 {
2293 QUIC_PKT_TYPE_1RTT, /* type */
2294 1, /* spin bit */
2295 0, /* key phase */
2296 3, /* PN length */
2297 0, /* partial */
2298 1, /* fixed */
2299 0, /* version */
2300 { 3, {0x70, 0x71, 0x72} }, /* DCID */
2301 { 0, {0} }, /* SCID */
2302 { 0x50, 0x51, 0x52 }, /* PN */
2303 NULL, 0, /* Token */
2304 18, NULL /* Len/Data */
2305 },
2306 pkt_hdr_test_8_expected, OSSL_NELEM(pkt_hdr_test_8_expected),
2307 pkt_hdr_test_8_payload, OSSL_NELEM(pkt_hdr_test_8_payload),
2308 3, 21,
2309 4, 8
2310};
2311
2312/* Packet Header Test 9: 1-RTT with Key Phase Bit */
2313static const unsigned char pkt_hdr_test_9_expected[] = {
2314 0x46, /* Short|Fixed, Type=1-RTT, PN Len=3, Key Phase=1 */
2315 0x70, 0x71, 0x72, /* DCID */
2316 0x50, 0x51, 0x52, /* PN */
2317 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
2318 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1
2319};
2320
2321static const unsigned char pkt_hdr_test_9_payload[] = {
2322 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
2323 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1
2324};
2325
2326static const struct pkt_hdr_test pkt_hdr_test_9 = {
2327 {
2328 QUIC_PKT_TYPE_1RTT, /* type */
2329 0, /* spin bit */
2330 1, /* key phase */
2331 3, /* PN length */
2332 0, /* partial */
2333 1, /* fixed */
2334 0, /* version */
2335 { 3, {0x70, 0x71, 0x72} }, /* DCID */
2336 { 0, {0} }, /* SCID */
2337 { 0x50, 0x51, 0x52 }, /* PN */
2338 NULL, 0, /* Token */
2339 18, NULL /* Len/Data */
2340 },
2341 pkt_hdr_test_9_expected, OSSL_NELEM(pkt_hdr_test_9_expected),
2342 pkt_hdr_test_9_payload, OSSL_NELEM(pkt_hdr_test_9_payload),
2343 3, 21,
2344 4, 8
2345};
2346
2347/* Packet Header Test 10: Handshake with 4-Byte PN */
2348static const unsigned char pkt_hdr_test_10_expected[] = {
2349 0xe3, /* Long|Fixed, Type=Handshake, PN Len=4 */
2350 0x00, 0x00, 0x00, 0x01, /* Version */
2351 0x03, /* DCID Length */
2352 0x70, 0x71, 0x72, /* DCID */
2353 0x08, 0xf0, 0x67, 0xa5, 0x50, 0x2a, 0x42, 0x62, 0xb5, /* SCID Length, SCID */
2354 0x17, /* Length=20 */
2355 0x33, 0x44, 0x55, 0x66, /* Encoded PN */
2356 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* Payload */
2357 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
2358 0x20, 0x21, 0x22
2359};
2360
2361static const unsigned char pkt_hdr_test_10_payload[] = {
2362 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
2363 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
2364 0x20, 0x21, 0x22
2365};
2366
2367static const struct pkt_hdr_test pkt_hdr_test_10 = {
2368 {
2369 QUIC_PKT_TYPE_HANDSHAKE, /* type */
2370 0, /* spin bit */
2371 0, /* key phase */
2372 4, /* PN length */
2373 0, /* partial */
2374 1, /* fixed */
2375 1, /* version */
2376 { 3, {0x70, 0x71, 0x72} }, /* DCID */
2377 { 8, {0xf0, 0x67, 0xa5, 0x50, 0x2a, 0x42, 0x62, 0xb5 } }, /* SCID */
2378 { 0x33, 0x44, 0x55, 0x66 }, /* PN */
2379 NULL, 0, /* Token */
2380 19, NULL /* Len/Data */
2381 },
2382 pkt_hdr_test_10_expected, OSSL_NELEM(pkt_hdr_test_10_expected),
2383 pkt_hdr_test_10_payload, OSSL_NELEM(pkt_hdr_test_10_payload),
2384 0, sizeof(pkt_hdr_test_10_expected),
2385 19, 23
2386};
2387
2388/* Packet Header Test 11: 1-RTT with 4-Byte PN */
2389static const unsigned char pkt_hdr_test_11_expected[] = {
2390 0x43, /* Short|Fixed, Type=1-RTT, PN Len=4 */
2391 0x70, 0x71, 0x72, /* DCID */
2392 0x50, 0x51, 0x52, 0x53, /* PN */
2393 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
2394 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1
2395};
2396
2397static const unsigned char pkt_hdr_test_11_payload[] = {
2398 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
2399 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1
2400};
2401
2402static const struct pkt_hdr_test pkt_hdr_test_11 = {
2403 {
2404 QUIC_PKT_TYPE_1RTT, /* type */
2405 0, /* spin bit */
2406 0, /* key phase */
2407 4, /* PN length */
2408 0, /* partial */
2409 1, /* fixed */
2410 0, /* version */
2411 { 3, {0x70, 0x71, 0x72} }, /* DCID */
2412 { 0, {0} }, /* SCID */
2413 { 0x50, 0x51, 0x52, 0x53 }, /* PN */
2414 NULL, 0, /* Token */
2415 18, NULL /* Len/Data */
2416 },
2417 pkt_hdr_test_11_expected, OSSL_NELEM(pkt_hdr_test_11_expected),
2418 pkt_hdr_test_11_payload, OSSL_NELEM(pkt_hdr_test_11_payload),
2419 3, 21,
2420 4, 8
2421};
2422
2423/* Packet Header Test 12: Version Negotiation */
2424static const unsigned char pkt_hdr_test_12_expected[] = {
2425 0xc0, /* Long|Fixed, Type=Version Neg */
2426 0x00, 0x00, 0x00, 0x00, /* Version (0) */
2427 0x03, 0x70, 0x71, 0x72, /* DCID */
2428 0x02, 0x81, 0x82, /* SCID */
2429 0x11, 0x22, 0x33, 0x44 /* One Version */
2430};
2431
2432static const unsigned char pkt_hdr_test_12_payload[] = {
2433 0x11, 0x22, 0x33, 0x44
2434};
2435
2436static const struct pkt_hdr_test pkt_hdr_test_12 = {
2437 {
2438 QUIC_PKT_TYPE_VERSION_NEG, /* type */
2439 0, /* spin bit */
2440 0, /* key phase */
2441 0, /* PN length */
2442 0, /* partial */
2443 1, /* fixed */
2444 0, /* version */
2445 { 3, {0x70, 0x71, 0x72} }, /* DCID */
2446 { 2, {0x81, 0x82} }, /* SCID */
2447 { 0 }, /* PN */
2448 NULL, 0, /* Token */
2449 4, NULL /* Len/Data */
2450 },
2451 pkt_hdr_test_12_expected, OSSL_NELEM(pkt_hdr_test_12_expected),
2452 pkt_hdr_test_12_payload, OSSL_NELEM(pkt_hdr_test_12_payload),
2453 0, 12,
2454 SIZE_MAX, SIZE_MAX
2455};
2456
2457/* Packet Header Test 13: Version Negotiation without Fixed Bit */
2458static const unsigned char pkt_hdr_test_13_expected[] = {
2459 0x80, /* Long|Fixed, Type=Version Neg */
2460 0x00, 0x00, 0x00, 0x00, /* Version (0) */
2461 0x03, 0x70, 0x71, 0x72, /* DCID */
2462 0x02, 0x81, 0x82, /* SCID */
2463 0x11, 0x22, 0x33, 0x44 /* One Version */
2464};
2465
2466static const unsigned char pkt_hdr_test_13_payload[] = {
2467 0x11, 0x22, 0x33, 0x44
2468};
2469
2470static const struct pkt_hdr_test pkt_hdr_test_13 = {
2471 {
2472 QUIC_PKT_TYPE_VERSION_NEG, /* type */
2473 0, /* spin bit */
2474 0, /* key phase */
2475 0, /* PN length */
2476 0, /* partial */
2477 0, /* fixed */
2478 0, /* version */
2479 { 3, {0x70, 0x71, 0x72} }, /* DCID */
2480 { 2, {0x81, 0x82} }, /* SCID */
2481 { 0 }, /* PN */
2482 NULL, 0, /* Token */
2483 4, NULL /* Len/Data */
2484 },
2485 pkt_hdr_test_13_expected, OSSL_NELEM(pkt_hdr_test_13_expected),
2486 pkt_hdr_test_13_payload, OSSL_NELEM(pkt_hdr_test_13_payload),
2487 0, 12,
2488 SIZE_MAX, SIZE_MAX
2489};
2490
2491/* Packet Header Test 14: 1-RTT - Malformed - No Fixed Bit */
2492static const unsigned char pkt_hdr_test_14_expected[] = {
2493 0x02, /* Fixed, Type=1-RTT, PN Len=3 */
2494 0x70, 0x71, 0x72, /* DCID */
2495 0x50, 0x51, 0x52, /* PN */
2496 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
2497 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1
2498};
2499
2500static const struct pkt_hdr_test pkt_hdr_test_14 = {
2501 { 0 },
2502 pkt_hdr_test_14_expected, OSSL_NELEM(pkt_hdr_test_14_expected),
2503 NULL, 0,
2504 3, SIZE_MAX,
2505 4, 8
2506};
2507
2508/* Packet Header Test 15: Handshake - Malformed - No Fixed Bit */
2509static const unsigned char pkt_hdr_test_15_expected[] = {
2510 0xa0, /* Long, Type=Handshake, PN Len=1 */
2511 0x00, 0x00, 0x00, 0x01, /* Version */
2512 0x03, /* DCID Length */
2513 0x70, 0x71, 0x72, /* DCID */
2514 0x08, 0xf0, 0x67, 0xa5, 0x50, 0x2a, 0x42, 0x62, 0xb5, /* SCID Length, SCID */
2515 0x14, /* Length=20 */
2516 0x33, /* Encoded PN */
2517 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* Payload */
2518 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
2519 0x20, 0x21, 0x22
2520};
2521
2522static const struct pkt_hdr_test pkt_hdr_test_15 = {
2523 { 0 },
2524 pkt_hdr_test_15_expected, OSSL_NELEM(pkt_hdr_test_15_expected),
2525 NULL, 0,
2526 0, SIZE_MAX,
2527 19, 23
2528};
2529
2530/* Packet Header Test 16: Handshake - Malformed - Wrong Version */
2531static const unsigned char pkt_hdr_test_16_expected[] = {
2532 0xe0, /* Long|Fixed, Type=Handshake, PN Len=1 */
2533 0x00, 0x00, 0x00, 0x02, /* Version */
2534 0x03, /* DCID Length */
2535 0x70, 0x71, 0x72, /* DCID */
2536 0x08, 0xf0, 0x67, 0xa5, 0x50, 0x2a, 0x42, 0x62, 0xb5, /* SCID Length, SCID */
2537 0x14, /* Length=20 */
2538 0x33, /* Encoded PN */
2539 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* Payload */
2540 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
2541 0x20, 0x21, 0x22
2542};
2543
2544static const struct pkt_hdr_test pkt_hdr_test_16 = {
2545 { 0 },
2546 pkt_hdr_test_16_expected, OSSL_NELEM(pkt_hdr_test_16_expected),
2547 NULL, 0,
2548 0, SIZE_MAX,
2549 19, 23
2550};
2551
2552static const struct pkt_hdr_test *const pkt_hdr_tests[] = {
2553 &pkt_hdr_test_1,
2554 &pkt_hdr_test_2,
2555 &pkt_hdr_test_3,
2556 &pkt_hdr_test_4,
2557 &pkt_hdr_test_5,
2558 &pkt_hdr_test_6,
2559 &pkt_hdr_test_7,
2560 &pkt_hdr_test_8,
2561 &pkt_hdr_test_9,
2562 &pkt_hdr_test_10,
2563 &pkt_hdr_test_11,
2564 &pkt_hdr_test_12,
2565 &pkt_hdr_test_13,
2566 &pkt_hdr_test_14,
2567 &pkt_hdr_test_15,
2568 &pkt_hdr_test_16
2569};
2570
2571#define HPR_REPEAT_COUNT 4
2572#define HPR_CIPHER_COUNT 3
2573
2574/*
2575 * Count of number of times we observed an unchanged (u) or changed (c) bit in
2576 * each header-protectable bit over all test suites.
2577 */
2578static unsigned int counts_u[HPR_CIPHER_COUNT][37] = {0};
2579static unsigned int counts_c[HPR_CIPHER_COUNT][37] = {0};
2580
2581static int test_wire_pkt_hdr_actual(int tidx, int repeat, int cipher,
2582 size_t trunc_len)
2583{
2584 int testresult = 0;
2585 const struct pkt_hdr_test *t = pkt_hdr_tests[tidx];
2586 QUIC_PKT_HDR hdr = {0};
2587 QUIC_PKT_HDR_PTRS ptrs = {0}, wptrs = {0};
2588 PACKET pkt = {0};
2589 WPACKET wpkt = {0};
2590 BUF_MEM *buf = NULL;
2591 size_t l = 0, i, j;
2592 QUIC_HDR_PROTECTOR hpr = {0};
2593 unsigned char hpr_key[32] = {0,1,2,3,4,5,6,7};
2594 int have_hpr = 0, hpr_cipher_id, hpr_key_len;
2595 unsigned char *hbuf = NULL;
2596 int is_trunc = trunc_len < t->expected_len;
2597 int expect_fail = trunc_len < t->min_success_len;
2598 hpr_key[8] = (unsigned char)tidx;
2599 hpr_key[9] = (unsigned char)repeat;
2600
2601 switch (cipher) {
2602 case 0:
2603 hpr_cipher_id = QUIC_HDR_PROT_CIPHER_AES_128;
2604 hpr_key_len = 16;
2605 break;
2606 case 1:
2607 hpr_cipher_id = QUIC_HDR_PROT_CIPHER_AES_256;
2608 hpr_key_len = 32;
2609 break;
2610 case 2:
681c4619
P
2611 /*
2612 * In a build without CHACHA, we rerun the AES 256 tests.
2613 * Removing all dependence on CHACHA is more difficult and these
2614 * tests are fast enough.
2615 */
2616#ifndef OPENSSL_NO_CHACHA
ec279ac2 2617 hpr_cipher_id = QUIC_HDR_PROT_CIPHER_CHACHA;
681c4619
P
2618#else
2619 hpr_cipher_id = QUIC_HDR_PROT_CIPHER_AES_256;
2620#endif
ec279ac2
HL
2621 hpr_key_len = 32;
2622 break;
2623 default:
2624 goto err;
2625 }
2626
2627 if (!TEST_ptr(buf = BUF_MEM_new()))
2628 goto err;
2629
2630 if (!TEST_true(WPACKET_init(&wpkt, buf)))
2631 goto err;
2632
2633 if (!TEST_true(PACKET_buf_init(&pkt, t->expected, trunc_len)))
2634 goto err;
2635
2636 if (!TEST_int_eq(ossl_quic_wire_decode_pkt_hdr(&pkt, t->short_conn_id_len,
2637 0, &hdr, &ptrs),
2638 !expect_fail))
2639 goto err;
2640
2641 if (!expect_fail && !is_trunc) {
2642 if (!TEST_true(cmp_pkt_hdr(&hdr, &t->hdr, t->payload, t->payload_len, 1)))
2643 goto err;
2644
2645 if (!TEST_ptr_eq(ptrs.raw_start, t->expected))
2646 goto err;
2647
2648 if (t->pn_offset == SIZE_MAX) {
2649 if (!TEST_ptr_null(ptrs.raw_pn))
2650 goto err;
2651 } else {
2652 if (!TEST_ptr_eq(ptrs.raw_pn, t->expected + t->pn_offset))
2653 goto err;
2654 }
2655
2656 if (t->sample_offset != SIZE_MAX) {
2657 if (!TEST_ptr_eq(ptrs.raw_sample, t->expected + t->sample_offset))
2658 goto err;
2659 if (!TEST_size_t_eq(ptrs.raw_sample_len,
2660 t->expected_len - t->sample_offset))
2661 goto err;
2662 }
2663
2664 if (!TEST_true(ossl_quic_wire_encode_pkt_hdr(&wpkt, t->short_conn_id_len, &hdr, &wptrs)))
2665 goto err;
2666
2667 if (!TEST_true(WPACKET_memcpy(&wpkt, t->payload, t->payload_len)))
2668 goto err;
2669
2670 if (!TEST_true(WPACKET_get_total_written(&wpkt, &l)))
2671 goto err;
2672
2673 if (!TEST_mem_eq(buf->data, l, t->expected, t->expected_len))
2674 goto err;
2675
2676 /* Test header protection. */
2677 if (t->sample_offset != SIZE_MAX) { /* if packet type has protection */
2678 if (!TEST_true(ossl_quic_hdr_protector_init(&hpr, NULL, NULL,
2679 hpr_cipher_id,
2680 hpr_key,
2681 hpr_key_len)))
2682 goto err;
2683
2684 have_hpr = 1;
2685
2686 /*
2687 * Copy into a duplicate buffer to test header protection by
2688 * comparing it against the original.
2689 */
2690 hbuf = OPENSSL_malloc(t->expected_len);
2691 if (!TEST_ptr(hbuf))
2692 goto err;
2693
2694 memcpy(hbuf, t->expected, t->expected_len);
2695
2696 /* Fixup pointers to new buffer and encrypt. */
2697 ptrs.raw_pn = hbuf + (ptrs.raw_pn - ptrs.raw_start);
2698 ptrs.raw_sample = hbuf + (ptrs.raw_sample - ptrs.raw_start);
2699 ptrs.raw_start = hbuf;
2700 if (!TEST_true(ossl_quic_hdr_protector_encrypt(&hpr, &ptrs)))
2701 goto err;
2702
2703 /* Ensure that bytes which should not have changed did not change */
2704 for (i = 0; i < t->expected_len; ++i) {
2705 unsigned char d = t->expected[i] ^ hbuf[i], rej_mask = 0xff;
2706 size_t jrel = 0;
2707 if (i == 0) {
2708 /* Bits in first byte which must not change */
2709 rej_mask = (t->hdr.type == QUIC_PKT_TYPE_1RTT) ? ~0x1f : ~0xf;
2710 } else if (i >= t->pn_offset && i < t->pn_offset + t->hdr.pn_len) {
2711 /* PN bytes change */
2712 rej_mask = 0;
2713 jrel = 5 + (i - t->pn_offset) * 8;
2714 }
2715
2716 if (rej_mask != 0xff)
2717 for (j = 0; j < 8; ++j) {
2718 if (((1U << j) & rej_mask) != 0)
2719 /*
2720 * Bit unrelated to header protection, do not record
2721 * stats about it.
2722 */
2723 continue;
2724
2725 OPENSSL_assert(jrel + j < OSSL_NELEM(counts_u[cipher]));
2726 if ((d & (1U << j)) != 0)
2727 ++counts_c[cipher][jrel + j]; /* bit did change */
2728 else
2729 ++counts_u[cipher][jrel + j]; /* bit did not change */
2730 }
2731
2732 /* Bits in rej_mask must not change */
2733 if (!TEST_int_eq(d & rej_mask, 0))
2734 goto err;
2735 }
2736
2737 /* Decrypt and check matches original. */
2738 if (!TEST_true(ossl_quic_hdr_protector_decrypt(&hpr, &ptrs)))
2739 goto err;
2740
2741 if (!TEST_mem_eq(hbuf, t->expected_len, t->expected, t->expected_len))
2742 goto err;
2743 }
2744 }
2745
2746 testresult = 1;
2747err:
2748 if (have_hpr)
948c656c 2749 ossl_quic_hdr_protector_cleanup(&hpr);
ec279ac2
HL
2750 WPACKET_finish(&wpkt);
2751 BUF_MEM_free(buf);
2752 OPENSSL_free(hbuf);
2753 return testresult;
2754}
2755
2756static int test_wire_pkt_hdr_inner(int tidx, int repeat, int cipher)
2757{
2758 int testresult = 0;
2759 const struct pkt_hdr_test *t = pkt_hdr_tests[tidx];
2760 size_t i;
2761
2762 /* Test with entire packet */
2763 if (!TEST_true(test_wire_pkt_hdr_actual(tidx, repeat, cipher,
2764 t->expected_len)))
2765 goto err;
2766
2767 /* Now repeat for every possible truncation of the packet */
2768 for (i = 0; i < t->expected_len; ++i)
2769 if (!TEST_true(test_wire_pkt_hdr_actual(tidx, repeat, cipher, i)))
2770 goto err;
2771
2772 testresult = 1;
2773err:
2774 return testresult;
2775}
2776
2777static int test_hdr_prot_stats(void)
2778{
2779 int testresult = 0;
2780 size_t i, cipher;
2781
2782 /*
2783 * Test that, across all previously executed tests for each header
2784 * protection cipher, every bit which can have header protection applied a)
2785 * was changed in at least one test of applying header protection, and b)
2786 * was unchanged in at least one test of applying header protection.
2787 */
2788 for (cipher = 0; cipher < HPR_CIPHER_COUNT; ++cipher)
2789 for (i = 0; i < OSSL_NELEM(counts_u[0]); ++i) {
681c4619 2790 if (!TEST_uint_gt(counts_u[cipher][i], 0))
ec279ac2 2791 goto err;
681c4619 2792 if (!TEST_uint_gt(counts_c[cipher][i], 0))
ec279ac2
HL
2793 goto err;
2794 }
2795
2796 testresult = 1;
2797err:
2798 return testresult;
2799}
2800
2801#define NUM_WIRE_PKT_HDR_TESTS \
2802 (OSSL_NELEM(pkt_hdr_tests) * HPR_REPEAT_COUNT * HPR_CIPHER_COUNT)
2803
2804static int test_wire_pkt_hdr(int idx)
2805{
2806 int tidx, repeat, cipher;
2807
2808 if (idx == NUM_WIRE_PKT_HDR_TESTS)
2809 return test_hdr_prot_stats();
2810
2811 cipher = idx % HPR_CIPHER_COUNT;
2812 idx /= HPR_CIPHER_COUNT;
2813
2814 repeat = idx % HPR_REPEAT_COUNT;
2815 idx /= HPR_REPEAT_COUNT;
2816
2817 tidx = idx;
2818
2819 return test_wire_pkt_hdr_inner(tidx, repeat, cipher);
2820}
2821
19571483
HL
2822/* TX Tests */
2823#define TX_TEST_OP_END 0 /* end of script */
2824#define TX_TEST_OP_WRITE 1 /* write packet */
2825#define TX_TEST_OP_PROVIDE_SECRET 2 /* provide TX secret */
2826#define TX_TEST_OP_PROVIDE_SECRET_INITIAL 3 /* provide TX secret for initial */
2827#define TX_TEST_OP_DISCARD_EL 4 /* discard an encryption level */
2828#define TX_TEST_OP_CHECK_DGRAM 5 /* read datagram, compare to expected */
2829#define TX_TEST_OP_CHECK_NO_DGRAM 6 /* check no datagram is in queue */
948c656c 2830#define TX_TEST_OP_KEY_UPDATE 7 /* perform key update for 1-RTT */
19571483
HL
2831
2832struct tx_test_op {
2833 unsigned char op;
2834 const unsigned char *buf;
2835 size_t buf_len;
2836 const OSSL_QTX_PKT *pkt;
2837 uint32_t enc_level, suite_id;
2838 const QUIC_CONN_ID *dcid;
2839};
2840
2841#define TX_OP_END \
2842 { TX_TEST_OP_END }
2843#define TX_OP_WRITE(pkt) \
2844 { TX_TEST_OP_WRITE, NULL, 0, &(pkt), 0, 0, NULL },
2845#define TX_OP_PROVIDE_SECRET(el, suite, key) \
2846 { \
2847 TX_TEST_OP_PROVIDE_SECRET, (key), sizeof(key), \
2848 NULL, (el), (suite), NULL \
2849 },
2850#define TX_OP_PROVIDE_SECRET_INITIAL(dcid, is_server) \
2851 { TX_TEST_OP_PROVIDE_SECRET_INITIAL, \
2852 NULL, 0, NULL, 0, (is_server), &(dcid) },
2853#define TX_OP_DISCARD_EL(el) \
2854 { TX_TEST_OP_DISCARD_EL, NULL, 0, NULL, (el), 0, NULL },
2855#define TX_OP_CHECK_DGRAM(expect_dgram) \
2856 { \
2857 TX_TEST_OP_CHECK_DGRAM, (expect_dgram), sizeof(expect_dgram), \
2858 NULL, 0, 0, NULL \
2859 },
2860#define TX_OP_CHECK_NO_DGRAM() \
2861 { TX_TEST_OP_CHECK_NO_PKT, NULL, 0, NULL, 0, 0, NULL },
2862
2863#define TX_OP_WRITE_N(n) \
2864 TX_OP_WRITE(tx_script_##n##_pkt)
2865#define TX_OP_CHECK_DGRAM_N(n) \
2866 TX_OP_CHECK_DGRAM(tx_script_##n##_dgram)
2867
2868#define TX_OP_WRITE_CHECK(n) \
2869 TX_OP_WRITE_N(n) \
2870 TX_OP_CHECK_DGRAM_N(n)
2871
948c656c
HL
2872#define TX_OP_KEY_UPDATE() \
2873 { TX_TEST_OP_KEY_UPDATE, NULL, 0, NULL, 0, 0, NULL },
2874
19571483
HL
2875/* 1. RFC 9001 - A.2 Client Initial */
2876static const unsigned char tx_script_1_body[1162] = {
2877 0x06, 0x00, 0x40, 0xf1, 0x01, 0x00, 0x00, 0xed, 0x03, 0x03, 0xeb, 0xf8,
2878 0xfa, 0x56, 0xf1, 0x29, 0x39, 0xb9, 0x58, 0x4a, 0x38, 0x96, 0x47, 0x2e,
2879 0xc4, 0x0b, 0xb8, 0x63, 0xcf, 0xd3, 0xe8, 0x68, 0x04, 0xfe, 0x3a, 0x47,
2880 0xf0, 0x6a, 0x2b, 0x69, 0x48, 0x4c, 0x00, 0x00, 0x04, 0x13, 0x01, 0x13,
2881 0x02, 0x01, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x10, 0x00, 0x0e, 0x00,
2882 0x00, 0x0b, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f,
2883 0x6d, 0xff, 0x01, 0x00, 0x01, 0x00, 0x00, 0x0a, 0x00, 0x08, 0x00, 0x06,
2884 0x00, 0x1d, 0x00, 0x17, 0x00, 0x18, 0x00, 0x10, 0x00, 0x07, 0x00, 0x05,
2885 0x04, 0x61, 0x6c, 0x70, 0x6e, 0x00, 0x05, 0x00, 0x05, 0x01, 0x00, 0x00,
2886 0x00, 0x00, 0x00, 0x33, 0x00, 0x26, 0x00, 0x24, 0x00, 0x1d, 0x00, 0x20,
2887 0x93, 0x70, 0xb2, 0xc9, 0xca, 0xa4, 0x7f, 0xba, 0xba, 0xf4, 0x55, 0x9f,
2888 0xed, 0xba, 0x75, 0x3d, 0xe1, 0x71, 0xfa, 0x71, 0xf5, 0x0f, 0x1c, 0xe1,
2889 0x5d, 0x43, 0xe9, 0x94, 0xec, 0x74, 0xd7, 0x48, 0x00, 0x2b, 0x00, 0x03,
2890 0x02, 0x03, 0x04, 0x00, 0x0d, 0x00, 0x10, 0x00, 0x0e, 0x04, 0x03, 0x05,
2891 0x03, 0x06, 0x03, 0x02, 0x03, 0x08, 0x04, 0x08, 0x05, 0x08, 0x06, 0x00,
2892 0x2d, 0x00, 0x02, 0x01, 0x01, 0x00, 0x1c, 0x00, 0x02, 0x40, 0x01, 0x00,
2893 0x39, 0x00, 0x32, 0x04, 0x08, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
2894 0xff, 0x05, 0x04, 0x80, 0x00, 0xff, 0xff, 0x07, 0x04, 0x80, 0x00, 0xff,
2895 0xff, 0x08, 0x01, 0x10, 0x01, 0x04, 0x80, 0x00, 0x75, 0x30, 0x09, 0x01,
2896 0x10, 0x0f, 0x08, 0x83, 0x94, 0xc8, 0xf0, 0x3e, 0x51, 0x57, 0x08, 0x06,
2897 0x04, 0x80, 0x00, 0xff, 0xff /* followed by zero padding */
2898};
2899
2900static const unsigned char tx_script_1_dgram[] = {
2901 0xc0, 0x00, 0x00, 0x00, 0x01, 0x08, 0x83, 0x94, 0xc8, 0xf0, 0x3e, 0x51,
2902 0x57, 0x08, 0x00, 0x00, 0x44, 0x9e, 0x7b, 0x9a, 0xec, 0x34, 0xd1, 0xb1,
2903 0xc9, 0x8d, 0xd7, 0x68, 0x9f, 0xb8, 0xec, 0x11, 0xd2, 0x42, 0xb1, 0x23,
2904 0xdc, 0x9b, 0xd8, 0xba, 0xb9, 0x36, 0xb4, 0x7d, 0x92, 0xec, 0x35, 0x6c,
2905 0x0b, 0xab, 0x7d, 0xf5, 0x97, 0x6d, 0x27, 0xcd, 0x44, 0x9f, 0x63, 0x30,
2906 0x00, 0x99, 0xf3, 0x99, 0x1c, 0x26, 0x0e, 0xc4, 0xc6, 0x0d, 0x17, 0xb3,
2907 0x1f, 0x84, 0x29, 0x15, 0x7b, 0xb3, 0x5a, 0x12, 0x82, 0xa6, 0x43, 0xa8,
2908 0xd2, 0x26, 0x2c, 0xad, 0x67, 0x50, 0x0c, 0xad, 0xb8, 0xe7, 0x37, 0x8c,
2909 0x8e, 0xb7, 0x53, 0x9e, 0xc4, 0xd4, 0x90, 0x5f, 0xed, 0x1b, 0xee, 0x1f,
2910 0xc8, 0xaa, 0xfb, 0xa1, 0x7c, 0x75, 0x0e, 0x2c, 0x7a, 0xce, 0x01, 0xe6,
2911 0x00, 0x5f, 0x80, 0xfc, 0xb7, 0xdf, 0x62, 0x12, 0x30, 0xc8, 0x37, 0x11,
2912 0xb3, 0x93, 0x43, 0xfa, 0x02, 0x8c, 0xea, 0x7f, 0x7f, 0xb5, 0xff, 0x89,
2913 0xea, 0xc2, 0x30, 0x82, 0x49, 0xa0, 0x22, 0x52, 0x15, 0x5e, 0x23, 0x47,
2914 0xb6, 0x3d, 0x58, 0xc5, 0x45, 0x7a, 0xfd, 0x84, 0xd0, 0x5d, 0xff, 0xfd,
2915 0xb2, 0x03, 0x92, 0x84, 0x4a, 0xe8, 0x12, 0x15, 0x46, 0x82, 0xe9, 0xcf,
2916 0x01, 0x2f, 0x90, 0x21, 0xa6, 0xf0, 0xbe, 0x17, 0xdd, 0xd0, 0xc2, 0x08,
2917 0x4d, 0xce, 0x25, 0xff, 0x9b, 0x06, 0xcd, 0xe5, 0x35, 0xd0, 0xf9, 0x20,
2918 0xa2, 0xdb, 0x1b, 0xf3, 0x62, 0xc2, 0x3e, 0x59, 0x6d, 0x11, 0xa4, 0xf5,
2919 0xa6, 0xcf, 0x39, 0x48, 0x83, 0x8a, 0x3a, 0xec, 0x4e, 0x15, 0xda, 0xf8,
2920 0x50, 0x0a, 0x6e, 0xf6, 0x9e, 0xc4, 0xe3, 0xfe, 0xb6, 0xb1, 0xd9, 0x8e,
2921 0x61, 0x0a, 0xc8, 0xb7, 0xec, 0x3f, 0xaf, 0x6a, 0xd7, 0x60, 0xb7, 0xba,
2922 0xd1, 0xdb, 0x4b, 0xa3, 0x48, 0x5e, 0x8a, 0x94, 0xdc, 0x25, 0x0a, 0xe3,
2923 0xfd, 0xb4, 0x1e, 0xd1, 0x5f, 0xb6, 0xa8, 0xe5, 0xeb, 0xa0, 0xfc, 0x3d,
2924 0xd6, 0x0b, 0xc8, 0xe3, 0x0c, 0x5c, 0x42, 0x87, 0xe5, 0x38, 0x05, 0xdb,
2925 0x05, 0x9a, 0xe0, 0x64, 0x8d, 0xb2, 0xf6, 0x42, 0x64, 0xed, 0x5e, 0x39,
2926 0xbe, 0x2e, 0x20, 0xd8, 0x2d, 0xf5, 0x66, 0xda, 0x8d, 0xd5, 0x99, 0x8c,
2927 0xca, 0xbd, 0xae, 0x05, 0x30, 0x60, 0xae, 0x6c, 0x7b, 0x43, 0x78, 0xe8,
2928 0x46, 0xd2, 0x9f, 0x37, 0xed, 0x7b, 0x4e, 0xa9, 0xec, 0x5d, 0x82, 0xe7,
2929 0x96, 0x1b, 0x7f, 0x25, 0xa9, 0x32, 0x38, 0x51, 0xf6, 0x81, 0xd5, 0x82,
2930 0x36, 0x3a, 0xa5, 0xf8, 0x99, 0x37, 0xf5, 0xa6, 0x72, 0x58, 0xbf, 0x63,
2931 0xad, 0x6f, 0x1a, 0x0b, 0x1d, 0x96, 0xdb, 0xd4, 0xfa, 0xdd, 0xfc, 0xef,
2932 0xc5, 0x26, 0x6b, 0xa6, 0x61, 0x17, 0x22, 0x39, 0x5c, 0x90, 0x65, 0x56,
2933 0xbe, 0x52, 0xaf, 0xe3, 0xf5, 0x65, 0x63, 0x6a, 0xd1, 0xb1, 0x7d, 0x50,
2934 0x8b, 0x73, 0xd8, 0x74, 0x3e, 0xeb, 0x52, 0x4b, 0xe2, 0x2b, 0x3d, 0xcb,
2935 0xc2, 0xc7, 0x46, 0x8d, 0x54, 0x11, 0x9c, 0x74, 0x68, 0x44, 0x9a, 0x13,
2936 0xd8, 0xe3, 0xb9, 0x58, 0x11, 0xa1, 0x98, 0xf3, 0x49, 0x1d, 0xe3, 0xe7,
2937 0xfe, 0x94, 0x2b, 0x33, 0x04, 0x07, 0xab, 0xf8, 0x2a, 0x4e, 0xd7, 0xc1,
2938 0xb3, 0x11, 0x66, 0x3a, 0xc6, 0x98, 0x90, 0xf4, 0x15, 0x70, 0x15, 0x85,
2939 0x3d, 0x91, 0xe9, 0x23, 0x03, 0x7c, 0x22, 0x7a, 0x33, 0xcd, 0xd5, 0xec,
2940 0x28, 0x1c, 0xa3, 0xf7, 0x9c, 0x44, 0x54, 0x6b, 0x9d, 0x90, 0xca, 0x00,
2941 0xf0, 0x64, 0xc9, 0x9e, 0x3d, 0xd9, 0x79, 0x11, 0xd3, 0x9f, 0xe9, 0xc5,
2942 0xd0, 0xb2, 0x3a, 0x22, 0x9a, 0x23, 0x4c, 0xb3, 0x61, 0x86, 0xc4, 0x81,
2943 0x9e, 0x8b, 0x9c, 0x59, 0x27, 0x72, 0x66, 0x32, 0x29, 0x1d, 0x6a, 0x41,
2944 0x82, 0x11, 0xcc, 0x29, 0x62, 0xe2, 0x0f, 0xe4, 0x7f, 0xeb, 0x3e, 0xdf,
2945 0x33, 0x0f, 0x2c, 0x60, 0x3a, 0x9d, 0x48, 0xc0, 0xfc, 0xb5, 0x69, 0x9d,
2946 0xbf, 0xe5, 0x89, 0x64, 0x25, 0xc5, 0xba, 0xc4, 0xae, 0xe8, 0x2e, 0x57,
2947 0xa8, 0x5a, 0xaf, 0x4e, 0x25, 0x13, 0xe4, 0xf0, 0x57, 0x96, 0xb0, 0x7b,
2948 0xa2, 0xee, 0x47, 0xd8, 0x05, 0x06, 0xf8, 0xd2, 0xc2, 0x5e, 0x50, 0xfd,
2949 0x14, 0xde, 0x71, 0xe6, 0xc4, 0x18, 0x55, 0x93, 0x02, 0xf9, 0x39, 0xb0,
2950 0xe1, 0xab, 0xd5, 0x76, 0xf2, 0x79, 0xc4, 0xb2, 0xe0, 0xfe, 0xb8, 0x5c,
2951 0x1f, 0x28, 0xff, 0x18, 0xf5, 0x88, 0x91, 0xff, 0xef, 0x13, 0x2e, 0xef,
2952 0x2f, 0xa0, 0x93, 0x46, 0xae, 0xe3, 0x3c, 0x28, 0xeb, 0x13, 0x0f, 0xf2,
2953 0x8f, 0x5b, 0x76, 0x69, 0x53, 0x33, 0x41, 0x13, 0x21, 0x19, 0x96, 0xd2,
2954 0x00, 0x11, 0xa1, 0x98, 0xe3, 0xfc, 0x43, 0x3f, 0x9f, 0x25, 0x41, 0x01,
2955 0x0a, 0xe1, 0x7c, 0x1b, 0xf2, 0x02, 0x58, 0x0f, 0x60, 0x47, 0x47, 0x2f,
2956 0xb3, 0x68, 0x57, 0xfe, 0x84, 0x3b, 0x19, 0xf5, 0x98, 0x40, 0x09, 0xdd,
2957 0xc3, 0x24, 0x04, 0x4e, 0x84, 0x7a, 0x4f, 0x4a, 0x0a, 0xb3, 0x4f, 0x71,
2958 0x95, 0x95, 0xde, 0x37, 0x25, 0x2d, 0x62, 0x35, 0x36, 0x5e, 0x9b, 0x84,
2959 0x39, 0x2b, 0x06, 0x10, 0x85, 0x34, 0x9d, 0x73, 0x20, 0x3a, 0x4a, 0x13,
2960 0xe9, 0x6f, 0x54, 0x32, 0xec, 0x0f, 0xd4, 0xa1, 0xee, 0x65, 0xac, 0xcd,
2961 0xd5, 0xe3, 0x90, 0x4d, 0xf5, 0x4c, 0x1d, 0xa5, 0x10, 0xb0, 0xff, 0x20,
2962 0xdc, 0xc0, 0xc7, 0x7f, 0xcb, 0x2c, 0x0e, 0x0e, 0xb6, 0x05, 0xcb, 0x05,
2963 0x04, 0xdb, 0x87, 0x63, 0x2c, 0xf3, 0xd8, 0xb4, 0xda, 0xe6, 0xe7, 0x05,
2964 0x76, 0x9d, 0x1d, 0xe3, 0x54, 0x27, 0x01, 0x23, 0xcb, 0x11, 0x45, 0x0e,
2965 0xfc, 0x60, 0xac, 0x47, 0x68, 0x3d, 0x7b, 0x8d, 0x0f, 0x81, 0x13, 0x65,
2966 0x56, 0x5f, 0xd9, 0x8c, 0x4c, 0x8e, 0xb9, 0x36, 0xbc, 0xab, 0x8d, 0x06,
2967 0x9f, 0xc3, 0x3b, 0xd8, 0x01, 0xb0, 0x3a, 0xde, 0xa2, 0xe1, 0xfb, 0xc5,
2968 0xaa, 0x46, 0x3d, 0x08, 0xca, 0x19, 0x89, 0x6d, 0x2b, 0xf5, 0x9a, 0x07,
2969 0x1b, 0x85, 0x1e, 0x6c, 0x23, 0x90, 0x52, 0x17, 0x2f, 0x29, 0x6b, 0xfb,
2970 0x5e, 0x72, 0x40, 0x47, 0x90, 0xa2, 0x18, 0x10, 0x14, 0xf3, 0xb9, 0x4a,
2971 0x4e, 0x97, 0xd1, 0x17, 0xb4, 0x38, 0x13, 0x03, 0x68, 0xcc, 0x39, 0xdb,
2972 0xb2, 0xd1, 0x98, 0x06, 0x5a, 0xe3, 0x98, 0x65, 0x47, 0x92, 0x6c, 0xd2,
2973 0x16, 0x2f, 0x40, 0xa2, 0x9f, 0x0c, 0x3c, 0x87, 0x45, 0xc0, 0xf5, 0x0f,
2974 0xba, 0x38, 0x52, 0xe5, 0x66, 0xd4, 0x45, 0x75, 0xc2, 0x9d, 0x39, 0xa0,
2975 0x3f, 0x0c, 0xda, 0x72, 0x19, 0x84, 0xb6, 0xf4, 0x40, 0x59, 0x1f, 0x35,
2976 0x5e, 0x12, 0xd4, 0x39, 0xff, 0x15, 0x0a, 0xab, 0x76, 0x13, 0x49, 0x9d,
2977 0xbd, 0x49, 0xad, 0xab, 0xc8, 0x67, 0x6e, 0xef, 0x02, 0x3b, 0x15, 0xb6,
2978 0x5b, 0xfc, 0x5c, 0xa0, 0x69, 0x48, 0x10, 0x9f, 0x23, 0xf3, 0x50, 0xdb,
2979 0x82, 0x12, 0x35, 0x35, 0xeb, 0x8a, 0x74, 0x33, 0xbd, 0xab, 0xcb, 0x90,
2980 0x92, 0x71, 0xa6, 0xec, 0xbc, 0xb5, 0x8b, 0x93, 0x6a, 0x88, 0xcd, 0x4e,
2981 0x8f, 0x2e, 0x6f, 0xf5, 0x80, 0x01, 0x75, 0xf1, 0x13, 0x25, 0x3d, 0x8f,
2982 0xa9, 0xca, 0x88, 0x85, 0xc2, 0xf5, 0x52, 0xe6, 0x57, 0xdc, 0x60, 0x3f,
2983 0x25, 0x2e, 0x1a, 0x8e, 0x30, 0x8f, 0x76, 0xf0, 0xbe, 0x79, 0xe2, 0xfb,
2984 0x8f, 0x5d, 0x5f, 0xbb, 0xe2, 0xe3, 0x0e, 0xca, 0xdd, 0x22, 0x07, 0x23,
2985 0xc8, 0xc0, 0xae, 0xa8, 0x07, 0x8c, 0xdf, 0xcb, 0x38, 0x68, 0x26, 0x3f,
2986 0xf8, 0xf0, 0x94, 0x00, 0x54, 0xda, 0x48, 0x78, 0x18, 0x93, 0xa7, 0xe4,
2987 0x9a, 0xd5, 0xaf, 0xf4, 0xaf, 0x30, 0x0c, 0xd8, 0x04, 0xa6, 0xb6, 0x27,
2988 0x9a, 0xb3, 0xff, 0x3a, 0xfb, 0x64, 0x49, 0x1c, 0x85, 0x19, 0x4a, 0xab,
2989 0x76, 0x0d, 0x58, 0xa6, 0x06, 0x65, 0x4f, 0x9f, 0x44, 0x00, 0xe8, 0xb3,
2990 0x85, 0x91, 0x35, 0x6f, 0xbf, 0x64, 0x25, 0xac, 0xa2, 0x6d, 0xc8, 0x52,
2991 0x44, 0x25, 0x9f, 0xf2, 0xb1, 0x9c, 0x41, 0xb9, 0xf9, 0x6f, 0x3c, 0xa9,
2992 0xec, 0x1d, 0xde, 0x43, 0x4d, 0xa7, 0xd2, 0xd3, 0x92, 0xb9, 0x05, 0xdd,
2993 0xf3, 0xd1, 0xf9, 0xaf, 0x93, 0xd1, 0xaf, 0x59, 0x50, 0xbd, 0x49, 0x3f,
2994 0x5a, 0xa7, 0x31, 0xb4, 0x05, 0x6d, 0xf3, 0x1b, 0xd2, 0x67, 0xb6, 0xb9,
2995 0x0a, 0x07, 0x98, 0x31, 0xaa, 0xf5, 0x79, 0xbe, 0x0a, 0x39, 0x01, 0x31,
2996 0x37, 0xaa, 0xc6, 0xd4, 0x04, 0xf5, 0x18, 0xcf, 0xd4, 0x68, 0x40, 0x64,
2997 0x7e, 0x78, 0xbf, 0xe7, 0x06, 0xca, 0x4c, 0xf5, 0xe9, 0xc5, 0x45, 0x3e,
2998 0x9f, 0x7c, 0xfd, 0x2b, 0x8b, 0x4c, 0x8d, 0x16, 0x9a, 0x44, 0xe5, 0x5c,
2999 0x88, 0xd4, 0xa9, 0xa7, 0xf9, 0x47, 0x42, 0x41, 0xe2, 0x21, 0xaf, 0x44,
3000 0x86, 0x00, 0x18, 0xab, 0x08, 0x56, 0x97, 0x2e, 0x19, 0x4c, 0xd9, 0x34
3001};
3002
3003static QUIC_PKT_HDR tx_script_1_hdr = {
3004 QUIC_PKT_TYPE_INITIAL, /* type */
3005 0, /* spin bit */
3006 0, /* key phase */
3007 4, /* PN length */
3008 0, /* partial */
3009 0, /* fixed */
3010 1, /* version */
3011 {8, {0x83, 0x94, 0xc8, 0xf0, 0x3e, 0x51, 0x57, 0x08}}, /* DCID */
3012 { 0, {0} }, /* SCID */
3013 { 0 }, /* PN */
3014 NULL, 0, /* Token */
3015 5555, NULL /* Len/Data */
3016};
3017
3018static const OSSL_QTX_IOVEC tx_script_1_iovec[] = {
3019 { tx_script_1_body, sizeof(tx_script_1_body) }
3020};
3021
3022static const OSSL_QTX_PKT tx_script_1_pkt = {
3023 &tx_script_1_hdr,
3024 tx_script_1_iovec,
3025 OSSL_NELEM(tx_script_1_iovec),
3026 NULL, NULL,
3027 2,
3028 0
3029};
3030
3031static const struct tx_test_op tx_script_1[] = {
3032 TX_OP_PROVIDE_SECRET_INITIAL(tx_script_1_hdr.dst_conn_id, 0)
3033 TX_OP_WRITE_CHECK(1)
3034 TX_OP_END
3035};
3036
3037/* 2. RFC 9001 - A.3 Server Initial */
3038static const unsigned char tx_script_2_body[] = {
3039 0x02, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x40, 0x5a, 0x02, 0x00, 0x00,
3040 0x56, 0x03, 0x03, 0xee, 0xfc, 0xe7, 0xf7, 0xb3, 0x7b, 0xa1, 0xd1, 0x63,
3041 0x2e, 0x96, 0x67, 0x78, 0x25, 0xdd, 0xf7, 0x39, 0x88, 0xcf, 0xc7, 0x98,
3042 0x25, 0xdf, 0x56, 0x6d, 0xc5, 0x43, 0x0b, 0x9a, 0x04, 0x5a, 0x12, 0x00,
3043 0x13, 0x01, 0x00, 0x00, 0x2e, 0x00, 0x33, 0x00, 0x24, 0x00, 0x1d, 0x00,
3044 0x20, 0x9d, 0x3c, 0x94, 0x0d, 0x89, 0x69, 0x0b, 0x84, 0xd0, 0x8a, 0x60,
3045 0x99, 0x3c, 0x14, 0x4e, 0xca, 0x68, 0x4d, 0x10, 0x81, 0x28, 0x7c, 0x83,
3046 0x4d, 0x53, 0x11, 0xbc, 0xf3, 0x2b, 0xb9, 0xda, 0x1a, 0x00, 0x2b, 0x00,
3047 0x02, 0x03, 0x04
3048};
3049
3050static const unsigned char tx_script_2_dgram[] = {
3051
3052 0xcf, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0xf0, 0x67, 0xa5, 0x50, 0x2a,
3053 0x42, 0x62, 0xb5, 0x00, 0x40, 0x75, 0xc0, 0xd9, 0x5a, 0x48, 0x2c, 0xd0,
3054 0x99, 0x1c, 0xd2, 0x5b, 0x0a, 0xac, 0x40, 0x6a, 0x58, 0x16, 0xb6, 0x39,
3055 0x41, 0x00, 0xf3, 0x7a, 0x1c, 0x69, 0x79, 0x75, 0x54, 0x78, 0x0b, 0xb3,
3056 0x8c, 0xc5, 0xa9, 0x9f, 0x5e, 0xde, 0x4c, 0xf7, 0x3c, 0x3e, 0xc2, 0x49,
3057 0x3a, 0x18, 0x39, 0xb3, 0xdb, 0xcb, 0xa3, 0xf6, 0xea, 0x46, 0xc5, 0xb7,
3058 0x68, 0x4d, 0xf3, 0x54, 0x8e, 0x7d, 0xde, 0xb9, 0xc3, 0xbf, 0x9c, 0x73,
3059 0xcc, 0x3f, 0x3b, 0xde, 0xd7, 0x4b, 0x56, 0x2b, 0xfb, 0x19, 0xfb, 0x84,
3060 0x02, 0x2f, 0x8e, 0xf4, 0xcd, 0xd9, 0x37, 0x95, 0xd7, 0x7d, 0x06, 0xed,
3061 0xbb, 0x7a, 0xaf, 0x2f, 0x58, 0x89, 0x18, 0x50, 0xab, 0xbd, 0xca, 0x3d,
3062 0x20, 0x39, 0x8c, 0x27, 0x64, 0x56, 0xcb, 0xc4, 0x21, 0x58, 0x40, 0x7d,
3063 0xd0, 0x74, 0xee
3064};
3065
3066static QUIC_PKT_HDR tx_script_2_hdr = {
3067 QUIC_PKT_TYPE_INITIAL, /* type */
3068 0, /* spin bit */
3069 0, /* key phase */
3070 2, /* PN length */
3071 0, /* partial */
3072 0, /* fixed */
3073 1, /* version */
3074 { 0, {0} }, /* DCID */
3075 {8, {0xf0, 0x67, 0xa5, 0x50, 0x2a, 0x42, 0x62, 0xb5}}, /* SCID */
3076 { 0 }, /* PN */
3077 NULL, 0, /* Token */
3078 5555, NULL /* Len/Data */
3079};
3080
3081static const OSSL_QTX_IOVEC tx_script_2_iovec[] = {
3082 { tx_script_2_body, sizeof(tx_script_2_body) }
3083};
3084
3085static const OSSL_QTX_PKT tx_script_2_pkt = {
3086 &tx_script_2_hdr,
3087 tx_script_2_iovec,
3088 OSSL_NELEM(tx_script_2_iovec),
3089 NULL, NULL,
3090 1,
3091 0
3092};
3093
3094static const struct tx_test_op tx_script_2[] = {
3095 TX_OP_PROVIDE_SECRET_INITIAL(tx_script_1_hdr.dst_conn_id, 1)
3096 TX_OP_WRITE_CHECK(2)
3097 TX_OP_END
3098};
3099
681c4619 3100#ifndef OPENSSL_NO_CHACHA
19571483
HL
3101/* 3. RFC 9001 - A.5 ChaCha20-Poly1305 Short Header Packet */
3102static const unsigned char tx_script_3_body[] = {
3103 0x01
3104};
3105
3106static const unsigned char tx_script_3_dgram[] = {
3107 0x4c, 0xfe, 0x41, 0x89, 0x65, 0x5e, 0x5c, 0xd5, 0x5c, 0x41, 0xf6, 0x90,
3108 0x80, 0x57, 0x5d, 0x79, 0x99, 0xc2, 0x5a, 0x5b, 0xfb
3109};
3110static const unsigned char tx_script_3_secret[] = {
3111 0x9a, 0xc3, 0x12, 0xa7, 0xf8, 0x77, 0x46, 0x8e, 0xbe, 0x69, 0x42, 0x27,
3112 0x48, 0xad, 0x00, 0xa1, 0x54, 0x43, 0xf1, 0x82, 0x03, 0xa0, 0x7d, 0x60,
3113 0x60, 0xf6, 0x88, 0xf3, 0x0f, 0x21, 0x63, 0x2b
3114};
3115
3116static QUIC_PKT_HDR tx_script_3_hdr = {
3117 QUIC_PKT_TYPE_1RTT, /* type */
3118 0, /* spin bit */
3119 0, /* key phase */
3120 3, /* PN length */
3121 0, /* partial */
3122 0, /* fixed */
3123 0, /* version */
3124 { 0, {0} }, /* DCID */
3125 { 0, {0} }, /* SCID */
3126 { 0 }, /* PN */
3127 NULL, 0, /* Token */
3128 5555, NULL /* Len/Data */
3129};
3130
3131static const OSSL_QTX_IOVEC tx_script_3_iovec[] = {
3132 { tx_script_3_body, sizeof(tx_script_3_body) }
3133};
3134
3135static const OSSL_QTX_PKT tx_script_3_pkt = {
3136 &tx_script_3_hdr,
3137 tx_script_3_iovec,
3138 OSSL_NELEM(tx_script_3_iovec),
3139 NULL, NULL,
3140 654360564,
3141 0
3142};
3143
3144static const struct tx_test_op tx_script_3[] = {
3145 TX_OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT, QRL_SUITE_CHACHA20POLY1305, tx_script_3_secret)
3146 TX_OP_WRITE_CHECK(3)
3147 TX_OP_END
3148};
681c4619 3149#endif /* !defined(OPENSSL_NO_CHACHA) */
19571483 3150
948c656c
HL
3151/* 4. Real World - AES-128-GCM Key Update */
3152static const unsigned char tx_script_4_secret[] = {
3153 0x70, 0x82, 0xc0, 0x45, 0x61, 0x4d, 0xfe, 0x04, 0x76, 0xa6, 0x4e, 0xf0,
3154 0x38, 0xe6, 0x63, 0xd9, 0xdd, 0x4a, 0x75, 0x16, 0xa8, 0xa0, 0x06, 0x5a,
3155 0xf2, 0x56, 0xfd, 0x84, 0x78, 0xfd, 0xf6, 0x5e
3156};
3157
3158static const unsigned char tx_script_4a_body[] = {
3159 0x02, 0x03, 0x09, 0x00, 0x03, 0x0c, 0x00, 0x36, 0x49, 0x27, 0x6d, 0x20,
3160 0x68, 0x61, 0x76, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x20, 0x77, 0x6f, 0x6e,
3161 0x64, 0x65, 0x72, 0x66, 0x75, 0x6c, 0x20, 0x74, 0x69, 0x6d, 0x65,
3162};
3163
3164static const unsigned char tx_script_4a_dgram[] = {
3165 0x47, 0x6e, 0x4e, 0xbd, 0x49, 0x7e, 0xbd, 0x15, 0x1c, 0xd1, 0x3e, 0xc8,
3166 0xcd, 0x43, 0x87, 0x6b, 0x84, 0xdb, 0xeb, 0x06, 0x8b, 0x8a, 0xae, 0x37,
3167 0xed, 0x9c, 0xeb, 0xbc, 0xcf, 0x0d, 0x3c, 0xf0, 0xa1, 0x6f, 0xee, 0xd2,
3168 0x7c, 0x07, 0x6e, 0xd1, 0xbe, 0x40, 0x6a, 0xd4, 0x53, 0x38, 0x9e, 0x63,
3169 0xb5, 0xde, 0x35, 0x09, 0xb2, 0x78, 0x94, 0xe4, 0x2b, 0x37
3170};
3171
3172static QUIC_PKT_HDR tx_script_4a_hdr = {
3173 QUIC_PKT_TYPE_1RTT, /* type */
3174 0, /* spin bit */
3175 0, /* key phase */
3176 2, /* PN length */
3177 0, /* partial */
3178 0, /* fixed */
3179 0, /* version */
3180 { 4, {0x6e, 0x4e, 0xbd, 0x49} }, /* DCID */
3181 { 0, {0} }, /* SCID */
3182 { 0 }, /* PN */
3183 NULL, 0, /* Token */
3184 5555, NULL /* Len/Data */
3185};
3186
3187static const OSSL_QTX_IOVEC tx_script_4a_iovec[] = {
3188 { tx_script_4a_body, sizeof(tx_script_4a_body) }
3189};
3190
3191static const OSSL_QTX_PKT tx_script_4a_pkt = {
3192 &tx_script_4a_hdr,
3193 tx_script_4a_iovec,
3194 OSSL_NELEM(tx_script_4a_iovec),
3195 NULL, NULL,
3196 4,
3197 0
3198};
3199
3200static const unsigned char tx_script_4b_body[] = {
3201 0x02, 0x04, 0x07, 0x00, 0x00, 0x0c, 0x00, 0x40, 0x51, 0x49, 0x27, 0x6d,
3202 0x20, 0x68, 0x61, 0x76, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x20, 0x77, 0x6f,
3203 0x6e, 0x64, 0x65, 0x72, 0x66, 0x75, 0x6c, 0x20, 0x74, 0x69, 0x6d, 0x65,
3204};
3205
3206static const unsigned char tx_script_4b_dgram[] = {
3207 0x58, 0x6e, 0x4e, 0xbd, 0x49, 0xa4, 0x43, 0x33, 0xea, 0x11, 0x3a, 0x6c,
3208 0xf5, 0x20, 0xef, 0x55, 0x8d, 0x25, 0xe2, 0x3b, 0x0e, 0x8c, 0xea, 0x17,
3209 0xfc, 0x2b, 0x7a, 0xab, 0xfa, 0x3d, 0x07, 0xda, 0xa7, 0x7c, 0xc7, 0x47,
3210 0x82, 0x02, 0x46, 0x40, 0x4f, 0x01, 0xad, 0xb2, 0x9d, 0x97, 0xdb, 0xfc,
3211 0x9c, 0x4b, 0x46, 0xb1, 0x5a, 0x7f, 0x0b, 0x12, 0xaf, 0x49, 0xdf,
3212};
3213
3214static QUIC_PKT_HDR tx_script_4b_hdr = {
3215 QUIC_PKT_TYPE_1RTT, /* type */
3216 0, /* spin bit */
3217 1, /* key phase */
3218 2, /* PN length */
3219 0, /* partial */
3220 0, /* fixed */
3221 0, /* version */
3222 { 4, {0x6e, 0x4e, 0xbd, 0x49} }, /* DCID */
3223 { 0, {0} }, /* SCID */
3224 { 0 }, /* PN */
3225 NULL, 0, /* Token */
3226 5555, NULL /* Len/Data */
3227};
3228
3229static const OSSL_QTX_IOVEC tx_script_4b_iovec[] = {
3230 { tx_script_4b_body, sizeof(tx_script_4b_body) }
3231};
3232
3233static const OSSL_QTX_PKT tx_script_4b_pkt = {
3234 &tx_script_4b_hdr,
3235 tx_script_4b_iovec,
3236 OSSL_NELEM(tx_script_4b_iovec),
3237 NULL, NULL,
3238 5,
3239 0
3240};
3241
3242static const unsigned char tx_script_4c_body[] = {
3243 0x02, 0x09, 0x0e, 0x00, 0x00, 0x0c, 0x00, 0x40, 0xd8, 0x49, 0x27, 0x6d,
3244 0x20, 0x68, 0x61, 0x76, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x20, 0x77, 0x6f,
3245 0x6e, 0x64, 0x65, 0x72, 0x66, 0x75, 0x6c, 0x20, 0x74, 0x69, 0x6d, 0x65,
3246};
3247
3248static const unsigned char tx_script_4c_dgram[] = {
3249 0x49, 0x6e, 0x4e, 0xbd, 0x49, 0x4d, 0xd9, 0x85, 0xba, 0x26, 0xfb, 0x68,
3250 0x83, 0x9b, 0x94, 0x34, 0x7d, 0xc1, 0x7a, 0x05, 0xb7, 0x38, 0x43, 0x21,
3251 0xe2, 0xec, 0x2b, 0xc1, 0x81, 0x74, 0x2d, 0xda, 0x24, 0xba, 0xbd, 0x99,
3252 0x69, 0xd2, 0x56, 0xfa, 0xae, 0x29, 0x24, 0xb2, 0xaa, 0xda, 0xbd, 0x82,
3253 0x80, 0xf1, 0xbb, 0x6a, 0xfd, 0xae, 0xda, 0x0e, 0x09, 0xcf, 0x09,
3254};
3255
3256static QUIC_PKT_HDR tx_script_4c_hdr = {
3257 QUIC_PKT_TYPE_1RTT, /* type */
3258 0, /* spin bit */
3259 0, /* key phase */
3260 2, /* PN length */
3261 0, /* partial */
3262 0, /* fixed */
3263 0, /* version */
3264 { 4, {0x6e, 0x4e, 0xbd, 0x49} }, /* DCID */
3265 { 0, {0} }, /* SCID */
3266 { 0 }, /* PN */
3267 NULL, 0, /* Token */
3268 5555, NULL /* Len/Data */
3269};
3270
3271static const OSSL_QTX_IOVEC tx_script_4c_iovec[] = {
3272 { tx_script_4c_body, sizeof(tx_script_4c_body) }
3273};
3274
3275static const OSSL_QTX_PKT tx_script_4c_pkt = {
3276 &tx_script_4c_hdr,
3277 tx_script_4c_iovec,
3278 OSSL_NELEM(tx_script_4c_iovec),
3279 NULL, NULL,
3280 10,
3281 0
3282};
3283
3284static const struct tx_test_op tx_script_4[] = {
3285 TX_OP_PROVIDE_SECRET(QUIC_ENC_LEVEL_1RTT, QRL_SUITE_AES128GCM, tx_script_4_secret)
3286 TX_OP_WRITE_CHECK(4a)
3287 TX_OP_KEY_UPDATE()
3288 TX_OP_WRITE_CHECK(4b)
3289 TX_OP_KEY_UPDATE()
3290 TX_OP_WRITE_CHECK(4c)
3291 TX_OP_END
3292};
3293
3294/* 5. Real World - Retry Packet */
3295static const unsigned char tx_script_5_body[] = {
3296 /* Retry Token */
3297 0x92, 0xe7, 0xc6, 0xd8, 0x09, 0x65, 0x72, 0x55, 0xe5, 0xe2, 0x73, 0x04,
3298 0xf3, 0x07, 0x5b, 0x21, 0x9f, 0x50, 0xcb, 0xbc, 0x79, 0xc5, 0x77, 0x5a,
3299 0x29, 0x43, 0x65, 0x49, 0xf0, 0x6e, 0xc1, 0xc0, 0x3a, 0xe8, 0xca, 0xd2,
3300 0x44, 0x69, 0xdd, 0x23, 0x31, 0x93, 0x52, 0x02, 0xf7, 0x42, 0x07, 0x78,
3301 0xa1, 0x81, 0x61, 0x9c, 0x39, 0x07, 0x18, 0x69, 0x6e, 0x4f, 0xdc, 0xa0,
3302 0xbe, 0x4b, 0xe5, 0xf2, 0xe9, 0xd2, 0xa4, 0xa7, 0x34, 0x55, 0x5e, 0xf3,
3303 0xf8, 0x9c, 0x49, 0x8f, 0x0c, 0xc8, 0xb2, 0x75, 0x4b, 0x4d, 0x2f, 0xfe,
3304 0x05, 0x5a, 0xdd, 0x4b, 0xe6, 0x14, 0xb4, 0xd2, 0xc0, 0x93, 0x6e, 0x0e,
3305 0x84, 0x41, 0x4d, 0x31,
3306 /* Retry Integrity Tag */
3307 0x43, 0x8e, 0xab, 0xcd, 0xce, 0x24, 0x44, 0xc2, 0x20, 0xe1, 0xe2, 0xc8,
3308 0xae, 0xa3, 0x8d, 0x4e,
3309};
3310
3311static const unsigned char tx_script_5_dgram[] = {
3312 0xf0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0xa9, 0x20, 0xcc, 0xc2, 0x92,
3313 0xe7, 0xc6, 0xd8, 0x09, 0x65, 0x72, 0x55, 0xe5, 0xe2, 0x73, 0x04, 0xf3,
3314 0x07, 0x5b, 0x21, 0x9f, 0x50, 0xcb, 0xbc, 0x79, 0xc5, 0x77, 0x5a, 0x29,
3315 0x43, 0x65, 0x49, 0xf0, 0x6e, 0xc1, 0xc0, 0x3a, 0xe8, 0xca, 0xd2, 0x44,
3316 0x69, 0xdd, 0x23, 0x31, 0x93, 0x52, 0x02, 0xf7, 0x42, 0x07, 0x78, 0xa1,
3317 0x81, 0x61, 0x9c, 0x39, 0x07, 0x18, 0x69, 0x6e, 0x4f, 0xdc, 0xa0, 0xbe,
3318 0x4b, 0xe5, 0xf2, 0xe9, 0xd2, 0xa4, 0xa7, 0x34, 0x55, 0x5e, 0xf3, 0xf8,
3319 0x9c, 0x49, 0x8f, 0x0c, 0xc8, 0xb2, 0x75, 0x4b, 0x4d, 0x2f, 0xfe, 0x05,
3320 0x5a, 0xdd, 0x4b, 0xe6, 0x14, 0xb4, 0xd2, 0xc0, 0x93, 0x6e, 0x0e, 0x84,
3321 0x41, 0x4d, 0x31, 0x43, 0x8e, 0xab, 0xcd, 0xce, 0x24, 0x44, 0xc2, 0x20,
3322 0xe1, 0xe2, 0xc8, 0xae, 0xa3, 0x8d, 0x4e,
3323};
3324
3325static QUIC_PKT_HDR tx_script_5_hdr = {
3326 QUIC_PKT_TYPE_RETRY, /* type */
3327 0, /* spin bit */
3328 0, /* key phase */
3329 0, /* PN length */
3330 0, /* partial */
3331 0, /* fixed */
3332 1, /* version */
3333 { 0, {0} }, /* DCID */
3334 { 4, {0xa9, 0x20, 0xcc, 0xc2} }, /* SCID */
3335 { 0 }, /* PN */
3336 NULL, 0, /* Token */
3337 5555, NULL /* Len/Data */
3338};
3339
3340static const OSSL_QTX_IOVEC tx_script_5_iovec[] = {
3341 { tx_script_5_body, sizeof(tx_script_5_body) }
3342};
3343
3344static const OSSL_QTX_PKT tx_script_5_pkt = {
3345 &tx_script_5_hdr,
3346 tx_script_5_iovec,
3347 OSSL_NELEM(tx_script_5_iovec),
3348 NULL, NULL,
3349 0,
3350 0
3351};
3352
3353static const struct tx_test_op tx_script_5[] = {
3354 TX_OP_WRITE_CHECK(5)
3355 TX_OP_END
3356};
3357
3358/* 6. Real World - Version Negotiation Packet */
3359static const unsigned char tx_script_6_body[] = {
3360 0x00, 0x00, 0x00, 0x01, /* Supported Version: 1 */
3361 0xaa, 0x9a, 0x3a, 0x9a /* Supported Version: Random (GREASE) */
3362};
3363
3364static const unsigned char tx_script_6_dgram[] = {
3365 0x80, /* Long */
3366 0x00, 0x00, 0x00, 0x00, /* Version 0 (Version Negotiation) */
3367 0x00, /* DCID */
3368 0x0c, 0x35, 0x3c, 0x1b, 0x97, 0xca, /* SCID */
3369 0xf8, 0x99, 0x11, 0x39, 0xad, 0x79,
3370 0x1f,
3371 0x00, 0x00, 0x00, 0x01, /* Supported Version: 1 */
3372 0xaa, 0x9a, 0x3a, 0x9a /* Supported Version: Random (GREASE) */
3373};
3374
3375static QUIC_PKT_HDR tx_script_6_hdr = {
3376 QUIC_PKT_TYPE_VERSION_NEG, /* type */
3377 0, /* spin bit */
3378 0, /* key phase */
3379 0, /* PN length */
3380 0, /* partial */
3381 0, /* fixed */
3382 0, /* version */
3383 { 0, {0} }, /* DCID */
3384 { 12, {0x35, 0x3c, 0x1b, 0x97, 0xca, 0xf8, 0x99,
3385 0x11, 0x39, 0xad, 0x79, 0x1f} }, /* SCID */
3386 { 0 }, /* PN */
3387 NULL, 0, /* Token */
3388 5555, NULL /* Len/Data */
3389};
3390
3391static const OSSL_QTX_IOVEC tx_script_6_iovec[] = {
3392 { tx_script_6_body, sizeof(tx_script_6_body) }
3393};
3394
3395static const OSSL_QTX_PKT tx_script_6_pkt = {
3396 &tx_script_6_hdr,
3397 tx_script_6_iovec,
3398 OSSL_NELEM(tx_script_6_iovec),
3399 NULL, NULL,
3400 0,
3401 0
3402};
3403
3404static const struct tx_test_op tx_script_6[] = {
3405 TX_OP_WRITE_CHECK(6)
3406 TX_OP_END
3407};
3408
19571483
HL
3409static const struct tx_test_op *const tx_scripts[] = {
3410 tx_script_1,
3411 tx_script_2,
681c4619 3412#ifndef OPENSSL_NO_CHACHA
948c656c 3413 tx_script_3,
681c4619 3414#endif
948c656c
HL
3415 tx_script_4,
3416 tx_script_5,
3417 tx_script_6
19571483
HL
3418};
3419
3420static int tx_run_script(const struct tx_test_op *script)
3421{
3422 int testresult = 0;
3423 const struct tx_test_op *op = script;
3424 OSSL_QTX *qtx = NULL;
3425 BIO_MSG msg = {0};
3426 OSSL_QTX_ARGS args = {0};
3427
3428 args.mdpl = 1472;
3429
3430 if (!TEST_ptr(qtx = ossl_qtx_new(&args)))
3431 goto err;
3432
3433 for (; op->op != TX_TEST_OP_END; ++op)
3434 switch (op->op) {
3435 case TX_TEST_OP_PROVIDE_SECRET:
3436 if (!TEST_true(ossl_qtx_provide_secret(qtx, op->enc_level,
3437 op->suite_id, NULL,
3438 op->buf, op->buf_len)))
3439 goto err;
3440 break;
3441 case TX_TEST_OP_PROVIDE_SECRET_INITIAL:
3442 if (!TEST_true(ossl_quic_provide_initial_secret(NULL, NULL,
3443 op->dcid,
3444 (int)op->suite_id,
3445 NULL, qtx)))
3446 goto err;
3447 break;
3448 case TX_TEST_OP_DISCARD_EL:
3449 if (!TEST_true(ossl_qtx_discard_enc_level(qtx, op->enc_level)))
3450 goto err;
3451 break;
3452 case TX_TEST_OP_WRITE:
3453 {
3454 uint32_t enc_level
3455 = ossl_quic_pkt_type_to_enc_level(op->pkt->hdr->type);
3456 uint64_t old_value = 0, new_value, max_value;
3457
3458 if (enc_level < QUIC_ENC_LEVEL_NUM) { /* encrypted packet */
3459 max_value = ossl_qtx_get_max_epoch_pkt_count(qtx, enc_level);
3460
3461 if (!TEST_uint64_t_lt(max_value, UINT64_MAX))
3462 goto err;
3463
3464 old_value = ossl_qtx_get_cur_epoch_pkt_count(qtx, enc_level);
3465 if (!TEST_uint64_t_lt(old_value, UINT64_MAX))
3466 goto err;
3467 }
3468
3469 if (!TEST_true(ossl_qtx_write_pkt(qtx, op->pkt)))
3470 goto err;
3471
3472 if (enc_level < QUIC_ENC_LEVEL_NUM) {
3473 new_value = ossl_qtx_get_cur_epoch_pkt_count(qtx, enc_level);
3474 if (!TEST_uint64_t_eq(old_value + 1, new_value))
3475 goto err;
3476 }
3477 }
3478 break;
3479 case TX_TEST_OP_CHECK_DGRAM:
3480 if (!TEST_true(ossl_qtx_pop_net(qtx, &msg)))
3481 goto err;
3482
3483 if (!TEST_mem_eq(msg.data, msg.data_len, op->buf, op->buf_len))
3484 goto err;
3485
3486 break;
3487 case TX_TEST_OP_CHECK_NO_DGRAM:
3488 if (!TEST_false(ossl_qtx_pop_net(qtx, &msg)))
3489 goto err;
3490 break;
948c656c
HL
3491 case TX_TEST_OP_KEY_UPDATE:
3492 if (!TEST_true(ossl_qtx_trigger_key_update(qtx)))
3493 goto err;
3494 break;
19571483
HL
3495 default:
3496 OPENSSL_assert(0);
3497 goto err;
3498 }
3499
3500 testresult = 1;
3501err:
3502 if (qtx != NULL)
3503 ossl_qtx_free(qtx);
3504
3505 return testresult;
3506}
3507
3508static int test_tx_script(int idx)
3509{
3510 return tx_run_script(tx_scripts[idx]);
3511}
3512
ec279ac2
HL
3513int setup_tests(void)
3514{
19571483 3515 ADD_ALL_TESTS(test_rx_script, OSSL_NELEM(rx_scripts));
ec279ac2
HL
3516 /*
3517 * Each instance of this test is executed multiple times to get enough
3518 * statistical coverage for our statistical test, as well as for each
3519 * supported key type.
3520 *
3521 * We call the statistical test as the last index in the wire_pkt_hdr
3522 * test rather than as a separate case, as it needs to execute last
3523 * and otherwise random test ordering will cause itt to randomly fail.
3524 */
3525 ADD_ALL_TESTS(test_wire_pkt_hdr, NUM_WIRE_PKT_HDR_TESTS + 1);
19571483 3526 ADD_ALL_TESTS(test_tx_script, OSSL_NELEM(tx_scripts));
ec279ac2
HL
3527 return 1;
3528}