quic_record_test.c 148 KB

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