quic_record_test.c 152 KB

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