quic_record_test.c 161 KB

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