ssl-opt.sh 445 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157
  1. #!/bin/sh
  2. # ssl-opt.sh
  3. #
  4. # Copyright The Mbed TLS Contributors
  5. # SPDX-License-Identifier: Apache-2.0
  6. #
  7. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  8. # not use this file except in compliance with the License.
  9. # You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. #
  19. # Purpose
  20. #
  21. # Executes tests to prove various TLS/SSL options and extensions.
  22. #
  23. # The goal is not to cover every ciphersuite/version, but instead to cover
  24. # specific options (max fragment length, truncated hmac, etc) or procedures
  25. # (session resumption from cache or ticket, renego, etc).
  26. #
  27. # The tests assume a build with default options, with exceptions expressed
  28. # with a dependency. The tests focus on functionality and do not consider
  29. # performance.
  30. #
  31. set -u
  32. # Limit the size of each log to 10 GiB, in case of failures with this script
  33. # where it may output seemingly unlimited length error logs.
  34. ulimit -f 20971520
  35. ORIGINAL_PWD=$PWD
  36. if ! cd "$(dirname "$0")"; then
  37. exit 125
  38. fi
  39. # default values, can be overridden by the environment
  40. : ${P_SRV:=../programs/ssl/ssl_server2}
  41. : ${P_CLI:=../programs/ssl/ssl_client2}
  42. : ${P_PXY:=../programs/test/udp_proxy}
  43. : ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
  44. : ${GNUTLS_CLI:=gnutls-cli}
  45. : ${GNUTLS_SERV:=gnutls-serv}
  46. : ${PERL:=perl}
  47. guess_config_name() {
  48. if git diff --quiet ../include/mbedtls/config.h 2>/dev/null; then
  49. echo "default"
  50. else
  51. echo "unknown"
  52. fi
  53. }
  54. : ${MBEDTLS_TEST_OUTCOME_FILE=}
  55. : ${MBEDTLS_TEST_CONFIGURATION:="$(guess_config_name)"}
  56. : ${MBEDTLS_TEST_PLATFORM:="$(uname -s | tr -c \\n0-9A-Za-z _)-$(uname -m | tr -c \\n0-9A-Za-z _)"}
  57. O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
  58. O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
  59. G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
  60. G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
  61. TCP_CLIENT="$PERL scripts/tcp_client.pl"
  62. # alternative versions of OpenSSL and GnuTLS (no default path)
  63. if [ -n "${OPENSSL_LEGACY:-}" ]; then
  64. O_LEGACY_SRV="$OPENSSL_LEGACY s_server -www -cert data_files/server5.crt -key data_files/server5.key"
  65. O_LEGACY_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_LEGACY s_client"
  66. else
  67. O_LEGACY_SRV=false
  68. O_LEGACY_CLI=false
  69. fi
  70. if [ -n "${OPENSSL_NEXT:-}" ]; then
  71. O_NEXT_SRV="$OPENSSL_NEXT s_server -www -cert data_files/server5.crt -key data_files/server5.key"
  72. O_NEXT_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_NEXT s_client"
  73. else
  74. O_NEXT_SRV=false
  75. O_NEXT_CLI=false
  76. fi
  77. if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
  78. G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
  79. else
  80. G_NEXT_SRV=false
  81. fi
  82. if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
  83. G_NEXT_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_NEXT_CLI --x509cafile data_files/test-ca_cat12.crt"
  84. else
  85. G_NEXT_CLI=false
  86. fi
  87. TESTS=0
  88. FAILS=0
  89. SKIPS=0
  90. CONFIG_H='../include/mbedtls/config.h'
  91. MEMCHECK=0
  92. FILTER='.*'
  93. EXCLUDE='^$'
  94. SHOW_TEST_NUMBER=0
  95. RUN_TEST_NUMBER=''
  96. PRESERVE_LOGS=0
  97. # Pick a "unique" server port in the range 10000-19999, and a proxy
  98. # port which is this plus 10000. Each port number may be independently
  99. # overridden by a command line option.
  100. SRV_PORT=$(($$ % 10000 + 10000))
  101. PXY_PORT=$((SRV_PORT + 10000))
  102. print_usage() {
  103. echo "Usage: $0 [options]"
  104. printf " -h|--help\tPrint this help.\n"
  105. printf " -m|--memcheck\tCheck memory leaks and errors.\n"
  106. printf " -f|--filter\tOnly matching tests are executed (substring or BRE)\n"
  107. printf " -e|--exclude\tMatching tests are excluded (substring or BRE)\n"
  108. printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
  109. printf " -s|--show-numbers\tShow test numbers in front of test names\n"
  110. printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
  111. printf " --outcome-file\tFile where test outcomes are written\n"
  112. printf " \t(default: \$MBEDTLS_TEST_OUTCOME_FILE, none if empty)\n"
  113. printf " --port \tTCP/UDP port (default: randomish 1xxxx)\n"
  114. printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
  115. printf " --seed \tInteger seed value to use for this test run\n"
  116. }
  117. get_options() {
  118. while [ $# -gt 0 ]; do
  119. case "$1" in
  120. -f|--filter)
  121. shift; FILTER=$1
  122. ;;
  123. -e|--exclude)
  124. shift; EXCLUDE=$1
  125. ;;
  126. -m|--memcheck)
  127. MEMCHECK=1
  128. ;;
  129. -n|--number)
  130. shift; RUN_TEST_NUMBER=$1
  131. ;;
  132. -s|--show-numbers)
  133. SHOW_TEST_NUMBER=1
  134. ;;
  135. -p|--preserve-logs)
  136. PRESERVE_LOGS=1
  137. ;;
  138. --port)
  139. shift; SRV_PORT=$1
  140. ;;
  141. --proxy-port)
  142. shift; PXY_PORT=$1
  143. ;;
  144. --seed)
  145. shift; SEED="$1"
  146. ;;
  147. -h|--help)
  148. print_usage
  149. exit 0
  150. ;;
  151. *)
  152. echo "Unknown argument: '$1'"
  153. print_usage
  154. exit 1
  155. ;;
  156. esac
  157. shift
  158. done
  159. }
  160. # Make the outcome file path relative to the original directory, not
  161. # to .../tests
  162. case "$MBEDTLS_TEST_OUTCOME_FILE" in
  163. [!/]*)
  164. MBEDTLS_TEST_OUTCOME_FILE="$ORIGINAL_PWD/$MBEDTLS_TEST_OUTCOME_FILE"
  165. ;;
  166. esac
  167. # Read boolean configuration options from config.h for easy and quick
  168. # testing. Skip non-boolean options (with something other than spaces
  169. # and a comment after "#define SYMBOL"). The variable contains a
  170. # space-separated list of symbols.
  171. CONFIGS_ENABLED=" $(<"$CONFIG_H" \
  172. sed -n 's!^ *#define *\([A-Za-z][0-9A-Z_a-z]*\) *\(/*\)*!\1!p' |
  173. tr '\n' ' ')"
  174. # Skip next test; use this macro to skip tests which are legitimate
  175. # in theory and expected to be re-introduced at some point, but
  176. # aren't expected to succeed at the moment due to problems outside
  177. # our control (such as bugs in other TLS implementations).
  178. skip_next_test() {
  179. SKIP_NEXT="YES"
  180. }
  181. # skip next test if the flag is not enabled in config.h
  182. requires_config_enabled() {
  183. case $CONFIGS_ENABLED in
  184. *" $1 "*) :;;
  185. *) SKIP_NEXT="YES";;
  186. esac
  187. }
  188. # skip next test if the flag is enabled in config.h
  189. requires_config_disabled() {
  190. case $CONFIGS_ENABLED in
  191. *" $1 "*) SKIP_NEXT="YES";;
  192. esac
  193. }
  194. get_config_value_or_default() {
  195. # This function uses the query_config command line option to query the
  196. # required Mbed TLS compile time configuration from the ssl_server2
  197. # program. The command will always return a success value if the
  198. # configuration is defined and the value will be printed to stdout.
  199. #
  200. # Note that if the configuration is not defined or is defined to nothing,
  201. # the output of this function will be an empty string.
  202. ${P_SRV} "query_config=${1}"
  203. }
  204. requires_config_value_at_least() {
  205. VAL="$( get_config_value_or_default "$1" )"
  206. if [ -z "$VAL" ]; then
  207. # Should never happen
  208. echo "Mbed TLS configuration $1 is not defined"
  209. exit 1
  210. elif [ "$VAL" -lt "$2" ]; then
  211. SKIP_NEXT="YES"
  212. fi
  213. }
  214. requires_config_value_at_most() {
  215. VAL=$( get_config_value_or_default "$1" )
  216. if [ -z "$VAL" ]; then
  217. # Should never happen
  218. echo "Mbed TLS configuration $1 is not defined"
  219. exit 1
  220. elif [ "$VAL" -gt "$2" ]; then
  221. SKIP_NEXT="YES"
  222. fi
  223. }
  224. requires_config_value_equals() {
  225. VAL=$( get_config_value_or_default "$1" )
  226. if [ -z "$VAL" ]; then
  227. # Should never happen
  228. echo "Mbed TLS configuration $1 is not defined"
  229. exit 1
  230. elif [ "$VAL" -ne "$2" ]; then
  231. SKIP_NEXT="YES"
  232. fi
  233. }
  234. # Space-separated list of ciphersuites supported by this build of
  235. # Mbed TLS.
  236. P_CIPHERSUITES=" $($P_CLI --help 2>/dev/null |
  237. grep TLS- |
  238. tr -s ' \n' ' ')"
  239. requires_ciphersuite_enabled() {
  240. case $P_CIPHERSUITES in
  241. *" $1 "*) :;;
  242. *) SKIP_NEXT="YES";;
  243. esac
  244. }
  245. # maybe_requires_ciphersuite_enabled CMD [RUN_TEST_OPTION...]
  246. # If CMD (call to a TLS client or server program) requires a specific
  247. # ciphersuite, arrange to only run the test case if this ciphersuite is
  248. # enabled. As an exception, do run the test case if it expects a ciphersuite
  249. # mismatch.
  250. maybe_requires_ciphersuite_enabled() {
  251. case "$1" in
  252. *\ force_ciphersuite=*) :;;
  253. *) return;; # No specific required ciphersuite
  254. esac
  255. ciphersuite="${1##*\ force_ciphersuite=}"
  256. ciphersuite="${ciphersuite%%[!-0-9A-Z_a-z]*}"
  257. shift
  258. case "$*" in
  259. *"-s SSL - The server has no ciphersuites in common"*)
  260. # This test case expects a ciphersuite mismatch, so it doesn't
  261. # require the ciphersuite to be enabled.
  262. ;;
  263. *)
  264. requires_ciphersuite_enabled "$ciphersuite"
  265. ;;
  266. esac
  267. unset ciphersuite
  268. }
  269. # skip next test if OpenSSL doesn't support FALLBACK_SCSV
  270. requires_openssl_with_fallback_scsv() {
  271. if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
  272. if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
  273. then
  274. OPENSSL_HAS_FBSCSV="YES"
  275. else
  276. OPENSSL_HAS_FBSCSV="NO"
  277. fi
  278. fi
  279. if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
  280. SKIP_NEXT="YES"
  281. fi
  282. }
  283. # skip next test if either IN_CONTENT_LEN or MAX_CONTENT_LEN are below a value
  284. requires_max_content_len() {
  285. requires_config_value_at_least "MBEDTLS_SSL_IN_CONTENT_LEN" $1
  286. requires_config_value_at_least "MBEDTLS_SSL_OUT_CONTENT_LEN" $1
  287. }
  288. # skip next test if GnuTLS isn't available
  289. requires_gnutls() {
  290. if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
  291. if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
  292. GNUTLS_AVAILABLE="YES"
  293. else
  294. GNUTLS_AVAILABLE="NO"
  295. fi
  296. fi
  297. if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
  298. SKIP_NEXT="YES"
  299. fi
  300. }
  301. # skip next test if GnuTLS-next isn't available
  302. requires_gnutls_next() {
  303. if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
  304. if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
  305. GNUTLS_NEXT_AVAILABLE="YES"
  306. else
  307. GNUTLS_NEXT_AVAILABLE="NO"
  308. fi
  309. fi
  310. if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
  311. SKIP_NEXT="YES"
  312. fi
  313. }
  314. # skip next test if OpenSSL-legacy isn't available
  315. requires_openssl_legacy() {
  316. if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
  317. if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
  318. OPENSSL_LEGACY_AVAILABLE="YES"
  319. else
  320. OPENSSL_LEGACY_AVAILABLE="NO"
  321. fi
  322. fi
  323. if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
  324. SKIP_NEXT="YES"
  325. fi
  326. }
  327. requires_openssl_next() {
  328. if [ -z "${OPENSSL_NEXT_AVAILABLE:-}" ]; then
  329. if which "${OPENSSL_NEXT:-}" >/dev/null 2>&1; then
  330. OPENSSL_NEXT_AVAILABLE="YES"
  331. else
  332. OPENSSL_NEXT_AVAILABLE="NO"
  333. fi
  334. fi
  335. if [ "$OPENSSL_NEXT_AVAILABLE" = "NO" ]; then
  336. SKIP_NEXT="YES"
  337. fi
  338. }
  339. # skip next test if IPv6 isn't available on this host
  340. requires_ipv6() {
  341. if [ -z "${HAS_IPV6:-}" ]; then
  342. $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
  343. SRV_PID=$!
  344. sleep 1
  345. kill $SRV_PID >/dev/null 2>&1
  346. if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
  347. HAS_IPV6="NO"
  348. else
  349. HAS_IPV6="YES"
  350. fi
  351. rm -r $SRV_OUT
  352. fi
  353. if [ "$HAS_IPV6" = "NO" ]; then
  354. SKIP_NEXT="YES"
  355. fi
  356. }
  357. # skip next test if it's i686 or uname is not available
  358. requires_not_i686() {
  359. if [ -z "${IS_I686:-}" ]; then
  360. IS_I686="YES"
  361. if which "uname" >/dev/null 2>&1; then
  362. if [ -z "$(uname -a | grep i686)" ]; then
  363. IS_I686="NO"
  364. fi
  365. fi
  366. fi
  367. if [ "$IS_I686" = "YES" ]; then
  368. SKIP_NEXT="YES"
  369. fi
  370. }
  371. # Calculate the input & output maximum content lengths set in the config
  372. MAX_CONTENT_LEN=$( get_config_value_or_default "MBEDTLS_SSL_MAX_CONTENT_LEN" )
  373. MAX_IN_LEN=$( get_config_value_or_default "MBEDTLS_SSL_IN_CONTENT_LEN" )
  374. MAX_OUT_LEN=$( get_config_value_or_default "MBEDTLS_SSL_OUT_CONTENT_LEN" )
  375. # Calculate the maximum content length that fits both
  376. if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
  377. MAX_CONTENT_LEN="$MAX_IN_LEN"
  378. fi
  379. if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
  380. MAX_CONTENT_LEN="$MAX_OUT_LEN"
  381. fi
  382. # skip the next test if the SSL output buffer is less than 16KB
  383. requires_full_size_output_buffer() {
  384. if [ "$MAX_OUT_LEN" -ne 16384 ]; then
  385. SKIP_NEXT="YES"
  386. fi
  387. }
  388. # skip the next test if valgrind is in use
  389. not_with_valgrind() {
  390. if [ "$MEMCHECK" -gt 0 ]; then
  391. SKIP_NEXT="YES"
  392. fi
  393. }
  394. # skip the next test if valgrind is NOT in use
  395. only_with_valgrind() {
  396. if [ "$MEMCHECK" -eq 0 ]; then
  397. SKIP_NEXT="YES"
  398. fi
  399. }
  400. # multiply the client timeout delay by the given factor for the next test
  401. client_needs_more_time() {
  402. CLI_DELAY_FACTOR=$1
  403. }
  404. # wait for the given seconds after the client finished in the next test
  405. server_needs_more_time() {
  406. SRV_DELAY_SECONDS=$1
  407. }
  408. # print_name <name>
  409. print_name() {
  410. TESTS=$(( $TESTS + 1 ))
  411. LINE=""
  412. if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
  413. LINE="$TESTS "
  414. fi
  415. LINE="$LINE$1"
  416. printf "%s " "$LINE"
  417. LEN=$(( 72 - `echo "$LINE" | wc -c` ))
  418. for i in `seq 1 $LEN`; do printf '.'; done
  419. printf ' '
  420. }
  421. # record_outcome <outcome> [<failure-reason>]
  422. # The test name must be in $NAME.
  423. record_outcome() {
  424. echo "$1"
  425. if [ -n "$MBEDTLS_TEST_OUTCOME_FILE" ]; then
  426. printf '%s;%s;%s;%s;%s;%s\n' \
  427. "$MBEDTLS_TEST_PLATFORM" "$MBEDTLS_TEST_CONFIGURATION" \
  428. "ssl-opt" "$NAME" \
  429. "$1" "${2-}" \
  430. >>"$MBEDTLS_TEST_OUTCOME_FILE"
  431. fi
  432. }
  433. # True if the presence of the given pattern in a log definitely indicates
  434. # that the test has failed. False if the presence is inconclusive.
  435. #
  436. # Inputs:
  437. # * $1: pattern found in the logs
  438. # * $TIMES_LEFT: >0 if retrying is an option
  439. #
  440. # Outputs:
  441. # * $outcome: set to a retry reason if the pattern is inconclusive,
  442. # unchanged otherwise.
  443. # * Return value: 1 if the pattern is inconclusive,
  444. # 0 if the failure is definitive.
  445. log_pattern_presence_is_conclusive() {
  446. # If we've run out of attempts, then don't retry no matter what.
  447. if [ $TIMES_LEFT -eq 0 ]; then
  448. return 0
  449. fi
  450. case $1 in
  451. "resend")
  452. # An undesired resend may have been caused by the OS dropping or
  453. # delaying a packet at an inopportune time.
  454. outcome="RETRY(resend)"
  455. return 1;;
  456. esac
  457. }
  458. # fail <message>
  459. fail() {
  460. record_outcome "FAIL" "$1"
  461. echo " ! $1"
  462. mv $SRV_OUT o-srv-${TESTS}.log
  463. mv $CLI_OUT o-cli-${TESTS}.log
  464. if [ -n "$PXY_CMD" ]; then
  465. mv $PXY_OUT o-pxy-${TESTS}.log
  466. fi
  467. echo " ! outputs saved to o-XXX-${TESTS}.log"
  468. if [ "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
  469. echo " ! server output:"
  470. cat o-srv-${TESTS}.log
  471. echo " ! ========================================================"
  472. echo " ! client output:"
  473. cat o-cli-${TESTS}.log
  474. if [ -n "$PXY_CMD" ]; then
  475. echo " ! ========================================================"
  476. echo " ! proxy output:"
  477. cat o-pxy-${TESTS}.log
  478. fi
  479. echo ""
  480. fi
  481. FAILS=$(( $FAILS + 1 ))
  482. }
  483. # is_polar <cmd_line>
  484. is_polar() {
  485. case "$1" in
  486. *ssl_client2*) true;;
  487. *ssl_server2*) true;;
  488. *) false;;
  489. esac
  490. }
  491. # openssl s_server doesn't have -www with DTLS
  492. check_osrv_dtls() {
  493. case "$SRV_CMD" in
  494. *s_server*-dtls*)
  495. NEEDS_INPUT=1
  496. SRV_CMD="$( echo $SRV_CMD | sed s/-www// )";;
  497. *) NEEDS_INPUT=0;;
  498. esac
  499. }
  500. # provide input to commands that need it
  501. provide_input() {
  502. if [ $NEEDS_INPUT -eq 0 ]; then
  503. return
  504. fi
  505. while true; do
  506. echo "HTTP/1.0 200 OK"
  507. sleep 1
  508. done
  509. }
  510. # has_mem_err <log_file_name>
  511. has_mem_err() {
  512. if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
  513. grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
  514. then
  515. return 1 # false: does not have errors
  516. else
  517. return 0 # true: has errors
  518. fi
  519. }
  520. # Wait for process $2 named $3 to be listening on port $1. Print error to $4.
  521. if type lsof >/dev/null 2>/dev/null; then
  522. wait_app_start() {
  523. newline='
  524. '
  525. START_TIME=$(date +%s)
  526. if [ "$DTLS" -eq 1 ]; then
  527. proto=UDP
  528. else
  529. proto=TCP
  530. fi
  531. # Make a tight loop, server normally takes less than 1s to start.
  532. while true; do
  533. SERVER_PIDS=$(lsof -a -n -b -i "$proto:$1" -F p)
  534. # When we use a proxy, it will be listening on the same port we
  535. # are checking for as well as the server and lsof will list both.
  536. # If multiple PIDs are returned, each one will be on a separate
  537. # line, each prepended with 'p'.
  538. case ${newline}${SERVER_PIDS}${newline} in
  539. *${newline}p${2}${newline}*) break;;
  540. esac
  541. if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
  542. echo "$3 START TIMEOUT"
  543. echo "$3 START TIMEOUT" >> $4
  544. break
  545. fi
  546. # Linux and *BSD support decimal arguments to sleep. On other
  547. # OSes this may be a tight loop.
  548. sleep 0.1 2>/dev/null || true
  549. done
  550. }
  551. else
  552. echo "Warning: lsof not available, wait_app_start = sleep"
  553. wait_app_start() {
  554. sleep "$START_DELAY"
  555. }
  556. fi
  557. # Wait for server process $2 to be listening on port $1.
  558. wait_server_start() {
  559. wait_app_start $1 $2 "SERVER" $SRV_OUT
  560. }
  561. # Wait for proxy process $2 to be listening on port $1.
  562. wait_proxy_start() {
  563. wait_app_start $1 $2 "PROXY" $PXY_OUT
  564. }
  565. # Given the client or server debug output, parse the unix timestamp that is
  566. # included in the first 4 bytes of the random bytes and check that it's within
  567. # acceptable bounds
  568. check_server_hello_time() {
  569. # Extract the time from the debug (lvl 3) output of the client
  570. SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
  571. # Get the Unix timestamp for now
  572. CUR_TIME=$(date +'%s')
  573. THRESHOLD_IN_SECS=300
  574. # Check if the ServerHello time was printed
  575. if [ -z "$SERVER_HELLO_TIME" ]; then
  576. return 1
  577. fi
  578. # Check the time in ServerHello is within acceptable bounds
  579. if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
  580. # The time in ServerHello is at least 5 minutes before now
  581. return 1
  582. elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
  583. # The time in ServerHello is at least 5 minutes later than now
  584. return 1
  585. else
  586. return 0
  587. fi
  588. }
  589. # Get handshake memory usage from server or client output and put it into the variable specified by the first argument
  590. handshake_memory_get() {
  591. OUTPUT_VARIABLE="$1"
  592. OUTPUT_FILE="$2"
  593. # Get memory usage from a pattern like "Heap memory usage after handshake: 23112 bytes. Peak memory usage was 33112"
  594. MEM_USAGE=$(sed -n 's/.*Heap memory usage after handshake: //p' < "$OUTPUT_FILE" | grep -o "[0-9]*" | head -1)
  595. # Check if memory usage was read
  596. if [ -z "$MEM_USAGE" ]; then
  597. echo "Error: Can not read the value of handshake memory usage"
  598. return 1
  599. else
  600. eval "$OUTPUT_VARIABLE=$MEM_USAGE"
  601. return 0
  602. fi
  603. }
  604. # Get handshake memory usage from server or client output and check if this value
  605. # is not higher than the maximum given by the first argument
  606. handshake_memory_check() {
  607. MAX_MEMORY="$1"
  608. OUTPUT_FILE="$2"
  609. # Get memory usage
  610. if ! handshake_memory_get "MEMORY_USAGE" "$OUTPUT_FILE"; then
  611. return 1
  612. fi
  613. # Check if memory usage is below max value
  614. if [ "$MEMORY_USAGE" -gt "$MAX_MEMORY" ]; then
  615. echo "\nFailed: Handshake memory usage was $MEMORY_USAGE bytes," \
  616. "but should be below $MAX_MEMORY bytes"
  617. return 1
  618. else
  619. return 0
  620. fi
  621. }
  622. # wait for client to terminate and set CLI_EXIT
  623. # must be called right after starting the client
  624. wait_client_done() {
  625. CLI_PID=$!
  626. CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
  627. CLI_DELAY_FACTOR=1
  628. ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
  629. DOG_PID=$!
  630. wait $CLI_PID
  631. CLI_EXIT=$?
  632. kill $DOG_PID >/dev/null 2>&1
  633. wait $DOG_PID
  634. echo "EXIT: $CLI_EXIT" >> $CLI_OUT
  635. sleep $SRV_DELAY_SECONDS
  636. SRV_DELAY_SECONDS=0
  637. }
  638. # check if the given command uses dtls and sets global variable DTLS
  639. detect_dtls() {
  640. case "$1" in
  641. *dtls=1*|*-dtls*|*-u*) DTLS=1;;
  642. *) DTLS=0;;
  643. esac
  644. }
  645. # check if the given command uses gnutls and sets global variable CMD_IS_GNUTLS
  646. is_gnutls() {
  647. case "$1" in
  648. *gnutls-cli*)
  649. CMD_IS_GNUTLS=1
  650. ;;
  651. *gnutls-serv*)
  652. CMD_IS_GNUTLS=1
  653. ;;
  654. *)
  655. CMD_IS_GNUTLS=0
  656. ;;
  657. esac
  658. }
  659. # Compare file content
  660. # Usage: find_in_both pattern file1 file2
  661. # extract from file1 the first line matching the pattern
  662. # check in file2 that the same line can be found
  663. find_in_both() {
  664. srv_pattern=$(grep -m 1 "$1" "$2");
  665. if [ -z "$srv_pattern" ]; then
  666. return 1;
  667. fi
  668. if grep "$srv_pattern" $3 >/dev/null; then :
  669. return 0;
  670. else
  671. return 1;
  672. fi
  673. }
  674. # Analyze the commands that will be used in a test.
  675. #
  676. # Analyze and possibly instrument $PXY_CMD, $CLI_CMD, $SRV_CMD to pass
  677. # extra arguments or go through wrappers.
  678. # Set $DTLS (0=TLS, 1=DTLS).
  679. analyze_test_commands() {
  680. # update DTLS variable
  681. detect_dtls "$SRV_CMD"
  682. # if the test uses DTLS but no custom proxy, add a simple proxy
  683. # as it provides timing info that's useful to debug failures
  684. if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then
  685. PXY_CMD="$P_PXY"
  686. case " $SRV_CMD " in
  687. *' server_addr=::1 '*)
  688. PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";;
  689. esac
  690. fi
  691. # update CMD_IS_GNUTLS variable
  692. is_gnutls "$SRV_CMD"
  693. # if the server uses gnutls but doesn't set priority, explicitly
  694. # set the default priority
  695. if [ "$CMD_IS_GNUTLS" -eq 1 ]; then
  696. case "$SRV_CMD" in
  697. *--priority*) :;;
  698. *) SRV_CMD="$SRV_CMD --priority=NORMAL";;
  699. esac
  700. fi
  701. # update CMD_IS_GNUTLS variable
  702. is_gnutls "$CLI_CMD"
  703. # if the client uses gnutls but doesn't set priority, explicitly
  704. # set the default priority
  705. if [ "$CMD_IS_GNUTLS" -eq 1 ]; then
  706. case "$CLI_CMD" in
  707. *--priority*) :;;
  708. *) CLI_CMD="$CLI_CMD --priority=NORMAL";;
  709. esac
  710. fi
  711. # fix client port
  712. if [ -n "$PXY_CMD" ]; then
  713. CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
  714. else
  715. CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
  716. fi
  717. # prepend valgrind to our commands if active
  718. if [ "$MEMCHECK" -gt 0 ]; then
  719. if is_polar "$SRV_CMD"; then
  720. SRV_CMD="valgrind --leak-check=full $SRV_CMD"
  721. fi
  722. if is_polar "$CLI_CMD"; then
  723. CLI_CMD="valgrind --leak-check=full $CLI_CMD"
  724. fi
  725. fi
  726. }
  727. # Check for failure conditions after a test case.
  728. #
  729. # Inputs from run_test:
  730. # * positional parameters: test options (see run_test documentation)
  731. # * $CLI_EXIT: client return code
  732. # * $CLI_EXPECT: expected client return code
  733. # * $SRV_RET: server return code
  734. # * $CLI_OUT, $SRV_OUT, $PXY_OUT: files containing client/server/proxy logs
  735. # * $TIMES_LEFT: if nonzero, a RETRY outcome is allowed
  736. #
  737. # Outputs:
  738. # * $outcome: one of PASS/RETRY*/FAIL
  739. check_test_failure() {
  740. outcome=FAIL
  741. if [ $TIMES_LEFT -gt 0 ] &&
  742. grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null
  743. then
  744. outcome="RETRY(client-timeout)"
  745. return
  746. fi
  747. # check if the client and server went at least to the handshake stage
  748. # (useful to avoid tests with only negative assertions and non-zero
  749. # expected client exit to incorrectly succeed in case of catastrophic
  750. # failure)
  751. if is_polar "$SRV_CMD"; then
  752. if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
  753. else
  754. fail "server or client failed to reach handshake stage"
  755. return
  756. fi
  757. fi
  758. if is_polar "$CLI_CMD"; then
  759. if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
  760. else
  761. fail "server or client failed to reach handshake stage"
  762. return
  763. fi
  764. fi
  765. # Check server exit code (only for Mbed TLS: GnuTLS and OpenSSL don't
  766. # exit with status 0 when interrupted by a signal, and we don't really
  767. # care anyway), in case e.g. the server reports a memory leak.
  768. if [ $SRV_RET != 0 ] && is_polar "$SRV_CMD"; then
  769. fail "Server exited with status $SRV_RET"
  770. return
  771. fi
  772. # check client exit code
  773. if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
  774. \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
  775. then
  776. fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
  777. return
  778. fi
  779. # check other assertions
  780. # lines beginning with == are added by valgrind, ignore them
  781. # lines with 'Serious error when reading debug info', are valgrind issues as well
  782. while [ $# -gt 0 ]
  783. do
  784. case $1 in
  785. "-s")
  786. if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
  787. fail "pattern '$2' MUST be present in the Server output"
  788. return
  789. fi
  790. ;;
  791. "-c")
  792. if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
  793. fail "pattern '$2' MUST be present in the Client output"
  794. return
  795. fi
  796. ;;
  797. "-S")
  798. if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
  799. if log_pattern_presence_is_conclusive "$2"; then
  800. fail "pattern '$2' MUST NOT be present in the Server output"
  801. fi
  802. return
  803. fi
  804. ;;
  805. "-C")
  806. if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
  807. if log_pattern_presence_is_conclusive "$2"; then
  808. fail "pattern '$2' MUST NOT be present in the Client output"
  809. fi
  810. return
  811. fi
  812. ;;
  813. # The filtering in the following two options (-u and -U) do the following
  814. # - ignore valgrind output
  815. # - filter out everything but lines right after the pattern occurrences
  816. # - keep one of each non-unique line
  817. # - count how many lines remain
  818. # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
  819. # if there were no duplicates.
  820. "-U")
  821. if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
  822. fail "lines following pattern '$2' must be unique in Server output"
  823. return
  824. fi
  825. ;;
  826. "-u")
  827. if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
  828. fail "lines following pattern '$2' must be unique in Client output"
  829. return
  830. fi
  831. ;;
  832. "-F")
  833. if ! $2 "$SRV_OUT"; then
  834. fail "function call to '$2' failed on Server output"
  835. return
  836. fi
  837. ;;
  838. "-f")
  839. if ! $2 "$CLI_OUT"; then
  840. fail "function call to '$2' failed on Client output"
  841. return
  842. fi
  843. ;;
  844. "-g")
  845. if ! eval "$2 '$SRV_OUT' '$CLI_OUT'"; then
  846. fail "function call to '$2' failed on Server and Client output"
  847. return
  848. fi
  849. ;;
  850. *)
  851. echo "Unknown test: $1" >&2
  852. exit 1
  853. esac
  854. shift 2
  855. done
  856. # check valgrind's results
  857. if [ "$MEMCHECK" -gt 0 ]; then
  858. if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
  859. fail "Server has memory errors"
  860. return
  861. fi
  862. if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
  863. fail "Client has memory errors"
  864. return
  865. fi
  866. fi
  867. # if we're here, everything is ok
  868. outcome=PASS
  869. }
  870. # Run the current test case: start the server and if applicable the proxy, run
  871. # the client, wait for all processes to finish or time out.
  872. #
  873. # Inputs:
  874. # * $NAME: test case name
  875. # * $CLI_CMD, $SRV_CMD, $PXY_CMD: commands to run
  876. # * $CLI_OUT, $SRV_OUT, $PXY_OUT: files to contain client/server/proxy logs
  877. #
  878. # Outputs:
  879. # * $CLI_EXIT: client return code
  880. # * $SRV_RET: server return code
  881. do_run_test_once() {
  882. # run the commands
  883. if [ -n "$PXY_CMD" ]; then
  884. printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT
  885. $PXY_CMD >> $PXY_OUT 2>&1 &
  886. PXY_PID=$!
  887. wait_proxy_start "$PXY_PORT" "$PXY_PID"
  888. fi
  889. check_osrv_dtls
  890. printf '# %s\n%s\n' "$NAME" "$SRV_CMD" > $SRV_OUT
  891. provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
  892. SRV_PID=$!
  893. wait_server_start "$SRV_PORT" "$SRV_PID"
  894. printf '# %s\n%s\n' "$NAME" "$CLI_CMD" > $CLI_OUT
  895. eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
  896. wait_client_done
  897. sleep 0.05
  898. # terminate the server (and the proxy)
  899. kill $SRV_PID
  900. wait $SRV_PID
  901. SRV_RET=$?
  902. if [ -n "$PXY_CMD" ]; then
  903. kill $PXY_PID >/dev/null 2>&1
  904. wait $PXY_PID
  905. fi
  906. }
  907. # Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
  908. # Options: -s pattern pattern that must be present in server output
  909. # -c pattern pattern that must be present in client output
  910. # -u pattern lines after pattern must be unique in client output
  911. # -f call shell function on client output
  912. # -S pattern pattern that must be absent in server output
  913. # -C pattern pattern that must be absent in client output
  914. # -U pattern lines after pattern must be unique in server output
  915. # -F call shell function on server output
  916. # -g call shell function on server and client output
  917. run_test() {
  918. NAME="$1"
  919. shift 1
  920. if is_excluded "$NAME"; then
  921. SKIP_NEXT="NO"
  922. # There was no request to run the test, so don't record its outcome.
  923. return
  924. fi
  925. print_name "$NAME"
  926. # Do we only run numbered tests?
  927. if [ -n "$RUN_TEST_NUMBER" ]; then
  928. case ",$RUN_TEST_NUMBER," in
  929. *",$TESTS,"*) :;;
  930. *) SKIP_NEXT="YES";;
  931. esac
  932. fi
  933. # does this test use a proxy?
  934. if [ "X$1" = "X-p" ]; then
  935. PXY_CMD="$2"
  936. shift 2
  937. else
  938. PXY_CMD=""
  939. fi
  940. # get commands and client output
  941. SRV_CMD="$1"
  942. CLI_CMD="$2"
  943. CLI_EXPECT="$3"
  944. shift 3
  945. # Check if test uses files
  946. case "$SRV_CMD $CLI_CMD" in
  947. *data_files/*)
  948. requires_config_enabled MBEDTLS_FS_IO;;
  949. esac
  950. # If the client or serve requires a ciphersuite, check that it's enabled.
  951. maybe_requires_ciphersuite_enabled "$SRV_CMD" "$@"
  952. maybe_requires_ciphersuite_enabled "$CLI_CMD" "$@"
  953. # should we skip?
  954. if [ "X$SKIP_NEXT" = "XYES" ]; then
  955. SKIP_NEXT="NO"
  956. record_outcome "SKIP"
  957. SKIPS=$(( $SKIPS + 1 ))
  958. return
  959. fi
  960. analyze_test_commands "$@"
  961. TIMES_LEFT=2
  962. while [ $TIMES_LEFT -gt 0 ]; do
  963. TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
  964. do_run_test_once
  965. check_test_failure "$@"
  966. case $outcome in
  967. PASS) break;;
  968. RETRY*) printf "$outcome ";;
  969. FAIL) return;;
  970. esac
  971. done
  972. # If we get this far, the test case passed.
  973. record_outcome "PASS"
  974. if [ "$PRESERVE_LOGS" -gt 0 ]; then
  975. mv $SRV_OUT o-srv-${TESTS}.log
  976. mv $CLI_OUT o-cli-${TESTS}.log
  977. if [ -n "$PXY_CMD" ]; then
  978. mv $PXY_OUT o-pxy-${TESTS}.log
  979. fi
  980. fi
  981. rm -f $SRV_OUT $CLI_OUT $PXY_OUT
  982. }
  983. run_test_psa() {
  984. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  985. run_test "PSA-supported ciphersuite: $1" \
  986. "$P_SRV debug_level=3 force_version=tls12" \
  987. "$P_CLI debug_level=3 force_version=tls12 force_ciphersuite=$1" \
  988. 0 \
  989. -c "Successfully setup PSA-based decryption cipher context" \
  990. -c "Successfully setup PSA-based encryption cipher context" \
  991. -c "PSA calc verify" \
  992. -c "calc PSA finished" \
  993. -s "Successfully setup PSA-based decryption cipher context" \
  994. -s "Successfully setup PSA-based encryption cipher context" \
  995. -s "PSA calc verify" \
  996. -s "calc PSA finished" \
  997. -C "Failed to setup PSA-based cipher context"\
  998. -S "Failed to setup PSA-based cipher context"\
  999. -s "Protocol is TLSv1.2" \
  1000. -c "Perform PSA-based ECDH computation."\
  1001. -c "Perform PSA-based computation of digest of ServerKeyExchange" \
  1002. -S "error" \
  1003. -C "error"
  1004. }
  1005. run_test_psa_force_curve() {
  1006. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  1007. run_test "PSA - ECDH with $1" \
  1008. "$P_SRV debug_level=4 force_version=tls12" \
  1009. "$P_CLI debug_level=4 force_version=tls12 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256 curves=$1" \
  1010. 0 \
  1011. -c "Successfully setup PSA-based decryption cipher context" \
  1012. -c "Successfully setup PSA-based encryption cipher context" \
  1013. -c "PSA calc verify" \
  1014. -c "calc PSA finished" \
  1015. -s "Successfully setup PSA-based decryption cipher context" \
  1016. -s "Successfully setup PSA-based encryption cipher context" \
  1017. -s "PSA calc verify" \
  1018. -s "calc PSA finished" \
  1019. -C "Failed to setup PSA-based cipher context"\
  1020. -S "Failed to setup PSA-based cipher context"\
  1021. -s "Protocol is TLSv1.2" \
  1022. -c "Perform PSA-based ECDH computation."\
  1023. -c "Perform PSA-based computation of digest of ServerKeyExchange" \
  1024. -S "error" \
  1025. -C "error"
  1026. }
  1027. # Test that the server's memory usage after a handshake is reduced when a client specifies
  1028. # a maximum fragment length.
  1029. # first argument ($1) is MFL for SSL client
  1030. # second argument ($2) is memory usage for SSL client with default MFL (16k)
  1031. run_test_memory_after_hanshake_with_mfl()
  1032. {
  1033. # The test passes if the difference is around 2*(16k-MFL)
  1034. MEMORY_USAGE_LIMIT="$(( $2 - ( 2 * ( 16384 - $1 )) ))"
  1035. # Leave some margin for robustness
  1036. MEMORY_USAGE_LIMIT="$(( ( MEMORY_USAGE_LIMIT * 110 ) / 100 ))"
  1037. run_test "Handshake memory usage (MFL $1)" \
  1038. "$P_SRV debug_level=3 auth_mode=required force_version=tls12" \
  1039. "$P_CLI debug_level=3 force_version=tls12 \
  1040. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  1041. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM max_frag_len=$1" \
  1042. 0 \
  1043. -F "handshake_memory_check $MEMORY_USAGE_LIMIT"
  1044. }
  1045. # Test that the server's memory usage after a handshake is reduced when a client specifies
  1046. # different values of Maximum Fragment Length: default (16k), 4k, 2k, 1k and 512 bytes
  1047. run_tests_memory_after_hanshake()
  1048. {
  1049. # all tests in this sequence requires the same configuration (see requires_config_enabled())
  1050. SKIP_THIS_TESTS="$SKIP_NEXT"
  1051. # first test with default MFU is to get reference memory usage
  1052. MEMORY_USAGE_MFL_16K=0
  1053. run_test "Handshake memory usage initial (MFL 16384 - default)" \
  1054. "$P_SRV debug_level=3 auth_mode=required force_version=tls12" \
  1055. "$P_CLI debug_level=3 force_version=tls12 \
  1056. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  1057. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM" \
  1058. 0 \
  1059. -F "handshake_memory_get MEMORY_USAGE_MFL_16K"
  1060. SKIP_NEXT="$SKIP_THIS_TESTS"
  1061. run_test_memory_after_hanshake_with_mfl 4096 "$MEMORY_USAGE_MFL_16K"
  1062. SKIP_NEXT="$SKIP_THIS_TESTS"
  1063. run_test_memory_after_hanshake_with_mfl 2048 "$MEMORY_USAGE_MFL_16K"
  1064. SKIP_NEXT="$SKIP_THIS_TESTS"
  1065. run_test_memory_after_hanshake_with_mfl 1024 "$MEMORY_USAGE_MFL_16K"
  1066. SKIP_NEXT="$SKIP_THIS_TESTS"
  1067. run_test_memory_after_hanshake_with_mfl 512 "$MEMORY_USAGE_MFL_16K"
  1068. }
  1069. cleanup() {
  1070. rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
  1071. rm -f context_srv.txt
  1072. rm -f context_cli.txt
  1073. test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
  1074. test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
  1075. test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
  1076. test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
  1077. exit 1
  1078. }
  1079. #
  1080. # MAIN
  1081. #
  1082. get_options "$@"
  1083. # Optimize filters: if $FILTER and $EXCLUDE can be expressed as shell
  1084. # patterns rather than regular expressions, use a case statement instead
  1085. # of calling grep. To keep the optimizer simple, it is incomplete and only
  1086. # detects simple cases: plain substring, everything, nothing.
  1087. #
  1088. # As an exception, the character '.' is treated as an ordinary character
  1089. # if it is the only special character in the string. This is because it's
  1090. # rare to need "any one character", but needing a literal '.' is common
  1091. # (e.g. '-f "DTLS 1.2"').
  1092. need_grep=
  1093. case "$FILTER" in
  1094. '^$') simple_filter=;;
  1095. '.*') simple_filter='*';;
  1096. *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
  1097. need_grep=1;;
  1098. *) # No regexp or shell-pattern special character
  1099. simple_filter="*$FILTER*";;
  1100. esac
  1101. case "$EXCLUDE" in
  1102. '^$') simple_exclude=;;
  1103. '.*') simple_exclude='*';;
  1104. *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
  1105. need_grep=1;;
  1106. *) # No regexp or shell-pattern special character
  1107. simple_exclude="*$EXCLUDE*";;
  1108. esac
  1109. if [ -n "$need_grep" ]; then
  1110. is_excluded () {
  1111. ! echo "$1" | grep "$FILTER" | grep -q -v "$EXCLUDE"
  1112. }
  1113. else
  1114. is_excluded () {
  1115. case "$1" in
  1116. $simple_exclude) true;;
  1117. $simple_filter) false;;
  1118. *) true;;
  1119. esac
  1120. }
  1121. fi
  1122. # sanity checks, avoid an avalanche of errors
  1123. P_SRV_BIN="${P_SRV%%[ ]*}"
  1124. P_CLI_BIN="${P_CLI%%[ ]*}"
  1125. P_PXY_BIN="${P_PXY%%[ ]*}"
  1126. if [ ! -x "$P_SRV_BIN" ]; then
  1127. echo "Command '$P_SRV_BIN' is not an executable file"
  1128. exit 1
  1129. fi
  1130. if [ ! -x "$P_CLI_BIN" ]; then
  1131. echo "Command '$P_CLI_BIN' is not an executable file"
  1132. exit 1
  1133. fi
  1134. if [ ! -x "$P_PXY_BIN" ]; then
  1135. echo "Command '$P_PXY_BIN' is not an executable file"
  1136. exit 1
  1137. fi
  1138. if [ "$MEMCHECK" -gt 0 ]; then
  1139. if which valgrind >/dev/null 2>&1; then :; else
  1140. echo "Memcheck not possible. Valgrind not found"
  1141. exit 1
  1142. fi
  1143. fi
  1144. if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
  1145. echo "Command '$OPENSSL_CMD' not found"
  1146. exit 1
  1147. fi
  1148. # used by watchdog
  1149. MAIN_PID="$$"
  1150. # We use somewhat arbitrary delays for tests:
  1151. # - how long do we wait for the server to start (when lsof not available)?
  1152. # - how long do we allow for the client to finish?
  1153. # (not to check performance, just to avoid waiting indefinitely)
  1154. # Things are slower with valgrind, so give extra time here.
  1155. #
  1156. # Note: without lsof, there is a trade-off between the running time of this
  1157. # script and the risk of spurious errors because we didn't wait long enough.
  1158. # The watchdog delay on the other hand doesn't affect normal running time of
  1159. # the script, only the case where a client or server gets stuck.
  1160. if [ "$MEMCHECK" -gt 0 ]; then
  1161. START_DELAY=6
  1162. DOG_DELAY=60
  1163. else
  1164. START_DELAY=2
  1165. DOG_DELAY=20
  1166. fi
  1167. # some particular tests need more time:
  1168. # - for the client, we multiply the usual watchdog limit by a factor
  1169. # - for the server, we sleep for a number of seconds after the client exits
  1170. # see client_need_more_time() and server_needs_more_time()
  1171. CLI_DELAY_FACTOR=1
  1172. SRV_DELAY_SECONDS=0
  1173. # fix commands to use this port, force IPv4 while at it
  1174. # +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
  1175. # Note: Using 'localhost' rather than 127.0.0.1 here is unwise, as on many
  1176. # machines that will resolve to ::1, and we don't want ipv6 here.
  1177. P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
  1178. P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
  1179. P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
  1180. O_SRV="$O_SRV -accept $SRV_PORT"
  1181. O_CLI="$O_CLI -connect 127.0.0.1:+SRV_PORT"
  1182. G_SRV="$G_SRV -p $SRV_PORT"
  1183. G_CLI="$G_CLI -p +SRV_PORT"
  1184. if [ -n "${OPENSSL_LEGACY:-}" ]; then
  1185. O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
  1186. O_LEGACY_CLI="$O_LEGACY_CLI -connect 127.0.0.1:+SRV_PORT"
  1187. fi
  1188. if [ -n "${OPENSSL_NEXT:-}" ]; then
  1189. O_NEXT_SRV="$O_NEXT_SRV -accept $SRV_PORT"
  1190. O_NEXT_CLI="$O_NEXT_CLI -connect 127.0.0.1:+SRV_PORT"
  1191. fi
  1192. if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
  1193. G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
  1194. fi
  1195. if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
  1196. G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
  1197. fi
  1198. # Allow SHA-1, because many of our test certificates use it
  1199. P_SRV="$P_SRV allow_sha1=1"
  1200. P_CLI="$P_CLI allow_sha1=1"
  1201. # Also pick a unique name for intermediate files
  1202. SRV_OUT="srv_out.$$"
  1203. CLI_OUT="cli_out.$$"
  1204. PXY_OUT="pxy_out.$$"
  1205. SESSION="session.$$"
  1206. SKIP_NEXT="NO"
  1207. trap cleanup INT TERM HUP
  1208. # Basic test
  1209. # Checks that:
  1210. # - things work with all ciphersuites active (used with config-full in all.sh)
  1211. # - the expected (highest security) parameters are selected
  1212. # ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
  1213. run_test "Default" \
  1214. "$P_SRV debug_level=3" \
  1215. "$P_CLI" \
  1216. 0 \
  1217. -s "Protocol is TLSv1.2" \
  1218. -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
  1219. -s "client hello v3, signature_algorithm ext: 6" \
  1220. -s "ECDHE curve: secp521r1" \
  1221. -S "error" \
  1222. -C "error"
  1223. run_test "Default, DTLS" \
  1224. "$P_SRV dtls=1" \
  1225. "$P_CLI dtls=1" \
  1226. 0 \
  1227. -s "Protocol is DTLSv1.2" \
  1228. -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
  1229. run_test "TLS client auth: required" \
  1230. "$P_SRV auth_mode=required" \
  1231. "$P_CLI" \
  1232. 0 \
  1233. -s "Verifying peer X.509 certificate... ok"
  1234. requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
  1235. requires_config_enabled MBEDTLS_ECDSA_C
  1236. requires_config_enabled MBEDTLS_SHA256_C
  1237. run_test "TLS: password protected client key" \
  1238. "$P_SRV auth_mode=required" \
  1239. "$P_CLI crt_file=data_files/server5.crt key_file=data_files/server5.key.enc key_pwd=PolarSSLTest" \
  1240. 0
  1241. requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
  1242. requires_config_enabled MBEDTLS_ECDSA_C
  1243. requires_config_enabled MBEDTLS_SHA256_C
  1244. run_test "TLS: password protected server key" \
  1245. "$P_SRV crt_file=data_files/server5.crt key_file=data_files/server5.key.enc key_pwd=PolarSSLTest" \
  1246. "$P_CLI" \
  1247. 0
  1248. requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
  1249. requires_config_enabled MBEDTLS_ECDSA_C
  1250. requires_config_enabled MBEDTLS_RSA_C
  1251. requires_config_enabled MBEDTLS_SHA256_C
  1252. run_test "TLS: password protected server key, two certificates" \
  1253. "$P_SRV \
  1254. key_file=data_files/server5.key.enc key_pwd=PolarSSLTest crt_file=data_files/server5.crt \
  1255. key_file2=data_files/server2.key.enc key_pwd2=PolarSSLTest crt_file2=data_files/server2.crt" \
  1256. "$P_CLI" \
  1257. 0
  1258. requires_config_enabled MBEDTLS_ZLIB_SUPPORT
  1259. run_test "Default (compression enabled)" \
  1260. "$P_SRV debug_level=3" \
  1261. "$P_CLI debug_level=3" \
  1262. 0 \
  1263. -s "Allocating compression buffer" \
  1264. -c "Allocating compression buffer" \
  1265. -s "Record expansion is unknown (compression)" \
  1266. -c "Record expansion is unknown (compression)" \
  1267. -S "error" \
  1268. -C "error"
  1269. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  1270. run_test "CA callback on client" \
  1271. "$P_SRV debug_level=3" \
  1272. "$P_CLI ca_callback=1 debug_level=3 " \
  1273. 0 \
  1274. -c "use CA callback for X.509 CRT verification" \
  1275. -S "error" \
  1276. -C "error"
  1277. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  1278. requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
  1279. requires_config_enabled MBEDTLS_ECDSA_C
  1280. requires_config_enabled MBEDTLS_SHA256_C
  1281. run_test "CA callback on server" \
  1282. "$P_SRV auth_mode=required" \
  1283. "$P_CLI ca_callback=1 debug_level=3 crt_file=data_files/server5.crt \
  1284. key_file=data_files/server5.key" \
  1285. 0 \
  1286. -c "use CA callback for X.509 CRT verification" \
  1287. -s "Verifying peer X.509 certificate... ok" \
  1288. -S "error" \
  1289. -C "error"
  1290. # Test using an opaque private key for client authentication
  1291. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  1292. requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
  1293. requires_config_enabled MBEDTLS_ECDSA_C
  1294. requires_config_enabled MBEDTLS_SHA256_C
  1295. run_test "Opaque key for client authentication" \
  1296. "$P_SRV auth_mode=required" \
  1297. "$P_CLI key_opaque=1 crt_file=data_files/server5.crt \
  1298. key_file=data_files/server5.key" \
  1299. 0 \
  1300. -c "key type: Opaque" \
  1301. -s "Verifying peer X.509 certificate... ok" \
  1302. -S "error" \
  1303. -C "error"
  1304. # Test ciphersuites which we expect to be fully supported by PSA Crypto
  1305. # and check that we don't fall back to Mbed TLS' internal crypto primitives.
  1306. run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM
  1307. run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8
  1308. run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CCM
  1309. run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8
  1310. run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
  1311. run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384
  1312. run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA
  1313. run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
  1314. run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384
  1315. requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
  1316. run_test_psa_force_curve "secp521r1"
  1317. requires_config_enabled MBEDTLS_ECP_DP_BP512R1_ENABLED
  1318. run_test_psa_force_curve "brainpoolP512r1"
  1319. requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
  1320. run_test_psa_force_curve "secp384r1"
  1321. requires_config_enabled MBEDTLS_ECP_DP_BP384R1_ENABLED
  1322. run_test_psa_force_curve "brainpoolP384r1"
  1323. requires_config_enabled MBEDTLS_ECP_DP_SECP256R1_ENABLED
  1324. run_test_psa_force_curve "secp256r1"
  1325. requires_config_enabled MBEDTLS_ECP_DP_SECP256K1_ENABLED
  1326. run_test_psa_force_curve "secp256k1"
  1327. requires_config_enabled MBEDTLS_ECP_DP_BP256R1_ENABLED
  1328. run_test_psa_force_curve "brainpoolP256r1"
  1329. requires_config_enabled MBEDTLS_ECP_DP_SECP224R1_ENABLED
  1330. run_test_psa_force_curve "secp224r1"
  1331. ## SECP224K1 is buggy via the PSA API
  1332. ## (https://github.com/ARMmbed/mbedtls/issues/3541),
  1333. ## so it is disabled in PSA even when it's enabled in Mbed TLS.
  1334. ## The proper dependency would be on PSA_WANT_ECC_SECP_K1_224 but
  1335. ## dependencies on PSA symbols in ssl-opt.sh are not implemented yet.
  1336. #requires_config_enabled MBEDTLS_ECP_DP_SECP224K1_ENABLED
  1337. #run_test_psa_force_curve "secp224k1"
  1338. requires_config_enabled MBEDTLS_ECP_DP_SECP192R1_ENABLED
  1339. run_test_psa_force_curve "secp192r1"
  1340. requires_config_enabled MBEDTLS_ECP_DP_SECP192K1_ENABLED
  1341. run_test_psa_force_curve "secp192k1"
  1342. # Test current time in ServerHello
  1343. requires_config_enabled MBEDTLS_HAVE_TIME
  1344. run_test "ServerHello contains gmt_unix_time" \
  1345. "$P_SRV debug_level=3" \
  1346. "$P_CLI debug_level=3" \
  1347. 0 \
  1348. -f "check_server_hello_time" \
  1349. -F "check_server_hello_time"
  1350. # Test for uniqueness of IVs in AEAD ciphersuites
  1351. run_test "Unique IV in GCM" \
  1352. "$P_SRV exchanges=20 debug_level=4" \
  1353. "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
  1354. 0 \
  1355. -u "IV used" \
  1356. -U "IV used"
  1357. # Tests for certificate verification callback
  1358. run_test "Configuration-specific CRT verification callback" \
  1359. "$P_SRV debug_level=3" \
  1360. "$P_CLI context_crt_cb=0 debug_level=3" \
  1361. 0 \
  1362. -S "error" \
  1363. -c "Verify requested for " \
  1364. -c "Use configuration-specific verification callback" \
  1365. -C "Use context-specific verification callback" \
  1366. -C "error"
  1367. run_test "Context-specific CRT verification callback" \
  1368. "$P_SRV debug_level=3" \
  1369. "$P_CLI context_crt_cb=1 debug_level=3" \
  1370. 0 \
  1371. -S "error" \
  1372. -c "Verify requested for " \
  1373. -c "Use context-specific verification callback" \
  1374. -C "Use configuration-specific verification callback" \
  1375. -C "error"
  1376. # Tests for rc4 option
  1377. requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
  1378. run_test "RC4: server disabled, client enabled" \
  1379. "$P_SRV" \
  1380. "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  1381. 1 \
  1382. -s "SSL - The server has no ciphersuites in common"
  1383. requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
  1384. run_test "RC4: server half, client enabled" \
  1385. "$P_SRV arc4=1" \
  1386. "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  1387. 1 \
  1388. -s "SSL - The server has no ciphersuites in common"
  1389. run_test "RC4: server enabled, client disabled" \
  1390. "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  1391. "$P_CLI" \
  1392. 1 \
  1393. -s "SSL - The server has no ciphersuites in common"
  1394. run_test "RC4: both enabled" \
  1395. "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  1396. "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  1397. 0 \
  1398. -S "SSL - None of the common ciphersuites is usable" \
  1399. -S "SSL - The server has no ciphersuites in common"
  1400. # Test empty CA list in CertificateRequest in TLS 1.1 and earlier
  1401. requires_gnutls
  1402. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
  1403. run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
  1404. "$G_SRV"\
  1405. "$P_CLI force_version=tls1_1" \
  1406. 0
  1407. requires_gnutls
  1408. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
  1409. run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
  1410. "$G_SRV"\
  1411. "$P_CLI force_version=tls1" \
  1412. 0
  1413. # Tests for SHA-1 support
  1414. run_test "SHA-1 forbidden by default in server certificate" \
  1415. "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
  1416. "$P_CLI debug_level=2 allow_sha1=0" \
  1417. 1 \
  1418. -c "The certificate is signed with an unacceptable hash"
  1419. run_test "SHA-1 explicitly allowed in server certificate" \
  1420. "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
  1421. "$P_CLI allow_sha1=1" \
  1422. 0
  1423. run_test "SHA-256 allowed by default in server certificate" \
  1424. "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
  1425. "$P_CLI allow_sha1=0" \
  1426. 0
  1427. run_test "SHA-1 forbidden by default in client certificate" \
  1428. "$P_SRV auth_mode=required allow_sha1=0" \
  1429. "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
  1430. 1 \
  1431. -s "The certificate is signed with an unacceptable hash"
  1432. run_test "SHA-1 explicitly allowed in client certificate" \
  1433. "$P_SRV auth_mode=required allow_sha1=1" \
  1434. "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
  1435. 0
  1436. run_test "SHA-256 allowed by default in client certificate" \
  1437. "$P_SRV auth_mode=required allow_sha1=0" \
  1438. "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
  1439. 0
  1440. # Tests for datagram packing
  1441. run_test "DTLS: multiple records in same datagram, client and server" \
  1442. "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
  1443. "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
  1444. 0 \
  1445. -c "next record in same datagram" \
  1446. -s "next record in same datagram"
  1447. run_test "DTLS: multiple records in same datagram, client only" \
  1448. "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
  1449. "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
  1450. 0 \
  1451. -s "next record in same datagram" \
  1452. -C "next record in same datagram"
  1453. run_test "DTLS: multiple records in same datagram, server only" \
  1454. "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
  1455. "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
  1456. 0 \
  1457. -S "next record in same datagram" \
  1458. -c "next record in same datagram"
  1459. run_test "DTLS: multiple records in same datagram, neither client nor server" \
  1460. "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
  1461. "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
  1462. 0 \
  1463. -S "next record in same datagram" \
  1464. -C "next record in same datagram"
  1465. # Tests for Truncated HMAC extension
  1466. run_test "Truncated HMAC: client default, server default" \
  1467. "$P_SRV debug_level=4" \
  1468. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  1469. 0 \
  1470. -s "dumping 'expected mac' (20 bytes)" \
  1471. -S "dumping 'expected mac' (10 bytes)"
  1472. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  1473. run_test "Truncated HMAC: client disabled, server default" \
  1474. "$P_SRV debug_level=4" \
  1475. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
  1476. 0 \
  1477. -s "dumping 'expected mac' (20 bytes)" \
  1478. -S "dumping 'expected mac' (10 bytes)"
  1479. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  1480. run_test "Truncated HMAC: client enabled, server default" \
  1481. "$P_SRV debug_level=4" \
  1482. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
  1483. 0 \
  1484. -s "dumping 'expected mac' (20 bytes)" \
  1485. -S "dumping 'expected mac' (10 bytes)"
  1486. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  1487. run_test "Truncated HMAC: client enabled, server disabled" \
  1488. "$P_SRV debug_level=4 trunc_hmac=0" \
  1489. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
  1490. 0 \
  1491. -s "dumping 'expected mac' (20 bytes)" \
  1492. -S "dumping 'expected mac' (10 bytes)"
  1493. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  1494. run_test "Truncated HMAC: client disabled, server enabled" \
  1495. "$P_SRV debug_level=4 trunc_hmac=1" \
  1496. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
  1497. 0 \
  1498. -s "dumping 'expected mac' (20 bytes)" \
  1499. -S "dumping 'expected mac' (10 bytes)"
  1500. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  1501. run_test "Truncated HMAC: client enabled, server enabled" \
  1502. "$P_SRV debug_level=4 trunc_hmac=1" \
  1503. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
  1504. 0 \
  1505. -S "dumping 'expected mac' (20 bytes)" \
  1506. -s "dumping 'expected mac' (10 bytes)"
  1507. run_test "Truncated HMAC, DTLS: client default, server default" \
  1508. "$P_SRV dtls=1 debug_level=4" \
  1509. "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  1510. 0 \
  1511. -s "dumping 'expected mac' (20 bytes)" \
  1512. -S "dumping 'expected mac' (10 bytes)"
  1513. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  1514. run_test "Truncated HMAC, DTLS: client disabled, server default" \
  1515. "$P_SRV dtls=1 debug_level=4" \
  1516. "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
  1517. 0 \
  1518. -s "dumping 'expected mac' (20 bytes)" \
  1519. -S "dumping 'expected mac' (10 bytes)"
  1520. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  1521. run_test "Truncated HMAC, DTLS: client enabled, server default" \
  1522. "$P_SRV dtls=1 debug_level=4" \
  1523. "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
  1524. 0 \
  1525. -s "dumping 'expected mac' (20 bytes)" \
  1526. -S "dumping 'expected mac' (10 bytes)"
  1527. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  1528. run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
  1529. "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
  1530. "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
  1531. 0 \
  1532. -s "dumping 'expected mac' (20 bytes)" \
  1533. -S "dumping 'expected mac' (10 bytes)"
  1534. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  1535. run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
  1536. "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
  1537. "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
  1538. 0 \
  1539. -s "dumping 'expected mac' (20 bytes)" \
  1540. -S "dumping 'expected mac' (10 bytes)"
  1541. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  1542. run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
  1543. "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
  1544. "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
  1545. 0 \
  1546. -S "dumping 'expected mac' (20 bytes)" \
  1547. -s "dumping 'expected mac' (10 bytes)"
  1548. # Tests for Context serialization
  1549. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1550. run_test "Context serialization, client serializes, CCM" \
  1551. "$P_SRV dtls=1 serialize=0 exchanges=2" \
  1552. "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
  1553. 0 \
  1554. -c "Deserializing connection..." \
  1555. -S "Deserializing connection..."
  1556. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1557. run_test "Context serialization, client serializes, ChaChaPoly" \
  1558. "$P_SRV dtls=1 serialize=0 exchanges=2" \
  1559. "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
  1560. 0 \
  1561. -c "Deserializing connection..." \
  1562. -S "Deserializing connection..."
  1563. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1564. run_test "Context serialization, client serializes, GCM" \
  1565. "$P_SRV dtls=1 serialize=0 exchanges=2" \
  1566. "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
  1567. 0 \
  1568. -c "Deserializing connection..." \
  1569. -S "Deserializing connection..."
  1570. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1571. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1572. run_test "Context serialization, client serializes, with CID" \
  1573. "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
  1574. "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
  1575. 0 \
  1576. -c "Deserializing connection..." \
  1577. -S "Deserializing connection..."
  1578. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1579. run_test "Context serialization, server serializes, CCM" \
  1580. "$P_SRV dtls=1 serialize=1 exchanges=2" \
  1581. "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
  1582. 0 \
  1583. -C "Deserializing connection..." \
  1584. -s "Deserializing connection..."
  1585. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1586. run_test "Context serialization, server serializes, ChaChaPoly" \
  1587. "$P_SRV dtls=1 serialize=1 exchanges=2" \
  1588. "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
  1589. 0 \
  1590. -C "Deserializing connection..." \
  1591. -s "Deserializing connection..."
  1592. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1593. run_test "Context serialization, server serializes, GCM" \
  1594. "$P_SRV dtls=1 serialize=1 exchanges=2" \
  1595. "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
  1596. 0 \
  1597. -C "Deserializing connection..." \
  1598. -s "Deserializing connection..."
  1599. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1600. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1601. run_test "Context serialization, server serializes, with CID" \
  1602. "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
  1603. "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
  1604. 0 \
  1605. -C "Deserializing connection..." \
  1606. -s "Deserializing connection..."
  1607. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1608. run_test "Context serialization, both serialize, CCM" \
  1609. "$P_SRV dtls=1 serialize=1 exchanges=2" \
  1610. "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
  1611. 0 \
  1612. -c "Deserializing connection..." \
  1613. -s "Deserializing connection..."
  1614. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1615. run_test "Context serialization, both serialize, ChaChaPoly" \
  1616. "$P_SRV dtls=1 serialize=1 exchanges=2" \
  1617. "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
  1618. 0 \
  1619. -c "Deserializing connection..." \
  1620. -s "Deserializing connection..."
  1621. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1622. run_test "Context serialization, both serialize, GCM" \
  1623. "$P_SRV dtls=1 serialize=1 exchanges=2" \
  1624. "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
  1625. 0 \
  1626. -c "Deserializing connection..." \
  1627. -s "Deserializing connection..."
  1628. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1629. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1630. run_test "Context serialization, both serialize, with CID" \
  1631. "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
  1632. "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
  1633. 0 \
  1634. -c "Deserializing connection..." \
  1635. -s "Deserializing connection..."
  1636. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1637. run_test "Context serialization, re-init, client serializes, CCM" \
  1638. "$P_SRV dtls=1 serialize=0 exchanges=2" \
  1639. "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
  1640. 0 \
  1641. -c "Deserializing connection..." \
  1642. -S "Deserializing connection..."
  1643. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1644. run_test "Context serialization, re-init, client serializes, ChaChaPoly" \
  1645. "$P_SRV dtls=1 serialize=0 exchanges=2" \
  1646. "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
  1647. 0 \
  1648. -c "Deserializing connection..." \
  1649. -S "Deserializing connection..."
  1650. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1651. run_test "Context serialization, re-init, client serializes, GCM" \
  1652. "$P_SRV dtls=1 serialize=0 exchanges=2" \
  1653. "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
  1654. 0 \
  1655. -c "Deserializing connection..." \
  1656. -S "Deserializing connection..."
  1657. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1658. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1659. run_test "Context serialization, re-init, client serializes, with CID" \
  1660. "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
  1661. "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
  1662. 0 \
  1663. -c "Deserializing connection..." \
  1664. -S "Deserializing connection..."
  1665. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1666. run_test "Context serialization, re-init, server serializes, CCM" \
  1667. "$P_SRV dtls=1 serialize=2 exchanges=2" \
  1668. "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
  1669. 0 \
  1670. -C "Deserializing connection..." \
  1671. -s "Deserializing connection..."
  1672. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1673. run_test "Context serialization, re-init, server serializes, ChaChaPoly" \
  1674. "$P_SRV dtls=1 serialize=2 exchanges=2" \
  1675. "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
  1676. 0 \
  1677. -C "Deserializing connection..." \
  1678. -s "Deserializing connection..."
  1679. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1680. run_test "Context serialization, re-init, server serializes, GCM" \
  1681. "$P_SRV dtls=1 serialize=2 exchanges=2" \
  1682. "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
  1683. 0 \
  1684. -C "Deserializing connection..." \
  1685. -s "Deserializing connection..."
  1686. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1687. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1688. run_test "Context serialization, re-init, server serializes, with CID" \
  1689. "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
  1690. "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
  1691. 0 \
  1692. -C "Deserializing connection..." \
  1693. -s "Deserializing connection..."
  1694. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1695. run_test "Context serialization, re-init, both serialize, CCM" \
  1696. "$P_SRV dtls=1 serialize=2 exchanges=2" \
  1697. "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
  1698. 0 \
  1699. -c "Deserializing connection..." \
  1700. -s "Deserializing connection..."
  1701. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1702. run_test "Context serialization, re-init, both serialize, ChaChaPoly" \
  1703. "$P_SRV dtls=1 serialize=2 exchanges=2" \
  1704. "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
  1705. 0 \
  1706. -c "Deserializing connection..." \
  1707. -s "Deserializing connection..."
  1708. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1709. run_test "Context serialization, re-init, both serialize, GCM" \
  1710. "$P_SRV dtls=1 serialize=2 exchanges=2" \
  1711. "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
  1712. 0 \
  1713. -c "Deserializing connection..." \
  1714. -s "Deserializing connection..."
  1715. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1716. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1717. run_test "Context serialization, re-init, both serialize, with CID" \
  1718. "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
  1719. "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
  1720. 0 \
  1721. -c "Deserializing connection..." \
  1722. -s "Deserializing connection..."
  1723. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1724. run_test "Saving the serialized context to a file" \
  1725. "$P_SRV dtls=1 serialize=1 context_file=context_srv.txt" \
  1726. "$P_CLI dtls=1 serialize=1 context_file=context_cli.txt" \
  1727. 0 \
  1728. -s "Save serialized context to a file... ok" \
  1729. -c "Save serialized context to a file... ok"
  1730. rm -f context_srv.txt
  1731. rm -f context_cli.txt
  1732. # Tests for DTLS Connection ID extension
  1733. # So far, the CID API isn't implemented, so we can't
  1734. # grep for output witnessing its use. This needs to be
  1735. # changed once the CID extension is implemented.
  1736. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1737. run_test "Connection ID: Cli enabled, Srv disabled" \
  1738. "$P_SRV debug_level=3 dtls=1 cid=0" \
  1739. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
  1740. 0 \
  1741. -s "Disable use of CID extension." \
  1742. -s "found CID extension" \
  1743. -s "Client sent CID extension, but CID disabled" \
  1744. -c "Enable use of CID extension." \
  1745. -c "client hello, adding CID extension" \
  1746. -S "server hello, adding CID extension" \
  1747. -C "found CID extension" \
  1748. -S "Copy CIDs into SSL transform" \
  1749. -C "Copy CIDs into SSL transform" \
  1750. -c "Use of Connection ID was rejected by the server"
  1751. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1752. run_test "Connection ID: Cli disabled, Srv enabled" \
  1753. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
  1754. "$P_CLI debug_level=3 dtls=1 cid=0" \
  1755. 0 \
  1756. -c "Disable use of CID extension." \
  1757. -C "client hello, adding CID extension" \
  1758. -S "found CID extension" \
  1759. -s "Enable use of CID extension." \
  1760. -S "server hello, adding CID extension" \
  1761. -C "found CID extension" \
  1762. -S "Copy CIDs into SSL transform" \
  1763. -C "Copy CIDs into SSL transform" \
  1764. -s "Use of Connection ID was not offered by client"
  1765. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1766. run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty" \
  1767. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
  1768. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef" \
  1769. 0 \
  1770. -c "Enable use of CID extension." \
  1771. -s "Enable use of CID extension." \
  1772. -c "client hello, adding CID extension" \
  1773. -s "found CID extension" \
  1774. -s "Use of CID extension negotiated" \
  1775. -s "server hello, adding CID extension" \
  1776. -c "found CID extension" \
  1777. -c "Use of CID extension negotiated" \
  1778. -s "Copy CIDs into SSL transform" \
  1779. -c "Copy CIDs into SSL transform" \
  1780. -c "Peer CID (length 2 Bytes): de ad" \
  1781. -s "Peer CID (length 2 Bytes): be ef" \
  1782. -s "Use of Connection ID has been negotiated" \
  1783. -c "Use of Connection ID has been negotiated"
  1784. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1785. run_test "Connection ID, 3D: Cli+Srv enabled, Cli+Srv CID nonempty" \
  1786. -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
  1787. "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead" \
  1788. "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef" \
  1789. 0 \
  1790. -c "Enable use of CID extension." \
  1791. -s "Enable use of CID extension." \
  1792. -c "client hello, adding CID extension" \
  1793. -s "found CID extension" \
  1794. -s "Use of CID extension negotiated" \
  1795. -s "server hello, adding CID extension" \
  1796. -c "found CID extension" \
  1797. -c "Use of CID extension negotiated" \
  1798. -s "Copy CIDs into SSL transform" \
  1799. -c "Copy CIDs into SSL transform" \
  1800. -c "Peer CID (length 2 Bytes): de ad" \
  1801. -s "Peer CID (length 2 Bytes): be ef" \
  1802. -s "Use of Connection ID has been negotiated" \
  1803. -c "Use of Connection ID has been negotiated" \
  1804. -c "ignoring unexpected CID" \
  1805. -s "ignoring unexpected CID"
  1806. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1807. run_test "Connection ID, MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
  1808. -p "$P_PXY mtu=800" \
  1809. "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
  1810. "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
  1811. 0 \
  1812. -c "Enable use of CID extension." \
  1813. -s "Enable use of CID extension." \
  1814. -c "client hello, adding CID extension" \
  1815. -s "found CID extension" \
  1816. -s "Use of CID extension negotiated" \
  1817. -s "server hello, adding CID extension" \
  1818. -c "found CID extension" \
  1819. -c "Use of CID extension negotiated" \
  1820. -s "Copy CIDs into SSL transform" \
  1821. -c "Copy CIDs into SSL transform" \
  1822. -c "Peer CID (length 2 Bytes): de ad" \
  1823. -s "Peer CID (length 2 Bytes): be ef" \
  1824. -s "Use of Connection ID has been negotiated" \
  1825. -c "Use of Connection ID has been negotiated"
  1826. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1827. run_test "Connection ID, 3D+MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
  1828. -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
  1829. "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
  1830. "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
  1831. 0 \
  1832. -c "Enable use of CID extension." \
  1833. -s "Enable use of CID extension." \
  1834. -c "client hello, adding CID extension" \
  1835. -s "found CID extension" \
  1836. -s "Use of CID extension negotiated" \
  1837. -s "server hello, adding CID extension" \
  1838. -c "found CID extension" \
  1839. -c "Use of CID extension negotiated" \
  1840. -s "Copy CIDs into SSL transform" \
  1841. -c "Copy CIDs into SSL transform" \
  1842. -c "Peer CID (length 2 Bytes): de ad" \
  1843. -s "Peer CID (length 2 Bytes): be ef" \
  1844. -s "Use of Connection ID has been negotiated" \
  1845. -c "Use of Connection ID has been negotiated" \
  1846. -c "ignoring unexpected CID" \
  1847. -s "ignoring unexpected CID"
  1848. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1849. run_test "Connection ID: Cli+Srv enabled, Cli CID empty" \
  1850. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
  1851. "$P_CLI debug_level=3 dtls=1 cid=1" \
  1852. 0 \
  1853. -c "Enable use of CID extension." \
  1854. -s "Enable use of CID extension." \
  1855. -c "client hello, adding CID extension" \
  1856. -s "found CID extension" \
  1857. -s "Use of CID extension negotiated" \
  1858. -s "server hello, adding CID extension" \
  1859. -c "found CID extension" \
  1860. -c "Use of CID extension negotiated" \
  1861. -s "Copy CIDs into SSL transform" \
  1862. -c "Copy CIDs into SSL transform" \
  1863. -c "Peer CID (length 4 Bytes): de ad be ef" \
  1864. -s "Peer CID (length 0 Bytes):" \
  1865. -s "Use of Connection ID has been negotiated" \
  1866. -c "Use of Connection ID has been negotiated"
  1867. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1868. run_test "Connection ID: Cli+Srv enabled, Srv CID empty" \
  1869. "$P_SRV debug_level=3 dtls=1 cid=1" \
  1870. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
  1871. 0 \
  1872. -c "Enable use of CID extension." \
  1873. -s "Enable use of CID extension." \
  1874. -c "client hello, adding CID extension" \
  1875. -s "found CID extension" \
  1876. -s "Use of CID extension negotiated" \
  1877. -s "server hello, adding CID extension" \
  1878. -c "found CID extension" \
  1879. -c "Use of CID extension negotiated" \
  1880. -s "Copy CIDs into SSL transform" \
  1881. -c "Copy CIDs into SSL transform" \
  1882. -s "Peer CID (length 4 Bytes): de ad be ef" \
  1883. -c "Peer CID (length 0 Bytes):" \
  1884. -s "Use of Connection ID has been negotiated" \
  1885. -c "Use of Connection ID has been negotiated"
  1886. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1887. run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty" \
  1888. "$P_SRV debug_level=3 dtls=1 cid=1" \
  1889. "$P_CLI debug_level=3 dtls=1 cid=1" \
  1890. 0 \
  1891. -c "Enable use of CID extension." \
  1892. -s "Enable use of CID extension." \
  1893. -c "client hello, adding CID extension" \
  1894. -s "found CID extension" \
  1895. -s "Use of CID extension negotiated" \
  1896. -s "server hello, adding CID extension" \
  1897. -c "found CID extension" \
  1898. -c "Use of CID extension negotiated" \
  1899. -s "Copy CIDs into SSL transform" \
  1900. -c "Copy CIDs into SSL transform" \
  1901. -S "Use of Connection ID has been negotiated" \
  1902. -C "Use of Connection ID has been negotiated"
  1903. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1904. run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CCM-8" \
  1905. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
  1906. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
  1907. 0 \
  1908. -c "Enable use of CID extension." \
  1909. -s "Enable use of CID extension." \
  1910. -c "client hello, adding CID extension" \
  1911. -s "found CID extension" \
  1912. -s "Use of CID extension negotiated" \
  1913. -s "server hello, adding CID extension" \
  1914. -c "found CID extension" \
  1915. -c "Use of CID extension negotiated" \
  1916. -s "Copy CIDs into SSL transform" \
  1917. -c "Copy CIDs into SSL transform" \
  1918. -c "Peer CID (length 2 Bytes): de ad" \
  1919. -s "Peer CID (length 2 Bytes): be ef" \
  1920. -s "Use of Connection ID has been negotiated" \
  1921. -c "Use of Connection ID has been negotiated"
  1922. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1923. run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CCM-8" \
  1924. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
  1925. "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
  1926. 0 \
  1927. -c "Enable use of CID extension." \
  1928. -s "Enable use of CID extension." \
  1929. -c "client hello, adding CID extension" \
  1930. -s "found CID extension" \
  1931. -s "Use of CID extension negotiated" \
  1932. -s "server hello, adding CID extension" \
  1933. -c "found CID extension" \
  1934. -c "Use of CID extension negotiated" \
  1935. -s "Copy CIDs into SSL transform" \
  1936. -c "Copy CIDs into SSL transform" \
  1937. -c "Peer CID (length 4 Bytes): de ad be ef" \
  1938. -s "Peer CID (length 0 Bytes):" \
  1939. -s "Use of Connection ID has been negotiated" \
  1940. -c "Use of Connection ID has been negotiated"
  1941. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1942. run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CCM-8" \
  1943. "$P_SRV debug_level=3 dtls=1 cid=1" \
  1944. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
  1945. 0 \
  1946. -c "Enable use of CID extension." \
  1947. -s "Enable use of CID extension." \
  1948. -c "client hello, adding CID extension" \
  1949. -s "found CID extension" \
  1950. -s "Use of CID extension negotiated" \
  1951. -s "server hello, adding CID extension" \
  1952. -c "found CID extension" \
  1953. -c "Use of CID extension negotiated" \
  1954. -s "Copy CIDs into SSL transform" \
  1955. -c "Copy CIDs into SSL transform" \
  1956. -s "Peer CID (length 4 Bytes): de ad be ef" \
  1957. -c "Peer CID (length 0 Bytes):" \
  1958. -s "Use of Connection ID has been negotiated" \
  1959. -c "Use of Connection ID has been negotiated"
  1960. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1961. run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CCM-8" \
  1962. "$P_SRV debug_level=3 dtls=1 cid=1" \
  1963. "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
  1964. 0 \
  1965. -c "Enable use of CID extension." \
  1966. -s "Enable use of CID extension." \
  1967. -c "client hello, adding CID extension" \
  1968. -s "found CID extension" \
  1969. -s "Use of CID extension negotiated" \
  1970. -s "server hello, adding CID extension" \
  1971. -c "found CID extension" \
  1972. -c "Use of CID extension negotiated" \
  1973. -s "Copy CIDs into SSL transform" \
  1974. -c "Copy CIDs into SSL transform" \
  1975. -S "Use of Connection ID has been negotiated" \
  1976. -C "Use of Connection ID has been negotiated"
  1977. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1978. run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CBC" \
  1979. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
  1980. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
  1981. 0 \
  1982. -c "Enable use of CID extension." \
  1983. -s "Enable use of CID extension." \
  1984. -c "client hello, adding CID extension" \
  1985. -s "found CID extension" \
  1986. -s "Use of CID extension negotiated" \
  1987. -s "server hello, adding CID extension" \
  1988. -c "found CID extension" \
  1989. -c "Use of CID extension negotiated" \
  1990. -s "Copy CIDs into SSL transform" \
  1991. -c "Copy CIDs into SSL transform" \
  1992. -c "Peer CID (length 2 Bytes): de ad" \
  1993. -s "Peer CID (length 2 Bytes): be ef" \
  1994. -s "Use of Connection ID has been negotiated" \
  1995. -c "Use of Connection ID has been negotiated"
  1996. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1997. run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CBC" \
  1998. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
  1999. "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
  2000. 0 \
  2001. -c "Enable use of CID extension." \
  2002. -s "Enable use of CID extension." \
  2003. -c "client hello, adding CID extension" \
  2004. -s "found CID extension" \
  2005. -s "Use of CID extension negotiated" \
  2006. -s "server hello, adding CID extension" \
  2007. -c "found CID extension" \
  2008. -c "Use of CID extension negotiated" \
  2009. -s "Copy CIDs into SSL transform" \
  2010. -c "Copy CIDs into SSL transform" \
  2011. -c "Peer CID (length 4 Bytes): de ad be ef" \
  2012. -s "Peer CID (length 0 Bytes):" \
  2013. -s "Use of Connection ID has been negotiated" \
  2014. -c "Use of Connection ID has been negotiated"
  2015. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  2016. run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CBC" \
  2017. "$P_SRV debug_level=3 dtls=1 cid=1" \
  2018. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
  2019. 0 \
  2020. -c "Enable use of CID extension." \
  2021. -s "Enable use of CID extension." \
  2022. -c "client hello, adding CID extension" \
  2023. -s "found CID extension" \
  2024. -s "Use of CID extension negotiated" \
  2025. -s "server hello, adding CID extension" \
  2026. -c "found CID extension" \
  2027. -c "Use of CID extension negotiated" \
  2028. -s "Copy CIDs into SSL transform" \
  2029. -c "Copy CIDs into SSL transform" \
  2030. -s "Peer CID (length 4 Bytes): de ad be ef" \
  2031. -c "Peer CID (length 0 Bytes):" \
  2032. -s "Use of Connection ID has been negotiated" \
  2033. -c "Use of Connection ID has been negotiated"
  2034. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  2035. run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CBC" \
  2036. "$P_SRV debug_level=3 dtls=1 cid=1" \
  2037. "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
  2038. 0 \
  2039. -c "Enable use of CID extension." \
  2040. -s "Enable use of CID extension." \
  2041. -c "client hello, adding CID extension" \
  2042. -s "found CID extension" \
  2043. -s "Use of CID extension negotiated" \
  2044. -s "server hello, adding CID extension" \
  2045. -c "found CID extension" \
  2046. -c "Use of CID extension negotiated" \
  2047. -s "Copy CIDs into SSL transform" \
  2048. -c "Copy CIDs into SSL transform" \
  2049. -S "Use of Connection ID has been negotiated" \
  2050. -C "Use of Connection ID has been negotiated"
  2051. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  2052. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  2053. run_test "Connection ID: Cli+Srv enabled, renegotiate without change of CID" \
  2054. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
  2055. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
  2056. 0 \
  2057. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  2058. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  2059. -s "(initial handshake) Use of Connection ID has been negotiated" \
  2060. -c "(initial handshake) Use of Connection ID has been negotiated" \
  2061. -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  2062. -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  2063. -s "(after renegotiation) Use of Connection ID has been negotiated" \
  2064. -c "(after renegotiation) Use of Connection ID has been negotiated"
  2065. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  2066. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  2067. run_test "Connection ID: Cli+Srv enabled, renegotiate with different CID" \
  2068. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
  2069. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
  2070. 0 \
  2071. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  2072. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  2073. -s "(initial handshake) Use of Connection ID has been negotiated" \
  2074. -c "(initial handshake) Use of Connection ID has been negotiated" \
  2075. -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  2076. -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  2077. -s "(after renegotiation) Use of Connection ID has been negotiated" \
  2078. -c "(after renegotiation) Use of Connection ID has been negotiated"
  2079. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  2080. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  2081. run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate with different CID" \
  2082. "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead cid_val_renego=beef renegotiation=1" \
  2083. "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
  2084. 0 \
  2085. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  2086. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  2087. -s "(initial handshake) Use of Connection ID has been negotiated" \
  2088. -c "(initial handshake) Use of Connection ID has been negotiated" \
  2089. -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  2090. -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  2091. -s "(after renegotiation) Use of Connection ID has been negotiated" \
  2092. -c "(after renegotiation) Use of Connection ID has been negotiated"
  2093. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  2094. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  2095. run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate with different CID" \
  2096. -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
  2097. "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
  2098. "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
  2099. 0 \
  2100. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  2101. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  2102. -s "(initial handshake) Use of Connection ID has been negotiated" \
  2103. -c "(initial handshake) Use of Connection ID has been negotiated" \
  2104. -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  2105. -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  2106. -s "(after renegotiation) Use of Connection ID has been negotiated" \
  2107. -c "(after renegotiation) Use of Connection ID has been negotiated" \
  2108. -c "ignoring unexpected CID" \
  2109. -s "ignoring unexpected CID"
  2110. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  2111. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  2112. run_test "Connection ID: Cli+Srv enabled, renegotiate without CID" \
  2113. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
  2114. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
  2115. 0 \
  2116. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  2117. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  2118. -s "(initial handshake) Use of Connection ID has been negotiated" \
  2119. -c "(initial handshake) Use of Connection ID has been negotiated" \
  2120. -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  2121. -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  2122. -C "(after renegotiation) Use of Connection ID has been negotiated" \
  2123. -S "(after renegotiation) Use of Connection ID has been negotiated"
  2124. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  2125. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  2126. run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate without CID" \
  2127. "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
  2128. "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
  2129. 0 \
  2130. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  2131. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  2132. -s "(initial handshake) Use of Connection ID has been negotiated" \
  2133. -c "(initial handshake) Use of Connection ID has been negotiated" \
  2134. -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  2135. -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  2136. -C "(after renegotiation) Use of Connection ID has been negotiated" \
  2137. -S "(after renegotiation) Use of Connection ID has been negotiated"
  2138. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  2139. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  2140. run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate without CID" \
  2141. -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
  2142. "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
  2143. "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
  2144. 0 \
  2145. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  2146. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  2147. -s "(initial handshake) Use of Connection ID has been negotiated" \
  2148. -c "(initial handshake) Use of Connection ID has been negotiated" \
  2149. -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  2150. -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  2151. -C "(after renegotiation) Use of Connection ID has been negotiated" \
  2152. -S "(after renegotiation) Use of Connection ID has been negotiated" \
  2153. -c "ignoring unexpected CID" \
  2154. -s "ignoring unexpected CID"
  2155. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  2156. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  2157. run_test "Connection ID: Cli+Srv enabled, CID on renegotiation" \
  2158. "$P_SRV debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
  2159. "$P_CLI debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
  2160. 0 \
  2161. -S "(initial handshake) Use of Connection ID has been negotiated" \
  2162. -C "(initial handshake) Use of Connection ID has been negotiated" \
  2163. -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  2164. -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  2165. -c "(after renegotiation) Use of Connection ID has been negotiated" \
  2166. -s "(after renegotiation) Use of Connection ID has been negotiated"
  2167. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  2168. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  2169. run_test "Connection ID, no packing: Cli+Srv enabled, CID on renegotiation" \
  2170. "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
  2171. "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
  2172. 0 \
  2173. -S "(initial handshake) Use of Connection ID has been negotiated" \
  2174. -C "(initial handshake) Use of Connection ID has been negotiated" \
  2175. -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  2176. -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  2177. -c "(after renegotiation) Use of Connection ID has been negotiated" \
  2178. -s "(after renegotiation) Use of Connection ID has been negotiated"
  2179. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  2180. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  2181. run_test "Connection ID, 3D+MTU: Cli+Srv enabled, CID on renegotiation" \
  2182. -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
  2183. "$P_SRV debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
  2184. "$P_CLI debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
  2185. 0 \
  2186. -S "(initial handshake) Use of Connection ID has been negotiated" \
  2187. -C "(initial handshake) Use of Connection ID has been negotiated" \
  2188. -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  2189. -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  2190. -c "(after renegotiation) Use of Connection ID has been negotiated" \
  2191. -s "(after renegotiation) Use of Connection ID has been negotiated" \
  2192. -c "ignoring unexpected CID" \
  2193. -s "ignoring unexpected CID"
  2194. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  2195. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  2196. run_test "Connection ID: Cli+Srv enabled, Cli disables on renegotiation" \
  2197. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
  2198. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
  2199. 0 \
  2200. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  2201. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  2202. -s "(initial handshake) Use of Connection ID has been negotiated" \
  2203. -c "(initial handshake) Use of Connection ID has been negotiated" \
  2204. -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  2205. -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  2206. -C "(after renegotiation) Use of Connection ID has been negotiated" \
  2207. -S "(after renegotiation) Use of Connection ID has been negotiated" \
  2208. -s "(after renegotiation) Use of Connection ID was not offered by client"
  2209. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  2210. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  2211. run_test "Connection ID, 3D: Cli+Srv enabled, Cli disables on renegotiation" \
  2212. -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
  2213. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
  2214. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
  2215. 0 \
  2216. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  2217. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  2218. -s "(initial handshake) Use of Connection ID has been negotiated" \
  2219. -c "(initial handshake) Use of Connection ID has been negotiated" \
  2220. -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  2221. -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  2222. -C "(after renegotiation) Use of Connection ID has been negotiated" \
  2223. -S "(after renegotiation) Use of Connection ID has been negotiated" \
  2224. -s "(after renegotiation) Use of Connection ID was not offered by client" \
  2225. -c "ignoring unexpected CID" \
  2226. -s "ignoring unexpected CID"
  2227. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  2228. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  2229. run_test "Connection ID: Cli+Srv enabled, Srv disables on renegotiation" \
  2230. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
  2231. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
  2232. 0 \
  2233. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  2234. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  2235. -s "(initial handshake) Use of Connection ID has been negotiated" \
  2236. -c "(initial handshake) Use of Connection ID has been negotiated" \
  2237. -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  2238. -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  2239. -C "(after renegotiation) Use of Connection ID has been negotiated" \
  2240. -S "(after renegotiation) Use of Connection ID has been negotiated" \
  2241. -c "(after renegotiation) Use of Connection ID was rejected by the server"
  2242. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  2243. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  2244. run_test "Connection ID, 3D: Cli+Srv enabled, Srv disables on renegotiation" \
  2245. -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
  2246. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
  2247. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
  2248. 0 \
  2249. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  2250. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  2251. -s "(initial handshake) Use of Connection ID has been negotiated" \
  2252. -c "(initial handshake) Use of Connection ID has been negotiated" \
  2253. -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  2254. -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  2255. -C "(after renegotiation) Use of Connection ID has been negotiated" \
  2256. -S "(after renegotiation) Use of Connection ID has been negotiated" \
  2257. -c "(after renegotiation) Use of Connection ID was rejected by the server" \
  2258. -c "ignoring unexpected CID" \
  2259. -s "ignoring unexpected CID"
  2260. # This and the test below it require MAX_CONTENT_LEN to be at least MFL+1, because the
  2261. # tests check that the buffer contents are reallocated when the message is
  2262. # larger than the buffer.
  2263. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  2264. requires_config_enabled MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
  2265. requires_max_content_len 513
  2266. run_test "Connection ID: Cli+Srv enabled, variable buffer lengths, MFL=512" \
  2267. "$P_SRV dtls=1 cid=1 cid_val=dead debug_level=2" \
  2268. "$P_CLI force_ciphersuite="TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" max_frag_len=512 dtls=1 cid=1 cid_val=beef" \
  2269. 0 \
  2270. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  2271. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  2272. -s "(initial handshake) Use of Connection ID has been negotiated" \
  2273. -c "(initial handshake) Use of Connection ID has been negotiated" \
  2274. -s "Reallocating in_buf" \
  2275. -s "Reallocating out_buf"
  2276. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  2277. requires_config_enabled MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
  2278. requires_max_content_len 1025
  2279. run_test "Connection ID: Cli+Srv enabled, variable buffer lengths, MFL=1024" \
  2280. "$P_SRV dtls=1 cid=1 cid_val=dead debug_level=2" \
  2281. "$P_CLI force_ciphersuite="TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" max_frag_len=1024 dtls=1 cid=1 cid_val=beef" \
  2282. 0 \
  2283. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  2284. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  2285. -s "(initial handshake) Use of Connection ID has been negotiated" \
  2286. -c "(initial handshake) Use of Connection ID has been negotiated" \
  2287. -s "Reallocating in_buf" \
  2288. -s "Reallocating out_buf"
  2289. # Tests for Encrypt-then-MAC extension
  2290. run_test "Encrypt then MAC: default" \
  2291. "$P_SRV debug_level=3 \
  2292. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  2293. "$P_CLI debug_level=3" \
  2294. 0 \
  2295. -c "client hello, adding encrypt_then_mac extension" \
  2296. -s "found encrypt then mac extension" \
  2297. -s "server hello, adding encrypt then mac extension" \
  2298. -c "found encrypt_then_mac extension" \
  2299. -c "using encrypt then mac" \
  2300. -s "using encrypt then mac"
  2301. run_test "Encrypt then MAC: client enabled, server disabled" \
  2302. "$P_SRV debug_level=3 etm=0 \
  2303. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  2304. "$P_CLI debug_level=3 etm=1" \
  2305. 0 \
  2306. -c "client hello, adding encrypt_then_mac extension" \
  2307. -s "found encrypt then mac extension" \
  2308. -S "server hello, adding encrypt then mac extension" \
  2309. -C "found encrypt_then_mac extension" \
  2310. -C "using encrypt then mac" \
  2311. -S "using encrypt then mac"
  2312. run_test "Encrypt then MAC: client enabled, aead cipher" \
  2313. "$P_SRV debug_level=3 etm=1 \
  2314. force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
  2315. "$P_CLI debug_level=3 etm=1" \
  2316. 0 \
  2317. -c "client hello, adding encrypt_then_mac extension" \
  2318. -s "found encrypt then mac extension" \
  2319. -S "server hello, adding encrypt then mac extension" \
  2320. -C "found encrypt_then_mac extension" \
  2321. -C "using encrypt then mac" \
  2322. -S "using encrypt then mac"
  2323. run_test "Encrypt then MAC: client enabled, stream cipher" \
  2324. "$P_SRV debug_level=3 etm=1 \
  2325. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  2326. "$P_CLI debug_level=3 etm=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  2327. 0 \
  2328. -c "client hello, adding encrypt_then_mac extension" \
  2329. -s "found encrypt then mac extension" \
  2330. -S "server hello, adding encrypt then mac extension" \
  2331. -C "found encrypt_then_mac extension" \
  2332. -C "using encrypt then mac" \
  2333. -S "using encrypt then mac"
  2334. run_test "Encrypt then MAC: client disabled, server enabled" \
  2335. "$P_SRV debug_level=3 etm=1 \
  2336. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  2337. "$P_CLI debug_level=3 etm=0" \
  2338. 0 \
  2339. -C "client hello, adding encrypt_then_mac extension" \
  2340. -S "found encrypt then mac extension" \
  2341. -S "server hello, adding encrypt then mac extension" \
  2342. -C "found encrypt_then_mac extension" \
  2343. -C "using encrypt then mac" \
  2344. -S "using encrypt then mac"
  2345. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  2346. run_test "Encrypt then MAC: client SSLv3, server enabled" \
  2347. "$P_SRV debug_level=3 min_version=ssl3 \
  2348. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  2349. "$P_CLI debug_level=3 force_version=ssl3" \
  2350. 0 \
  2351. -C "client hello, adding encrypt_then_mac extension" \
  2352. -S "found encrypt then mac extension" \
  2353. -S "server hello, adding encrypt then mac extension" \
  2354. -C "found encrypt_then_mac extension" \
  2355. -C "using encrypt then mac" \
  2356. -S "using encrypt then mac"
  2357. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  2358. run_test "Encrypt then MAC: client enabled, server SSLv3" \
  2359. "$P_SRV debug_level=3 force_version=ssl3 \
  2360. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  2361. "$P_CLI debug_level=3 min_version=ssl3" \
  2362. 0 \
  2363. -c "client hello, adding encrypt_then_mac extension" \
  2364. -S "found encrypt then mac extension" \
  2365. -S "server hello, adding encrypt then mac extension" \
  2366. -C "found encrypt_then_mac extension" \
  2367. -C "using encrypt then mac" \
  2368. -S "using encrypt then mac"
  2369. # Tests for Extended Master Secret extension
  2370. run_test "Extended Master Secret: default" \
  2371. "$P_SRV debug_level=3" \
  2372. "$P_CLI debug_level=3" \
  2373. 0 \
  2374. -c "client hello, adding extended_master_secret extension" \
  2375. -s "found extended master secret extension" \
  2376. -s "server hello, adding extended master secret extension" \
  2377. -c "found extended_master_secret extension" \
  2378. -c "session hash for extended master secret" \
  2379. -s "session hash for extended master secret"
  2380. run_test "Extended Master Secret: client enabled, server disabled" \
  2381. "$P_SRV debug_level=3 extended_ms=0" \
  2382. "$P_CLI debug_level=3 extended_ms=1" \
  2383. 0 \
  2384. -c "client hello, adding extended_master_secret extension" \
  2385. -s "found extended master secret extension" \
  2386. -S "server hello, adding extended master secret extension" \
  2387. -C "found extended_master_secret extension" \
  2388. -C "session hash for extended master secret" \
  2389. -S "session hash for extended master secret"
  2390. run_test "Extended Master Secret: client disabled, server enabled" \
  2391. "$P_SRV debug_level=3 extended_ms=1" \
  2392. "$P_CLI debug_level=3 extended_ms=0" \
  2393. 0 \
  2394. -C "client hello, adding extended_master_secret extension" \
  2395. -S "found extended master secret extension" \
  2396. -S "server hello, adding extended master secret extension" \
  2397. -C "found extended_master_secret extension" \
  2398. -C "session hash for extended master secret" \
  2399. -S "session hash for extended master secret"
  2400. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  2401. run_test "Extended Master Secret: client SSLv3, server enabled" \
  2402. "$P_SRV debug_level=3 min_version=ssl3" \
  2403. "$P_CLI debug_level=3 force_version=ssl3" \
  2404. 0 \
  2405. -C "client hello, adding extended_master_secret extension" \
  2406. -S "found extended master secret extension" \
  2407. -S "server hello, adding extended master secret extension" \
  2408. -C "found extended_master_secret extension" \
  2409. -C "session hash for extended master secret" \
  2410. -S "session hash for extended master secret"
  2411. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  2412. run_test "Extended Master Secret: client enabled, server SSLv3" \
  2413. "$P_SRV debug_level=3 force_version=ssl3" \
  2414. "$P_CLI debug_level=3 min_version=ssl3" \
  2415. 0 \
  2416. -c "client hello, adding extended_master_secret extension" \
  2417. -S "found extended master secret extension" \
  2418. -S "server hello, adding extended master secret extension" \
  2419. -C "found extended_master_secret extension" \
  2420. -C "session hash for extended master secret" \
  2421. -S "session hash for extended master secret"
  2422. # Tests for FALLBACK_SCSV
  2423. run_test "Fallback SCSV: default" \
  2424. "$P_SRV debug_level=2" \
  2425. "$P_CLI debug_level=3 force_version=tls1_1" \
  2426. 0 \
  2427. -C "adding FALLBACK_SCSV" \
  2428. -S "received FALLBACK_SCSV" \
  2429. -S "inapropriate fallback" \
  2430. -C "is a fatal alert message (msg 86)"
  2431. run_test "Fallback SCSV: explicitly disabled" \
  2432. "$P_SRV debug_level=2" \
  2433. "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
  2434. 0 \
  2435. -C "adding FALLBACK_SCSV" \
  2436. -S "received FALLBACK_SCSV" \
  2437. -S "inapropriate fallback" \
  2438. -C "is a fatal alert message (msg 86)"
  2439. run_test "Fallback SCSV: enabled" \
  2440. "$P_SRV debug_level=2" \
  2441. "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
  2442. 1 \
  2443. -c "adding FALLBACK_SCSV" \
  2444. -s "received FALLBACK_SCSV" \
  2445. -s "inapropriate fallback" \
  2446. -c "is a fatal alert message (msg 86)"
  2447. run_test "Fallback SCSV: enabled, max version" \
  2448. "$P_SRV debug_level=2" \
  2449. "$P_CLI debug_level=3 fallback=1" \
  2450. 0 \
  2451. -c "adding FALLBACK_SCSV" \
  2452. -s "received FALLBACK_SCSV" \
  2453. -S "inapropriate fallback" \
  2454. -C "is a fatal alert message (msg 86)"
  2455. requires_openssl_with_fallback_scsv
  2456. run_test "Fallback SCSV: default, openssl server" \
  2457. "$O_SRV" \
  2458. "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
  2459. 0 \
  2460. -C "adding FALLBACK_SCSV" \
  2461. -C "is a fatal alert message (msg 86)"
  2462. requires_openssl_with_fallback_scsv
  2463. run_test "Fallback SCSV: enabled, openssl server" \
  2464. "$O_SRV" \
  2465. "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
  2466. 1 \
  2467. -c "adding FALLBACK_SCSV" \
  2468. -c "is a fatal alert message (msg 86)"
  2469. requires_openssl_with_fallback_scsv
  2470. run_test "Fallback SCSV: disabled, openssl client" \
  2471. "$P_SRV debug_level=2" \
  2472. "$O_CLI -tls1_1" \
  2473. 0 \
  2474. -S "received FALLBACK_SCSV" \
  2475. -S "inapropriate fallback"
  2476. requires_openssl_with_fallback_scsv
  2477. run_test "Fallback SCSV: enabled, openssl client" \
  2478. "$P_SRV debug_level=2" \
  2479. "$O_CLI -tls1_1 -fallback_scsv" \
  2480. 1 \
  2481. -s "received FALLBACK_SCSV" \
  2482. -s "inapropriate fallback"
  2483. requires_openssl_with_fallback_scsv
  2484. run_test "Fallback SCSV: enabled, max version, openssl client" \
  2485. "$P_SRV debug_level=2" \
  2486. "$O_CLI -fallback_scsv" \
  2487. 0 \
  2488. -s "received FALLBACK_SCSV" \
  2489. -S "inapropriate fallback"
  2490. # Test sending and receiving empty application data records
  2491. run_test "Encrypt then MAC: empty application data record" \
  2492. "$P_SRV auth_mode=none debug_level=4 etm=1" \
  2493. "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
  2494. 0 \
  2495. -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
  2496. -s "dumping 'input payload after decrypt' (0 bytes)" \
  2497. -c "0 bytes written in 1 fragments"
  2498. run_test "Encrypt then MAC: disabled, empty application data record" \
  2499. "$P_SRV auth_mode=none debug_level=4 etm=0" \
  2500. "$P_CLI auth_mode=none etm=0 request_size=0" \
  2501. 0 \
  2502. -s "dumping 'input payload after decrypt' (0 bytes)" \
  2503. -c "0 bytes written in 1 fragments"
  2504. run_test "Encrypt then MAC, DTLS: empty application data record" \
  2505. "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
  2506. "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
  2507. 0 \
  2508. -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
  2509. -s "dumping 'input payload after decrypt' (0 bytes)" \
  2510. -c "0 bytes written in 1 fragments"
  2511. run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
  2512. "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
  2513. "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
  2514. 0 \
  2515. -s "dumping 'input payload after decrypt' (0 bytes)" \
  2516. -c "0 bytes written in 1 fragments"
  2517. ## ClientHello generated with
  2518. ## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
  2519. ## then manually twiddling the ciphersuite list.
  2520. ## The ClientHello content is spelled out below as a hex string as
  2521. ## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
  2522. ## The expected response is an inappropriate_fallback alert.
  2523. requires_openssl_with_fallback_scsv
  2524. run_test "Fallback SCSV: beginning of list" \
  2525. "$P_SRV debug_level=2" \
  2526. "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
  2527. 0 \
  2528. -s "received FALLBACK_SCSV" \
  2529. -s "inapropriate fallback"
  2530. requires_openssl_with_fallback_scsv
  2531. run_test "Fallback SCSV: end of list" \
  2532. "$P_SRV debug_level=2" \
  2533. "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
  2534. 0 \
  2535. -s "received FALLBACK_SCSV" \
  2536. -s "inapropriate fallback"
  2537. ## Here the expected response is a valid ServerHello prefix, up to the random.
  2538. requires_openssl_with_fallback_scsv
  2539. run_test "Fallback SCSV: not in list" \
  2540. "$P_SRV debug_level=2" \
  2541. "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
  2542. 0 \
  2543. -S "received FALLBACK_SCSV" \
  2544. -S "inapropriate fallback"
  2545. # Tests for CBC 1/n-1 record splitting
  2546. run_test "CBC Record splitting: TLS 1.2, no splitting" \
  2547. "$P_SRV" \
  2548. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
  2549. request_size=123 force_version=tls12" \
  2550. 0 \
  2551. -s "Read from client: 123 bytes read" \
  2552. -S "Read from client: 1 bytes read" \
  2553. -S "122 bytes read"
  2554. run_test "CBC Record splitting: TLS 1.1, no splitting" \
  2555. "$P_SRV" \
  2556. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
  2557. request_size=123 force_version=tls1_1" \
  2558. 0 \
  2559. -s "Read from client: 123 bytes read" \
  2560. -S "Read from client: 1 bytes read" \
  2561. -S "122 bytes read"
  2562. run_test "CBC Record splitting: TLS 1.0, splitting" \
  2563. "$P_SRV" \
  2564. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
  2565. request_size=123 force_version=tls1" \
  2566. 0 \
  2567. -S "Read from client: 123 bytes read" \
  2568. -s "Read from client: 1 bytes read" \
  2569. -s "122 bytes read"
  2570. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  2571. run_test "CBC Record splitting: SSLv3, splitting" \
  2572. "$P_SRV min_version=ssl3" \
  2573. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
  2574. request_size=123 force_version=ssl3" \
  2575. 0 \
  2576. -S "Read from client: 123 bytes read" \
  2577. -s "Read from client: 1 bytes read" \
  2578. -s "122 bytes read"
  2579. run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
  2580. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  2581. "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
  2582. request_size=123 force_version=tls1" \
  2583. 0 \
  2584. -s "Read from client: 123 bytes read" \
  2585. -S "Read from client: 1 bytes read" \
  2586. -S "122 bytes read"
  2587. run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
  2588. "$P_SRV" \
  2589. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
  2590. request_size=123 force_version=tls1 recsplit=0" \
  2591. 0 \
  2592. -s "Read from client: 123 bytes read" \
  2593. -S "Read from client: 1 bytes read" \
  2594. -S "122 bytes read"
  2595. run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
  2596. "$P_SRV nbio=2" \
  2597. "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
  2598. request_size=123 force_version=tls1" \
  2599. 0 \
  2600. -S "Read from client: 123 bytes read" \
  2601. -s "Read from client: 1 bytes read" \
  2602. -s "122 bytes read"
  2603. # Tests for Session Tickets
  2604. run_test "Session resume using tickets: basic" \
  2605. "$P_SRV debug_level=3 tickets=1" \
  2606. "$P_CLI debug_level=3 tickets=1 reconnect=1" \
  2607. 0 \
  2608. -c "client hello, adding session ticket extension" \
  2609. -s "found session ticket extension" \
  2610. -s "server hello, adding session ticket extension" \
  2611. -c "found session_ticket extension" \
  2612. -c "parse new session ticket" \
  2613. -S "session successfully restored from cache" \
  2614. -s "session successfully restored from ticket" \
  2615. -s "a session has been resumed" \
  2616. -c "a session has been resumed"
  2617. run_test "Session resume using tickets: cache disabled" \
  2618. "$P_SRV debug_level=3 tickets=1 cache_max=0" \
  2619. "$P_CLI debug_level=3 tickets=1 reconnect=1" \
  2620. 0 \
  2621. -c "client hello, adding session ticket extension" \
  2622. -s "found session ticket extension" \
  2623. -s "server hello, adding session ticket extension" \
  2624. -c "found session_ticket extension" \
  2625. -c "parse new session ticket" \
  2626. -S "session successfully restored from cache" \
  2627. -s "session successfully restored from ticket" \
  2628. -s "a session has been resumed" \
  2629. -c "a session has been resumed"
  2630. run_test "Session resume using tickets: timeout" \
  2631. "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
  2632. "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
  2633. 0 \
  2634. -c "client hello, adding session ticket extension" \
  2635. -s "found session ticket extension" \
  2636. -s "server hello, adding session ticket extension" \
  2637. -c "found session_ticket extension" \
  2638. -c "parse new session ticket" \
  2639. -S "session successfully restored from cache" \
  2640. -S "session successfully restored from ticket" \
  2641. -S "a session has been resumed" \
  2642. -C "a session has been resumed"
  2643. run_test "Session resume using tickets: session copy" \
  2644. "$P_SRV debug_level=3 tickets=1 cache_max=0" \
  2645. "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_mode=0" \
  2646. 0 \
  2647. -c "client hello, adding session ticket extension" \
  2648. -s "found session ticket extension" \
  2649. -s "server hello, adding session ticket extension" \
  2650. -c "found session_ticket extension" \
  2651. -c "parse new session ticket" \
  2652. -S "session successfully restored from cache" \
  2653. -s "session successfully restored from ticket" \
  2654. -s "a session has been resumed" \
  2655. -c "a session has been resumed"
  2656. run_test "Session resume using tickets: openssl server" \
  2657. "$O_SRV" \
  2658. "$P_CLI debug_level=3 tickets=1 reconnect=1" \
  2659. 0 \
  2660. -c "client hello, adding session ticket extension" \
  2661. -c "found session_ticket extension" \
  2662. -c "parse new session ticket" \
  2663. -c "a session has been resumed"
  2664. run_test "Session resume using tickets: openssl client" \
  2665. "$P_SRV debug_level=3 tickets=1" \
  2666. "( $O_CLI -sess_out $SESSION; \
  2667. $O_CLI -sess_in $SESSION; \
  2668. rm -f $SESSION )" \
  2669. 0 \
  2670. -s "found session ticket extension" \
  2671. -s "server hello, adding session ticket extension" \
  2672. -S "session successfully restored from cache" \
  2673. -s "session successfully restored from ticket" \
  2674. -s "a session has been resumed"
  2675. # Tests for Session Tickets with DTLS
  2676. run_test "Session resume using tickets, DTLS: basic" \
  2677. "$P_SRV debug_level=3 dtls=1 tickets=1" \
  2678. "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
  2679. 0 \
  2680. -c "client hello, adding session ticket extension" \
  2681. -s "found session ticket extension" \
  2682. -s "server hello, adding session ticket extension" \
  2683. -c "found session_ticket extension" \
  2684. -c "parse new session ticket" \
  2685. -S "session successfully restored from cache" \
  2686. -s "session successfully restored from ticket" \
  2687. -s "a session has been resumed" \
  2688. -c "a session has been resumed"
  2689. run_test "Session resume using tickets, DTLS: cache disabled" \
  2690. "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
  2691. "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
  2692. 0 \
  2693. -c "client hello, adding session ticket extension" \
  2694. -s "found session ticket extension" \
  2695. -s "server hello, adding session ticket extension" \
  2696. -c "found session_ticket extension" \
  2697. -c "parse new session ticket" \
  2698. -S "session successfully restored from cache" \
  2699. -s "session successfully restored from ticket" \
  2700. -s "a session has been resumed" \
  2701. -c "a session has been resumed"
  2702. run_test "Session resume using tickets, DTLS: timeout" \
  2703. "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
  2704. "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1 reco_delay=2" \
  2705. 0 \
  2706. -c "client hello, adding session ticket extension" \
  2707. -s "found session ticket extension" \
  2708. -s "server hello, adding session ticket extension" \
  2709. -c "found session_ticket extension" \
  2710. -c "parse new session ticket" \
  2711. -S "session successfully restored from cache" \
  2712. -S "session successfully restored from ticket" \
  2713. -S "a session has been resumed" \
  2714. -C "a session has been resumed"
  2715. run_test "Session resume using tickets, DTLS: session copy" \
  2716. "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
  2717. "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1 reco_mode=0" \
  2718. 0 \
  2719. -c "client hello, adding session ticket extension" \
  2720. -s "found session ticket extension" \
  2721. -s "server hello, adding session ticket extension" \
  2722. -c "found session_ticket extension" \
  2723. -c "parse new session ticket" \
  2724. -S "session successfully restored from cache" \
  2725. -s "session successfully restored from ticket" \
  2726. -s "a session has been resumed" \
  2727. -c "a session has been resumed"
  2728. run_test "Session resume using tickets, DTLS: openssl server" \
  2729. "$O_SRV -dtls1" \
  2730. "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
  2731. 0 \
  2732. -c "client hello, adding session ticket extension" \
  2733. -c "found session_ticket extension" \
  2734. -c "parse new session ticket" \
  2735. -c "a session has been resumed"
  2736. # For reasons that aren't fully understood, this test randomly fails with high
  2737. # probability with OpenSSL 1.0.2g on the CI, see #5012.
  2738. requires_openssl_next
  2739. run_test "Session resume using tickets, DTLS: openssl client" \
  2740. "$P_SRV dtls=1 debug_level=3 tickets=1" \
  2741. "( $O_NEXT_CLI -dtls1 -sess_out $SESSION; \
  2742. $O_NEXT_CLI -dtls1 -sess_in $SESSION; \
  2743. rm -f $SESSION )" \
  2744. 0 \
  2745. -s "found session ticket extension" \
  2746. -s "server hello, adding session ticket extension" \
  2747. -S "session successfully restored from cache" \
  2748. -s "session successfully restored from ticket" \
  2749. -s "a session has been resumed"
  2750. # Tests for Session Resume based on session-ID and cache
  2751. run_test "Session resume using cache: tickets enabled on client" \
  2752. "$P_SRV debug_level=3 tickets=0" \
  2753. "$P_CLI debug_level=3 tickets=1 reconnect=1" \
  2754. 0 \
  2755. -c "client hello, adding session ticket extension" \
  2756. -s "found session ticket extension" \
  2757. -S "server hello, adding session ticket extension" \
  2758. -C "found session_ticket extension" \
  2759. -C "parse new session ticket" \
  2760. -s "session successfully restored from cache" \
  2761. -S "session successfully restored from ticket" \
  2762. -s "a session has been resumed" \
  2763. -c "a session has been resumed"
  2764. run_test "Session resume using cache: tickets enabled on server" \
  2765. "$P_SRV debug_level=3 tickets=1" \
  2766. "$P_CLI debug_level=3 tickets=0 reconnect=1" \
  2767. 0 \
  2768. -C "client hello, adding session ticket extension" \
  2769. -S "found session ticket extension" \
  2770. -S "server hello, adding session ticket extension" \
  2771. -C "found session_ticket extension" \
  2772. -C "parse new session ticket" \
  2773. -s "session successfully restored from cache" \
  2774. -S "session successfully restored from ticket" \
  2775. -s "a session has been resumed" \
  2776. -c "a session has been resumed"
  2777. run_test "Session resume using cache: cache_max=0" \
  2778. "$P_SRV debug_level=3 tickets=0 cache_max=0" \
  2779. "$P_CLI debug_level=3 tickets=0 reconnect=1" \
  2780. 0 \
  2781. -S "session successfully restored from cache" \
  2782. -S "session successfully restored from ticket" \
  2783. -S "a session has been resumed" \
  2784. -C "a session has been resumed"
  2785. run_test "Session resume using cache: cache_max=1" \
  2786. "$P_SRV debug_level=3 tickets=0 cache_max=1" \
  2787. "$P_CLI debug_level=3 tickets=0 reconnect=1" \
  2788. 0 \
  2789. -s "session successfully restored from cache" \
  2790. -S "session successfully restored from ticket" \
  2791. -s "a session has been resumed" \
  2792. -c "a session has been resumed"
  2793. run_test "Session resume using cache: timeout > delay" \
  2794. "$P_SRV debug_level=3 tickets=0" \
  2795. "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
  2796. 0 \
  2797. -s "session successfully restored from cache" \
  2798. -S "session successfully restored from ticket" \
  2799. -s "a session has been resumed" \
  2800. -c "a session has been resumed"
  2801. run_test "Session resume using cache: timeout < delay" \
  2802. "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
  2803. "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
  2804. 0 \
  2805. -S "session successfully restored from cache" \
  2806. -S "session successfully restored from ticket" \
  2807. -S "a session has been resumed" \
  2808. -C "a session has been resumed"
  2809. run_test "Session resume using cache: no timeout" \
  2810. "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
  2811. "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
  2812. 0 \
  2813. -s "session successfully restored from cache" \
  2814. -S "session successfully restored from ticket" \
  2815. -s "a session has been resumed" \
  2816. -c "a session has been resumed"
  2817. run_test "Session resume using cache: session copy" \
  2818. "$P_SRV debug_level=3 tickets=0" \
  2819. "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
  2820. 0 \
  2821. -s "session successfully restored from cache" \
  2822. -S "session successfully restored from ticket" \
  2823. -s "a session has been resumed" \
  2824. -c "a session has been resumed"
  2825. run_test "Session resume using cache: openssl client" \
  2826. "$P_SRV debug_level=3 tickets=0" \
  2827. "( $O_CLI -sess_out $SESSION; \
  2828. $O_CLI -sess_in $SESSION; \
  2829. rm -f $SESSION )" \
  2830. 0 \
  2831. -s "found session ticket extension" \
  2832. -S "server hello, adding session ticket extension" \
  2833. -s "session successfully restored from cache" \
  2834. -S "session successfully restored from ticket" \
  2835. -s "a session has been resumed"
  2836. run_test "Session resume using cache: openssl server" \
  2837. "$O_SRV" \
  2838. "$P_CLI debug_level=3 tickets=0 reconnect=1" \
  2839. 0 \
  2840. -C "found session_ticket extension" \
  2841. -C "parse new session ticket" \
  2842. -c "a session has been resumed"
  2843. # Tests for Session Resume based on session-ID and cache, DTLS
  2844. run_test "Session resume using cache, DTLS: tickets enabled on client" \
  2845. "$P_SRV dtls=1 debug_level=3 tickets=0" \
  2846. "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
  2847. 0 \
  2848. -c "client hello, adding session ticket extension" \
  2849. -s "found session ticket extension" \
  2850. -S "server hello, adding session ticket extension" \
  2851. -C "found session_ticket extension" \
  2852. -C "parse new session ticket" \
  2853. -s "session successfully restored from cache" \
  2854. -S "session successfully restored from ticket" \
  2855. -s "a session has been resumed" \
  2856. -c "a session has been resumed"
  2857. run_test "Session resume using cache, DTLS: tickets enabled on server" \
  2858. "$P_SRV dtls=1 debug_level=3 tickets=1" \
  2859. "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
  2860. 0 \
  2861. -C "client hello, adding session ticket extension" \
  2862. -S "found session ticket extension" \
  2863. -S "server hello, adding session ticket extension" \
  2864. -C "found session_ticket extension" \
  2865. -C "parse new session ticket" \
  2866. -s "session successfully restored from cache" \
  2867. -S "session successfully restored from ticket" \
  2868. -s "a session has been resumed" \
  2869. -c "a session has been resumed"
  2870. run_test "Session resume using cache, DTLS: cache_max=0" \
  2871. "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
  2872. "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
  2873. 0 \
  2874. -S "session successfully restored from cache" \
  2875. -S "session successfully restored from ticket" \
  2876. -S "a session has been resumed" \
  2877. -C "a session has been resumed"
  2878. run_test "Session resume using cache, DTLS: cache_max=1" \
  2879. "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
  2880. "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
  2881. 0 \
  2882. -s "session successfully restored from cache" \
  2883. -S "session successfully restored from ticket" \
  2884. -s "a session has been resumed" \
  2885. -c "a session has been resumed"
  2886. run_test "Session resume using cache, DTLS: timeout > delay" \
  2887. "$P_SRV dtls=1 debug_level=3 tickets=0" \
  2888. "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=0" \
  2889. 0 \
  2890. -s "session successfully restored from cache" \
  2891. -S "session successfully restored from ticket" \
  2892. -s "a session has been resumed" \
  2893. -c "a session has been resumed"
  2894. run_test "Session resume using cache, DTLS: timeout < delay" \
  2895. "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
  2896. "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=2" \
  2897. 0 \
  2898. -S "session successfully restored from cache" \
  2899. -S "session successfully restored from ticket" \
  2900. -S "a session has been resumed" \
  2901. -C "a session has been resumed"
  2902. run_test "Session resume using cache, DTLS: no timeout" \
  2903. "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
  2904. "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=2" \
  2905. 0 \
  2906. -s "session successfully restored from cache" \
  2907. -S "session successfully restored from ticket" \
  2908. -s "a session has been resumed" \
  2909. -c "a session has been resumed"
  2910. run_test "Session resume using cache, DTLS: session copy" \
  2911. "$P_SRV dtls=1 debug_level=3 tickets=0" \
  2912. "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_mode=0" \
  2913. 0 \
  2914. -s "session successfully restored from cache" \
  2915. -S "session successfully restored from ticket" \
  2916. -s "a session has been resumed" \
  2917. -c "a session has been resumed"
  2918. # For reasons that aren't fully understood, this test randomly fails with high
  2919. # probability with OpenSSL 1.0.2g on the CI, see #5012.
  2920. requires_openssl_next
  2921. run_test "Session resume using cache, DTLS: openssl client" \
  2922. "$P_SRV dtls=1 debug_level=3 tickets=0" \
  2923. "( $O_NEXT_CLI -dtls1 -sess_out $SESSION; \
  2924. $O_NEXT_CLI -dtls1 -sess_in $SESSION; \
  2925. rm -f $SESSION )" \
  2926. 0 \
  2927. -s "found session ticket extension" \
  2928. -S "server hello, adding session ticket extension" \
  2929. -s "session successfully restored from cache" \
  2930. -S "session successfully restored from ticket" \
  2931. -s "a session has been resumed"
  2932. run_test "Session resume using cache, DTLS: openssl server" \
  2933. "$O_SRV -dtls1" \
  2934. "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
  2935. 0 \
  2936. -C "found session_ticket extension" \
  2937. -C "parse new session ticket" \
  2938. -c "a session has been resumed"
  2939. # Tests for Max Fragment Length extension
  2940. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2941. run_test "Max fragment length: enabled, default" \
  2942. "$P_SRV debug_level=3" \
  2943. "$P_CLI debug_level=3" \
  2944. 0 \
  2945. -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
  2946. -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
  2947. -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
  2948. -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
  2949. -C "client hello, adding max_fragment_length extension" \
  2950. -S "found max fragment length extension" \
  2951. -S "server hello, max_fragment_length extension" \
  2952. -C "found max_fragment_length extension"
  2953. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2954. run_test "Max fragment length: enabled, default, larger message" \
  2955. "$P_SRV debug_level=3" \
  2956. "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
  2957. 0 \
  2958. -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
  2959. -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
  2960. -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
  2961. -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
  2962. -C "client hello, adding max_fragment_length extension" \
  2963. -S "found max fragment length extension" \
  2964. -S "server hello, max_fragment_length extension" \
  2965. -C "found max_fragment_length extension" \
  2966. -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
  2967. -s "$MAX_CONTENT_LEN bytes read" \
  2968. -s "1 bytes read"
  2969. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2970. run_test "Max fragment length, DTLS: enabled, default, larger message" \
  2971. "$P_SRV debug_level=3 dtls=1" \
  2972. "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
  2973. 1 \
  2974. -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
  2975. -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
  2976. -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
  2977. -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
  2978. -C "client hello, adding max_fragment_length extension" \
  2979. -S "found max fragment length extension" \
  2980. -S "server hello, max_fragment_length extension" \
  2981. -C "found max_fragment_length extension" \
  2982. -c "fragment larger than.*maximum "
  2983. # Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
  2984. # (session fragment length will be 16384 regardless of mbedtls
  2985. # content length configuration.)
  2986. requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2987. run_test "Max fragment length: disabled, larger message" \
  2988. "$P_SRV debug_level=3" \
  2989. "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
  2990. 0 \
  2991. -C "Maximum input fragment length is 16384" \
  2992. -C "Maximum output fragment length is 16384" \
  2993. -S "Maximum input fragment length is 16384" \
  2994. -S "Maximum output fragment length is 16384" \
  2995. -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
  2996. -s "$MAX_CONTENT_LEN bytes read" \
  2997. -s "1 bytes read"
  2998. requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2999. run_test "Max fragment length, DTLS: disabled, larger message" \
  3000. "$P_SRV debug_level=3 dtls=1" \
  3001. "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
  3002. 1 \
  3003. -C "Maximum input fragment length is 16384" \
  3004. -C "Maximum output fragment length is 16384" \
  3005. -S "Maximum input fragment length is 16384" \
  3006. -S "Maximum output fragment length is 16384" \
  3007. -c "fragment larger than.*maximum "
  3008. requires_max_content_len 4096
  3009. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  3010. run_test "Max fragment length: used by client" \
  3011. "$P_SRV debug_level=3" \
  3012. "$P_CLI debug_level=3 max_frag_len=4096" \
  3013. 0 \
  3014. -c "Maximum input fragment length is 4096" \
  3015. -c "Maximum output fragment length is 4096" \
  3016. -s "Maximum input fragment length is 4096" \
  3017. -s "Maximum output fragment length is 4096" \
  3018. -c "client hello, adding max_fragment_length extension" \
  3019. -s "found max fragment length extension" \
  3020. -s "server hello, max_fragment_length extension" \
  3021. -c "found max_fragment_length extension"
  3022. requires_max_content_len 1024
  3023. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  3024. run_test "Max fragment length: client 512, server 1024" \
  3025. "$P_SRV debug_level=3 max_frag_len=1024" \
  3026. "$P_CLI debug_level=3 max_frag_len=512" \
  3027. 0 \
  3028. -c "Maximum input fragment length is 512" \
  3029. -c "Maximum output fragment length is 512" \
  3030. -s "Maximum input fragment length is 512" \
  3031. -s "Maximum output fragment length is 512" \
  3032. -c "client hello, adding max_fragment_length extension" \
  3033. -s "found max fragment length extension" \
  3034. -s "server hello, max_fragment_length extension" \
  3035. -c "found max_fragment_length extension"
  3036. requires_max_content_len 2048
  3037. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  3038. run_test "Max fragment length: client 512, server 2048" \
  3039. "$P_SRV debug_level=3 max_frag_len=2048" \
  3040. "$P_CLI debug_level=3 max_frag_len=512" \
  3041. 0 \
  3042. -c "Maximum input fragment length is 512" \
  3043. -c "Maximum output fragment length is 512" \
  3044. -s "Maximum input fragment length is 512" \
  3045. -s "Maximum output fragment length is 512" \
  3046. -c "client hello, adding max_fragment_length extension" \
  3047. -s "found max fragment length extension" \
  3048. -s "server hello, max_fragment_length extension" \
  3049. -c "found max_fragment_length extension"
  3050. requires_max_content_len 4096
  3051. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  3052. run_test "Max fragment length: client 512, server 4096" \
  3053. "$P_SRV debug_level=3 max_frag_len=4096" \
  3054. "$P_CLI debug_level=3 max_frag_len=512" \
  3055. 0 \
  3056. -c "Maximum input fragment length is 512" \
  3057. -c "Maximum output fragment length is 512" \
  3058. -s "Maximum input fragment length is 512" \
  3059. -s "Maximum output fragment length is 512" \
  3060. -c "client hello, adding max_fragment_length extension" \
  3061. -s "found max fragment length extension" \
  3062. -s "server hello, max_fragment_length extension" \
  3063. -c "found max_fragment_length extension"
  3064. requires_max_content_len 1024
  3065. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  3066. run_test "Max fragment length: client 1024, server 512" \
  3067. "$P_SRV debug_level=3 max_frag_len=512" \
  3068. "$P_CLI debug_level=3 max_frag_len=1024" \
  3069. 0 \
  3070. -c "Maximum input fragment length is 1024" \
  3071. -c "Maximum output fragment length is 1024" \
  3072. -s "Maximum input fragment length is 1024" \
  3073. -s "Maximum output fragment length is 512" \
  3074. -c "client hello, adding max_fragment_length extension" \
  3075. -s "found max fragment length extension" \
  3076. -s "server hello, max_fragment_length extension" \
  3077. -c "found max_fragment_length extension"
  3078. requires_max_content_len 2048
  3079. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  3080. run_test "Max fragment length: client 1024, server 2048" \
  3081. "$P_SRV debug_level=3 max_frag_len=2048" \
  3082. "$P_CLI debug_level=3 max_frag_len=1024" \
  3083. 0 \
  3084. -c "Maximum input fragment length is 1024" \
  3085. -c "Maximum output fragment length is 1024" \
  3086. -s "Maximum input fragment length is 1024" \
  3087. -s "Maximum output fragment length is 1024" \
  3088. -c "client hello, adding max_fragment_length extension" \
  3089. -s "found max fragment length extension" \
  3090. -s "server hello, max_fragment_length extension" \
  3091. -c "found max_fragment_length extension"
  3092. requires_max_content_len 4096
  3093. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  3094. run_test "Max fragment length: client 1024, server 4096" \
  3095. "$P_SRV debug_level=3 max_frag_len=4096" \
  3096. "$P_CLI debug_level=3 max_frag_len=1024" \
  3097. 0 \
  3098. -c "Maximum input fragment length is 1024" \
  3099. -c "Maximum output fragment length is 1024" \
  3100. -s "Maximum input fragment length is 1024" \
  3101. -s "Maximum output fragment length is 1024" \
  3102. -c "client hello, adding max_fragment_length extension" \
  3103. -s "found max fragment length extension" \
  3104. -s "server hello, max_fragment_length extension" \
  3105. -c "found max_fragment_length extension"
  3106. requires_max_content_len 2048
  3107. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  3108. run_test "Max fragment length: client 2048, server 512" \
  3109. "$P_SRV debug_level=3 max_frag_len=512" \
  3110. "$P_CLI debug_level=3 max_frag_len=2048" \
  3111. 0 \
  3112. -c "Maximum input fragment length is 2048" \
  3113. -c "Maximum output fragment length is 2048" \
  3114. -s "Maximum input fragment length is 2048" \
  3115. -s "Maximum output fragment length is 512" \
  3116. -c "client hello, adding max_fragment_length extension" \
  3117. -s "found max fragment length extension" \
  3118. -s "server hello, max_fragment_length extension" \
  3119. -c "found max_fragment_length extension"
  3120. requires_max_content_len 2048
  3121. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  3122. run_test "Max fragment length: client 2048, server 1024" \
  3123. "$P_SRV debug_level=3 max_frag_len=1024" \
  3124. "$P_CLI debug_level=3 max_frag_len=2048" \
  3125. 0 \
  3126. -c "Maximum input fragment length is 2048" \
  3127. -c "Maximum output fragment length is 2048" \
  3128. -s "Maximum input fragment length is 2048" \
  3129. -s "Maximum output fragment length is 1024" \
  3130. -c "client hello, adding max_fragment_length extension" \
  3131. -s "found max fragment length extension" \
  3132. -s "server hello, max_fragment_length extension" \
  3133. -c "found max_fragment_length extension"
  3134. requires_max_content_len 4096
  3135. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  3136. run_test "Max fragment length: client 2048, server 4096" \
  3137. "$P_SRV debug_level=3 max_frag_len=4096" \
  3138. "$P_CLI debug_level=3 max_frag_len=2048" \
  3139. 0 \
  3140. -c "Maximum input fragment length is 2048" \
  3141. -c "Maximum output fragment length is 2048" \
  3142. -s "Maximum input fragment length is 2048" \
  3143. -s "Maximum output fragment length is 2048" \
  3144. -c "client hello, adding max_fragment_length extension" \
  3145. -s "found max fragment length extension" \
  3146. -s "server hello, max_fragment_length extension" \
  3147. -c "found max_fragment_length extension"
  3148. requires_max_content_len 4096
  3149. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  3150. run_test "Max fragment length: client 4096, server 512" \
  3151. "$P_SRV debug_level=3 max_frag_len=512" \
  3152. "$P_CLI debug_level=3 max_frag_len=4096" \
  3153. 0 \
  3154. -c "Maximum input fragment length is 4096" \
  3155. -c "Maximum output fragment length is 4096" \
  3156. -s "Maximum input fragment length is 4096" \
  3157. -s "Maximum output fragment length is 512" \
  3158. -c "client hello, adding max_fragment_length extension" \
  3159. -s "found max fragment length extension" \
  3160. -s "server hello, max_fragment_length extension" \
  3161. -c "found max_fragment_length extension"
  3162. requires_max_content_len 4096
  3163. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  3164. run_test "Max fragment length: client 4096, server 1024" \
  3165. "$P_SRV debug_level=3 max_frag_len=1024" \
  3166. "$P_CLI debug_level=3 max_frag_len=4096" \
  3167. 0 \
  3168. -c "Maximum input fragment length is 4096" \
  3169. -c "Maximum output fragment length is 4096" \
  3170. -s "Maximum input fragment length is 4096" \
  3171. -s "Maximum output fragment length is 1024" \
  3172. -c "client hello, adding max_fragment_length extension" \
  3173. -s "found max fragment length extension" \
  3174. -s "server hello, max_fragment_length extension" \
  3175. -c "found max_fragment_length extension"
  3176. requires_max_content_len 4096
  3177. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  3178. run_test "Max fragment length: client 4096, server 2048" \
  3179. "$P_SRV debug_level=3 max_frag_len=2048" \
  3180. "$P_CLI debug_level=3 max_frag_len=4096" \
  3181. 0 \
  3182. -c "Maximum input fragment length is 4096" \
  3183. -c "Maximum output fragment length is 4096" \
  3184. -s "Maximum input fragment length is 4096" \
  3185. -s "Maximum output fragment length is 2048" \
  3186. -c "client hello, adding max_fragment_length extension" \
  3187. -s "found max fragment length extension" \
  3188. -s "server hello, max_fragment_length extension" \
  3189. -c "found max_fragment_length extension"
  3190. requires_max_content_len 4096
  3191. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  3192. run_test "Max fragment length: used by server" \
  3193. "$P_SRV debug_level=3 max_frag_len=4096" \
  3194. "$P_CLI debug_level=3" \
  3195. 0 \
  3196. -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
  3197. -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
  3198. -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
  3199. -s "Maximum output fragment length is 4096" \
  3200. -C "client hello, adding max_fragment_length extension" \
  3201. -S "found max fragment length extension" \
  3202. -S "server hello, max_fragment_length extension" \
  3203. -C "found max_fragment_length extension"
  3204. requires_max_content_len 4096
  3205. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  3206. requires_gnutls
  3207. run_test "Max fragment length: gnutls server" \
  3208. "$G_SRV" \
  3209. "$P_CLI debug_level=3 max_frag_len=4096" \
  3210. 0 \
  3211. -c "Maximum input fragment length is 4096" \
  3212. -c "Maximum output fragment length is 4096" \
  3213. -c "client hello, adding max_fragment_length extension" \
  3214. -c "found max_fragment_length extension"
  3215. requires_max_content_len 2048
  3216. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  3217. run_test "Max fragment length: client, message just fits" \
  3218. "$P_SRV debug_level=3" \
  3219. "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
  3220. 0 \
  3221. -c "Maximum input fragment length is 2048" \
  3222. -c "Maximum output fragment length is 2048" \
  3223. -s "Maximum input fragment length is 2048" \
  3224. -s "Maximum output fragment length is 2048" \
  3225. -c "client hello, adding max_fragment_length extension" \
  3226. -s "found max fragment length extension" \
  3227. -s "server hello, max_fragment_length extension" \
  3228. -c "found max_fragment_length extension" \
  3229. -c "2048 bytes written in 1 fragments" \
  3230. -s "2048 bytes read"
  3231. requires_max_content_len 2048
  3232. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  3233. run_test "Max fragment length: client, larger message" \
  3234. "$P_SRV debug_level=3" \
  3235. "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
  3236. 0 \
  3237. -c "Maximum input fragment length is 2048" \
  3238. -c "Maximum output fragment length is 2048" \
  3239. -s "Maximum input fragment length is 2048" \
  3240. -s "Maximum output fragment length is 2048" \
  3241. -c "client hello, adding max_fragment_length extension" \
  3242. -s "found max fragment length extension" \
  3243. -s "server hello, max_fragment_length extension" \
  3244. -c "found max_fragment_length extension" \
  3245. -c "2345 bytes written in 2 fragments" \
  3246. -s "2048 bytes read" \
  3247. -s "297 bytes read"
  3248. requires_max_content_len 2048
  3249. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  3250. run_test "Max fragment length: DTLS client, larger message" \
  3251. "$P_SRV debug_level=3 dtls=1" \
  3252. "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
  3253. 1 \
  3254. -c "Maximum input fragment length is 2048" \
  3255. -c "Maximum output fragment length is 2048" \
  3256. -s "Maximum input fragment length is 2048" \
  3257. -s "Maximum output fragment length is 2048" \
  3258. -c "client hello, adding max_fragment_length extension" \
  3259. -s "found max fragment length extension" \
  3260. -s "server hello, max_fragment_length extension" \
  3261. -c "found max_fragment_length extension" \
  3262. -c "fragment larger than.*maximum"
  3263. # Tests for renegotiation
  3264. # Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
  3265. run_test "Renegotiation: none, for reference" \
  3266. "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
  3267. "$P_CLI debug_level=3 exchanges=2" \
  3268. 0 \
  3269. -C "client hello, adding renegotiation extension" \
  3270. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3271. -S "found renegotiation extension" \
  3272. -s "server hello, secure renegotiation extension" \
  3273. -c "found renegotiation extension" \
  3274. -C "=> renegotiate" \
  3275. -S "=> renegotiate" \
  3276. -S "write hello request"
  3277. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3278. run_test "Renegotiation: client-initiated" \
  3279. "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
  3280. "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
  3281. 0 \
  3282. -c "client hello, adding renegotiation extension" \
  3283. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3284. -s "found renegotiation extension" \
  3285. -s "server hello, secure renegotiation extension" \
  3286. -c "found renegotiation extension" \
  3287. -c "=> renegotiate" \
  3288. -s "=> renegotiate" \
  3289. -S "write hello request"
  3290. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3291. run_test "Renegotiation: server-initiated" \
  3292. "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
  3293. "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
  3294. 0 \
  3295. -c "client hello, adding renegotiation extension" \
  3296. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3297. -s "found renegotiation extension" \
  3298. -s "server hello, secure renegotiation extension" \
  3299. -c "found renegotiation extension" \
  3300. -c "=> renegotiate" \
  3301. -s "=> renegotiate" \
  3302. -s "write hello request"
  3303. # Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
  3304. # the server did not parse the Signature Algorithm extension. This test is valid only if an MD
  3305. # algorithm stronger than SHA-1 is enabled in config.h
  3306. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3307. run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
  3308. "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
  3309. "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
  3310. 0 \
  3311. -c "client hello, adding renegotiation extension" \
  3312. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3313. -s "found renegotiation extension" \
  3314. -s "server hello, secure renegotiation extension" \
  3315. -c "found renegotiation extension" \
  3316. -c "=> renegotiate" \
  3317. -s "=> renegotiate" \
  3318. -S "write hello request" \
  3319. -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
  3320. # Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
  3321. # the server did not parse the Signature Algorithm extension. This test is valid only if an MD
  3322. # algorithm stronger than SHA-1 is enabled in config.h
  3323. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3324. run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
  3325. "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
  3326. "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
  3327. 0 \
  3328. -c "client hello, adding renegotiation extension" \
  3329. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3330. -s "found renegotiation extension" \
  3331. -s "server hello, secure renegotiation extension" \
  3332. -c "found renegotiation extension" \
  3333. -c "=> renegotiate" \
  3334. -s "=> renegotiate" \
  3335. -s "write hello request" \
  3336. -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
  3337. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3338. run_test "Renegotiation: double" \
  3339. "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
  3340. "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
  3341. 0 \
  3342. -c "client hello, adding renegotiation extension" \
  3343. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3344. -s "found renegotiation extension" \
  3345. -s "server hello, secure renegotiation extension" \
  3346. -c "found renegotiation extension" \
  3347. -c "=> renegotiate" \
  3348. -s "=> renegotiate" \
  3349. -s "write hello request"
  3350. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3351. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  3352. requires_max_content_len 2048
  3353. run_test "Renegotiation with max fragment length: client 2048, server 512" \
  3354. "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1 max_frag_len=512" \
  3355. "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 max_frag_len=2048 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
  3356. 0 \
  3357. -c "Maximum input fragment length is 2048" \
  3358. -c "Maximum output fragment length is 2048" \
  3359. -s "Maximum input fragment length is 2048" \
  3360. -s "Maximum output fragment length is 512" \
  3361. -c "client hello, adding max_fragment_length extension" \
  3362. -s "found max fragment length extension" \
  3363. -s "server hello, max_fragment_length extension" \
  3364. -c "found max_fragment_length extension" \
  3365. -c "client hello, adding renegotiation extension" \
  3366. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3367. -s "found renegotiation extension" \
  3368. -s "server hello, secure renegotiation extension" \
  3369. -c "found renegotiation extension" \
  3370. -c "=> renegotiate" \
  3371. -s "=> renegotiate" \
  3372. -s "write hello request"
  3373. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3374. run_test "Renegotiation: client-initiated, server-rejected" \
  3375. "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
  3376. "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
  3377. 1 \
  3378. -c "client hello, adding renegotiation extension" \
  3379. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3380. -S "found renegotiation extension" \
  3381. -s "server hello, secure renegotiation extension" \
  3382. -c "found renegotiation extension" \
  3383. -c "=> renegotiate" \
  3384. -S "=> renegotiate" \
  3385. -S "write hello request" \
  3386. -c "SSL - Unexpected message at ServerHello in renegotiation" \
  3387. -c "failed"
  3388. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3389. run_test "Renegotiation: server-initiated, client-rejected, default" \
  3390. "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
  3391. "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
  3392. 0 \
  3393. -C "client hello, adding renegotiation extension" \
  3394. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3395. -S "found renegotiation extension" \
  3396. -s "server hello, secure renegotiation extension" \
  3397. -c "found renegotiation extension" \
  3398. -C "=> renegotiate" \
  3399. -S "=> renegotiate" \
  3400. -s "write hello request" \
  3401. -S "SSL - An unexpected message was received from our peer" \
  3402. -S "failed"
  3403. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3404. run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
  3405. "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
  3406. renego_delay=-1 auth_mode=optional" \
  3407. "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
  3408. 0 \
  3409. -C "client hello, adding renegotiation extension" \
  3410. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3411. -S "found renegotiation extension" \
  3412. -s "server hello, secure renegotiation extension" \
  3413. -c "found renegotiation extension" \
  3414. -C "=> renegotiate" \
  3415. -S "=> renegotiate" \
  3416. -s "write hello request" \
  3417. -S "SSL - An unexpected message was received from our peer" \
  3418. -S "failed"
  3419. # delay 2 for 1 alert record + 1 application data record
  3420. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3421. run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
  3422. "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
  3423. renego_delay=2 auth_mode=optional" \
  3424. "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
  3425. 0 \
  3426. -C "client hello, adding renegotiation extension" \
  3427. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3428. -S "found renegotiation extension" \
  3429. -s "server hello, secure renegotiation extension" \
  3430. -c "found renegotiation extension" \
  3431. -C "=> renegotiate" \
  3432. -S "=> renegotiate" \
  3433. -s "write hello request" \
  3434. -S "SSL - An unexpected message was received from our peer" \
  3435. -S "failed"
  3436. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3437. run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
  3438. "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
  3439. renego_delay=0 auth_mode=optional" \
  3440. "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
  3441. 0 \
  3442. -C "client hello, adding renegotiation extension" \
  3443. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3444. -S "found renegotiation extension" \
  3445. -s "server hello, secure renegotiation extension" \
  3446. -c "found renegotiation extension" \
  3447. -C "=> renegotiate" \
  3448. -S "=> renegotiate" \
  3449. -s "write hello request" \
  3450. -s "SSL - An unexpected message was received from our peer"
  3451. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3452. run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
  3453. "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
  3454. renego_delay=0 auth_mode=optional" \
  3455. "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
  3456. 0 \
  3457. -c "client hello, adding renegotiation extension" \
  3458. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3459. -s "found renegotiation extension" \
  3460. -s "server hello, secure renegotiation extension" \
  3461. -c "found renegotiation extension" \
  3462. -c "=> renegotiate" \
  3463. -s "=> renegotiate" \
  3464. -s "write hello request" \
  3465. -S "SSL - An unexpected message was received from our peer" \
  3466. -S "failed"
  3467. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3468. run_test "Renegotiation: periodic, just below period" \
  3469. "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
  3470. "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
  3471. 0 \
  3472. -C "client hello, adding renegotiation extension" \
  3473. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3474. -S "found renegotiation extension" \
  3475. -s "server hello, secure renegotiation extension" \
  3476. -c "found renegotiation extension" \
  3477. -S "record counter limit reached: renegotiate" \
  3478. -C "=> renegotiate" \
  3479. -S "=> renegotiate" \
  3480. -S "write hello request" \
  3481. -S "SSL - An unexpected message was received from our peer" \
  3482. -S "failed"
  3483. # one extra exchange to be able to complete renego
  3484. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3485. run_test "Renegotiation: periodic, just above period" \
  3486. "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
  3487. "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
  3488. 0 \
  3489. -c "client hello, adding renegotiation extension" \
  3490. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3491. -s "found renegotiation extension" \
  3492. -s "server hello, secure renegotiation extension" \
  3493. -c "found renegotiation extension" \
  3494. -s "record counter limit reached: renegotiate" \
  3495. -c "=> renegotiate" \
  3496. -s "=> renegotiate" \
  3497. -s "write hello request" \
  3498. -S "SSL - An unexpected message was received from our peer" \
  3499. -S "failed"
  3500. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3501. run_test "Renegotiation: periodic, two times period" \
  3502. "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
  3503. "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
  3504. 0 \
  3505. -c "client hello, adding renegotiation extension" \
  3506. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3507. -s "found renegotiation extension" \
  3508. -s "server hello, secure renegotiation extension" \
  3509. -c "found renegotiation extension" \
  3510. -s "record counter limit reached: renegotiate" \
  3511. -c "=> renegotiate" \
  3512. -s "=> renegotiate" \
  3513. -s "write hello request" \
  3514. -S "SSL - An unexpected message was received from our peer" \
  3515. -S "failed"
  3516. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3517. run_test "Renegotiation: periodic, above period, disabled" \
  3518. "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
  3519. "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
  3520. 0 \
  3521. -C "client hello, adding renegotiation extension" \
  3522. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3523. -S "found renegotiation extension" \
  3524. -s "server hello, secure renegotiation extension" \
  3525. -c "found renegotiation extension" \
  3526. -S "record counter limit reached: renegotiate" \
  3527. -C "=> renegotiate" \
  3528. -S "=> renegotiate" \
  3529. -S "write hello request" \
  3530. -S "SSL - An unexpected message was received from our peer" \
  3531. -S "failed"
  3532. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3533. run_test "Renegotiation: nbio, client-initiated" \
  3534. "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
  3535. "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
  3536. 0 \
  3537. -c "client hello, adding renegotiation extension" \
  3538. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3539. -s "found renegotiation extension" \
  3540. -s "server hello, secure renegotiation extension" \
  3541. -c "found renegotiation extension" \
  3542. -c "=> renegotiate" \
  3543. -s "=> renegotiate" \
  3544. -S "write hello request"
  3545. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3546. run_test "Renegotiation: nbio, server-initiated" \
  3547. "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
  3548. "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
  3549. 0 \
  3550. -c "client hello, adding renegotiation extension" \
  3551. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3552. -s "found renegotiation extension" \
  3553. -s "server hello, secure renegotiation extension" \
  3554. -c "found renegotiation extension" \
  3555. -c "=> renegotiate" \
  3556. -s "=> renegotiate" \
  3557. -s "write hello request"
  3558. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3559. run_test "Renegotiation: openssl server, client-initiated" \
  3560. "$O_SRV -www" \
  3561. "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
  3562. 0 \
  3563. -c "client hello, adding renegotiation extension" \
  3564. -c "found renegotiation extension" \
  3565. -c "=> renegotiate" \
  3566. -C "ssl_hanshake() returned" \
  3567. -C "error" \
  3568. -c "HTTP/1.0 200 [Oo][Kk]"
  3569. requires_gnutls
  3570. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3571. run_test "Renegotiation: gnutls server strict, client-initiated" \
  3572. "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
  3573. "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
  3574. 0 \
  3575. -c "client hello, adding renegotiation extension" \
  3576. -c "found renegotiation extension" \
  3577. -c "=> renegotiate" \
  3578. -C "ssl_hanshake() returned" \
  3579. -C "error" \
  3580. -c "HTTP/1.0 200 [Oo][Kk]"
  3581. requires_gnutls
  3582. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3583. run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
  3584. "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
  3585. "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
  3586. 1 \
  3587. -c "client hello, adding renegotiation extension" \
  3588. -C "found renegotiation extension" \
  3589. -c "=> renegotiate" \
  3590. -c "mbedtls_ssl_handshake() returned" \
  3591. -c "error" \
  3592. -C "HTTP/1.0 200 [Oo][Kk]"
  3593. requires_gnutls
  3594. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3595. run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
  3596. "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
  3597. "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
  3598. allow_legacy=0" \
  3599. 1 \
  3600. -c "client hello, adding renegotiation extension" \
  3601. -C "found renegotiation extension" \
  3602. -c "=> renegotiate" \
  3603. -c "mbedtls_ssl_handshake() returned" \
  3604. -c "error" \
  3605. -C "HTTP/1.0 200 [Oo][Kk]"
  3606. requires_gnutls
  3607. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3608. run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
  3609. "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
  3610. "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
  3611. allow_legacy=1" \
  3612. 0 \
  3613. -c "client hello, adding renegotiation extension" \
  3614. -C "found renegotiation extension" \
  3615. -c "=> renegotiate" \
  3616. -C "ssl_hanshake() returned" \
  3617. -C "error" \
  3618. -c "HTTP/1.0 200 [Oo][Kk]"
  3619. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3620. run_test "Renegotiation: DTLS, client-initiated" \
  3621. "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
  3622. "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
  3623. 0 \
  3624. -c "client hello, adding renegotiation extension" \
  3625. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3626. -s "found renegotiation extension" \
  3627. -s "server hello, secure renegotiation extension" \
  3628. -c "found renegotiation extension" \
  3629. -c "=> renegotiate" \
  3630. -s "=> renegotiate" \
  3631. -S "write hello request"
  3632. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3633. run_test "Renegotiation: DTLS, server-initiated" \
  3634. "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
  3635. "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
  3636. read_timeout=1000 max_resend=2" \
  3637. 0 \
  3638. -c "client hello, adding renegotiation extension" \
  3639. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3640. -s "found renegotiation extension" \
  3641. -s "server hello, secure renegotiation extension" \
  3642. -c "found renegotiation extension" \
  3643. -c "=> renegotiate" \
  3644. -s "=> renegotiate" \
  3645. -s "write hello request"
  3646. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3647. run_test "Renegotiation: DTLS, renego_period overflow" \
  3648. "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
  3649. "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
  3650. 0 \
  3651. -c "client hello, adding renegotiation extension" \
  3652. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3653. -s "found renegotiation extension" \
  3654. -s "server hello, secure renegotiation extension" \
  3655. -s "record counter limit reached: renegotiate" \
  3656. -c "=> renegotiate" \
  3657. -s "=> renegotiate" \
  3658. -s "write hello request"
  3659. requires_gnutls
  3660. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3661. run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
  3662. "$G_SRV -u --mtu 4096" \
  3663. "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
  3664. 0 \
  3665. -c "client hello, adding renegotiation extension" \
  3666. -c "found renegotiation extension" \
  3667. -c "=> renegotiate" \
  3668. -C "mbedtls_ssl_handshake returned" \
  3669. -C "error" \
  3670. -s "Extra-header:"
  3671. # Test for the "secure renegotation" extension only (no actual renegotiation)
  3672. requires_gnutls
  3673. run_test "Renego ext: gnutls server strict, client default" \
  3674. "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
  3675. "$P_CLI debug_level=3" \
  3676. 0 \
  3677. -c "found renegotiation extension" \
  3678. -C "error" \
  3679. -c "HTTP/1.0 200 [Oo][Kk]"
  3680. requires_gnutls
  3681. run_test "Renego ext: gnutls server unsafe, client default" \
  3682. "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
  3683. "$P_CLI debug_level=3" \
  3684. 0 \
  3685. -C "found renegotiation extension" \
  3686. -C "error" \
  3687. -c "HTTP/1.0 200 [Oo][Kk]"
  3688. requires_gnutls
  3689. run_test "Renego ext: gnutls server unsafe, client break legacy" \
  3690. "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
  3691. "$P_CLI debug_level=3 allow_legacy=-1" \
  3692. 1 \
  3693. -C "found renegotiation extension" \
  3694. -c "error" \
  3695. -C "HTTP/1.0 200 [Oo][Kk]"
  3696. requires_gnutls
  3697. run_test "Renego ext: gnutls client strict, server default" \
  3698. "$P_SRV debug_level=3" \
  3699. "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
  3700. 0 \
  3701. -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
  3702. -s "server hello, secure renegotiation extension"
  3703. requires_gnutls
  3704. run_test "Renego ext: gnutls client unsafe, server default" \
  3705. "$P_SRV debug_level=3" \
  3706. "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
  3707. 0 \
  3708. -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
  3709. -S "server hello, secure renegotiation extension"
  3710. requires_gnutls
  3711. run_test "Renego ext: gnutls client unsafe, server break legacy" \
  3712. "$P_SRV debug_level=3 allow_legacy=-1" \
  3713. "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
  3714. 1 \
  3715. -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
  3716. -S "server hello, secure renegotiation extension"
  3717. # Tests for silently dropping trailing extra bytes in .der certificates
  3718. requires_gnutls
  3719. run_test "DER format: no trailing bytes" \
  3720. "$P_SRV crt_file=data_files/server5-der0.crt \
  3721. key_file=data_files/server5.key" \
  3722. "$G_CLI localhost" \
  3723. 0 \
  3724. -c "Handshake was completed" \
  3725. requires_gnutls
  3726. run_test "DER format: with a trailing zero byte" \
  3727. "$P_SRV crt_file=data_files/server5-der1a.crt \
  3728. key_file=data_files/server5.key" \
  3729. "$G_CLI localhost" \
  3730. 0 \
  3731. -c "Handshake was completed" \
  3732. requires_gnutls
  3733. run_test "DER format: with a trailing random byte" \
  3734. "$P_SRV crt_file=data_files/server5-der1b.crt \
  3735. key_file=data_files/server5.key" \
  3736. "$G_CLI localhost" \
  3737. 0 \
  3738. -c "Handshake was completed" \
  3739. requires_gnutls
  3740. run_test "DER format: with 2 trailing random bytes" \
  3741. "$P_SRV crt_file=data_files/server5-der2.crt \
  3742. key_file=data_files/server5.key" \
  3743. "$G_CLI localhost" \
  3744. 0 \
  3745. -c "Handshake was completed" \
  3746. requires_gnutls
  3747. run_test "DER format: with 4 trailing random bytes" \
  3748. "$P_SRV crt_file=data_files/server5-der4.crt \
  3749. key_file=data_files/server5.key" \
  3750. "$G_CLI localhost" \
  3751. 0 \
  3752. -c "Handshake was completed" \
  3753. requires_gnutls
  3754. run_test "DER format: with 8 trailing random bytes" \
  3755. "$P_SRV crt_file=data_files/server5-der8.crt \
  3756. key_file=data_files/server5.key" \
  3757. "$G_CLI localhost" \
  3758. 0 \
  3759. -c "Handshake was completed" \
  3760. requires_gnutls
  3761. run_test "DER format: with 9 trailing random bytes" \
  3762. "$P_SRV crt_file=data_files/server5-der9.crt \
  3763. key_file=data_files/server5.key" \
  3764. "$G_CLI localhost" \
  3765. 0 \
  3766. -c "Handshake was completed" \
  3767. # Tests for auth_mode, there are duplicated tests using ca callback for authentication
  3768. # When updating these tests, modify the matching authentication tests accordingly
  3769. run_test "Authentication: server badcert, client required" \
  3770. "$P_SRV crt_file=data_files/server5-badsign.crt \
  3771. key_file=data_files/server5.key" \
  3772. "$P_CLI debug_level=1 auth_mode=required" \
  3773. 1 \
  3774. -c "x509_verify_cert() returned" \
  3775. -c "! The certificate is not correctly signed by the trusted CA" \
  3776. -c "! mbedtls_ssl_handshake returned" \
  3777. -c "X509 - Certificate verification failed"
  3778. run_test "Authentication: server badcert, client optional" \
  3779. "$P_SRV crt_file=data_files/server5-badsign.crt \
  3780. key_file=data_files/server5.key" \
  3781. "$P_CLI debug_level=1 auth_mode=optional" \
  3782. 0 \
  3783. -c "x509_verify_cert() returned" \
  3784. -c "! The certificate is not correctly signed by the trusted CA" \
  3785. -C "! mbedtls_ssl_handshake returned" \
  3786. -C "X509 - Certificate verification failed"
  3787. run_test "Authentication: server goodcert, client optional, no trusted CA" \
  3788. "$P_SRV" \
  3789. "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
  3790. 0 \
  3791. -c "x509_verify_cert() returned" \
  3792. -c "! The certificate is not correctly signed by the trusted CA" \
  3793. -c "! Certificate verification flags"\
  3794. -C "! mbedtls_ssl_handshake returned" \
  3795. -C "X509 - Certificate verification failed" \
  3796. -C "SSL - No CA Chain is set, but required to operate"
  3797. run_test "Authentication: server goodcert, client required, no trusted CA" \
  3798. "$P_SRV" \
  3799. "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
  3800. 1 \
  3801. -c "x509_verify_cert() returned" \
  3802. -c "! The certificate is not correctly signed by the trusted CA" \
  3803. -c "! Certificate verification flags"\
  3804. -c "! mbedtls_ssl_handshake returned" \
  3805. -c "SSL - No CA Chain is set, but required to operate"
  3806. # The purpose of the next two tests is to test the client's behaviour when receiving a server
  3807. # certificate with an unsupported elliptic curve. This should usually not happen because
  3808. # the client informs the server about the supported curves - it does, though, in the
  3809. # corner case of a static ECDH suite, because the server doesn't check the curve on that
  3810. # occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
  3811. # different means to have the server ignoring the client's supported curve list.
  3812. requires_config_enabled MBEDTLS_ECP_C
  3813. run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
  3814. "$P_SRV debug_level=1 key_file=data_files/server5.key \
  3815. crt_file=data_files/server5.ku-ka.crt" \
  3816. "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
  3817. 1 \
  3818. -c "bad certificate (EC key curve)"\
  3819. -c "! Certificate verification flags"\
  3820. -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
  3821. requires_config_enabled MBEDTLS_ECP_C
  3822. run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
  3823. "$P_SRV debug_level=1 key_file=data_files/server5.key \
  3824. crt_file=data_files/server5.ku-ka.crt" \
  3825. "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
  3826. 1 \
  3827. -c "bad certificate (EC key curve)"\
  3828. -c "! Certificate verification flags"\
  3829. -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
  3830. run_test "Authentication: server badcert, client none" \
  3831. "$P_SRV crt_file=data_files/server5-badsign.crt \
  3832. key_file=data_files/server5.key" \
  3833. "$P_CLI debug_level=1 auth_mode=none" \
  3834. 0 \
  3835. -C "x509_verify_cert() returned" \
  3836. -C "! The certificate is not correctly signed by the trusted CA" \
  3837. -C "! mbedtls_ssl_handshake returned" \
  3838. -C "X509 - Certificate verification failed"
  3839. run_test "Authentication: client SHA256, server required" \
  3840. "$P_SRV auth_mode=required" \
  3841. "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
  3842. key_file=data_files/server6.key \
  3843. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
  3844. 0 \
  3845. -c "Supported Signature Algorithm found: 4," \
  3846. -c "Supported Signature Algorithm found: 5,"
  3847. run_test "Authentication: client SHA384, server required" \
  3848. "$P_SRV auth_mode=required" \
  3849. "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
  3850. key_file=data_files/server6.key \
  3851. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
  3852. 0 \
  3853. -c "Supported Signature Algorithm found: 4," \
  3854. -c "Supported Signature Algorithm found: 5,"
  3855. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  3856. run_test "Authentication: client has no cert, server required (SSLv3)" \
  3857. "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
  3858. "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
  3859. key_file=data_files/server5.key" \
  3860. 1 \
  3861. -S "skip write certificate request" \
  3862. -C "skip parse certificate request" \
  3863. -c "got a certificate request" \
  3864. -c "got no certificate to send" \
  3865. -S "x509_verify_cert() returned" \
  3866. -s "client has no certificate" \
  3867. -s "! mbedtls_ssl_handshake returned" \
  3868. -c "! mbedtls_ssl_handshake returned" \
  3869. -s "No client certification received from the client, but required by the authentication mode"
  3870. run_test "Authentication: client has no cert, server required (TLS)" \
  3871. "$P_SRV debug_level=3 auth_mode=required" \
  3872. "$P_CLI debug_level=3 crt_file=none \
  3873. key_file=data_files/server5.key" \
  3874. 1 \
  3875. -S "skip write certificate request" \
  3876. -C "skip parse certificate request" \
  3877. -c "got a certificate request" \
  3878. -c "= write certificate$" \
  3879. -C "skip write certificate$" \
  3880. -S "x509_verify_cert() returned" \
  3881. -s "client has no certificate" \
  3882. -s "! mbedtls_ssl_handshake returned" \
  3883. -c "! mbedtls_ssl_handshake returned" \
  3884. -s "No client certification received from the client, but required by the authentication mode"
  3885. run_test "Authentication: client badcert, server required" \
  3886. "$P_SRV debug_level=3 auth_mode=required" \
  3887. "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
  3888. key_file=data_files/server5.key" \
  3889. 1 \
  3890. -S "skip write certificate request" \
  3891. -C "skip parse certificate request" \
  3892. -c "got a certificate request" \
  3893. -C "skip write certificate" \
  3894. -C "skip write certificate verify" \
  3895. -S "skip parse certificate verify" \
  3896. -s "x509_verify_cert() returned" \
  3897. -s "! The certificate is not correctly signed by the trusted CA" \
  3898. -s "! mbedtls_ssl_handshake returned" \
  3899. -s "send alert level=2 message=48" \
  3900. -c "! mbedtls_ssl_handshake returned" \
  3901. -s "X509 - Certificate verification failed"
  3902. # We don't check that the client receives the alert because it might
  3903. # detect that its write end of the connection is closed and abort
  3904. # before reading the alert message.
  3905. run_test "Authentication: client cert not trusted, server required" \
  3906. "$P_SRV debug_level=3 auth_mode=required" \
  3907. "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
  3908. key_file=data_files/server5.key" \
  3909. 1 \
  3910. -S "skip write certificate request" \
  3911. -C "skip parse certificate request" \
  3912. -c "got a certificate request" \
  3913. -C "skip write certificate" \
  3914. -C "skip write certificate verify" \
  3915. -S "skip parse certificate verify" \
  3916. -s "x509_verify_cert() returned" \
  3917. -s "! The certificate is not correctly signed by the trusted CA" \
  3918. -s "! mbedtls_ssl_handshake returned" \
  3919. -c "! mbedtls_ssl_handshake returned" \
  3920. -s "X509 - Certificate verification failed"
  3921. run_test "Authentication: client badcert, server optional" \
  3922. "$P_SRV debug_level=3 auth_mode=optional" \
  3923. "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
  3924. key_file=data_files/server5.key" \
  3925. 0 \
  3926. -S "skip write certificate request" \
  3927. -C "skip parse certificate request" \
  3928. -c "got a certificate request" \
  3929. -C "skip write certificate" \
  3930. -C "skip write certificate verify" \
  3931. -S "skip parse certificate verify" \
  3932. -s "x509_verify_cert() returned" \
  3933. -s "! The certificate is not correctly signed by the trusted CA" \
  3934. -S "! mbedtls_ssl_handshake returned" \
  3935. -C "! mbedtls_ssl_handshake returned" \
  3936. -S "X509 - Certificate verification failed"
  3937. run_test "Authentication: client badcert, server none" \
  3938. "$P_SRV debug_level=3 auth_mode=none" \
  3939. "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
  3940. key_file=data_files/server5.key" \
  3941. 0 \
  3942. -s "skip write certificate request" \
  3943. -C "skip parse certificate request" \
  3944. -c "got no certificate request" \
  3945. -c "skip write certificate" \
  3946. -c "skip write certificate verify" \
  3947. -s "skip parse certificate verify" \
  3948. -S "x509_verify_cert() returned" \
  3949. -S "! The certificate is not correctly signed by the trusted CA" \
  3950. -S "! mbedtls_ssl_handshake returned" \
  3951. -C "! mbedtls_ssl_handshake returned" \
  3952. -S "X509 - Certificate verification failed"
  3953. run_test "Authentication: client no cert, server optional" \
  3954. "$P_SRV debug_level=3 auth_mode=optional" \
  3955. "$P_CLI debug_level=3 crt_file=none key_file=none" \
  3956. 0 \
  3957. -S "skip write certificate request" \
  3958. -C "skip parse certificate request" \
  3959. -c "got a certificate request" \
  3960. -C "skip write certificate$" \
  3961. -C "got no certificate to send" \
  3962. -S "SSLv3 client has no certificate" \
  3963. -c "skip write certificate verify" \
  3964. -s "skip parse certificate verify" \
  3965. -s "! Certificate was missing" \
  3966. -S "! mbedtls_ssl_handshake returned" \
  3967. -C "! mbedtls_ssl_handshake returned" \
  3968. -S "X509 - Certificate verification failed"
  3969. run_test "Authentication: openssl client no cert, server optional" \
  3970. "$P_SRV debug_level=3 auth_mode=optional" \
  3971. "$O_CLI" \
  3972. 0 \
  3973. -S "skip write certificate request" \
  3974. -s "skip parse certificate verify" \
  3975. -s "! Certificate was missing" \
  3976. -S "! mbedtls_ssl_handshake returned" \
  3977. -S "X509 - Certificate verification failed"
  3978. run_test "Authentication: client no cert, openssl server optional" \
  3979. "$O_SRV -verify 10" \
  3980. "$P_CLI debug_level=3 crt_file=none key_file=none" \
  3981. 0 \
  3982. -C "skip parse certificate request" \
  3983. -c "got a certificate request" \
  3984. -C "skip write certificate$" \
  3985. -c "skip write certificate verify" \
  3986. -C "! mbedtls_ssl_handshake returned"
  3987. run_test "Authentication: client no cert, openssl server required" \
  3988. "$O_SRV -Verify 10" \
  3989. "$P_CLI debug_level=3 crt_file=none key_file=none" \
  3990. 1 \
  3991. -C "skip parse certificate request" \
  3992. -c "got a certificate request" \
  3993. -C "skip write certificate$" \
  3994. -c "skip write certificate verify" \
  3995. -c "! mbedtls_ssl_handshake returned"
  3996. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  3997. run_test "Authentication: client no cert, ssl3" \
  3998. "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
  3999. "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
  4000. 0 \
  4001. -S "skip write certificate request" \
  4002. -C "skip parse certificate request" \
  4003. -c "got a certificate request" \
  4004. -C "skip write certificate$" \
  4005. -c "skip write certificate verify" \
  4006. -c "got no certificate to send" \
  4007. -s "SSLv3 client has no certificate" \
  4008. -s "skip parse certificate verify" \
  4009. -s "! Certificate was missing" \
  4010. -S "! mbedtls_ssl_handshake returned" \
  4011. -C "! mbedtls_ssl_handshake returned" \
  4012. -S "X509 - Certificate verification failed"
  4013. # This script assumes that MBEDTLS_X509_MAX_INTERMEDIATE_CA has its default
  4014. # value, defined here as MAX_IM_CA. Some test cases will be skipped if the
  4015. # library is configured with a different value.
  4016. MAX_IM_CA='8'
  4017. # The tests for the max_int tests can pass with any number higher than MAX_IM_CA
  4018. # because only a chain of MAX_IM_CA length is tested. Equally, the max_int+1
  4019. # tests can pass with any number less than MAX_IM_CA. However, stricter preconditions
  4020. # are in place so that the semantics are consistent with the test description.
  4021. requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
  4022. requires_full_size_output_buffer
  4023. run_test "Authentication: server max_int chain, client default" \
  4024. "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
  4025. key_file=data_files/dir-maxpath/09.key" \
  4026. "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
  4027. 0 \
  4028. -C "X509 - A fatal error occurred"
  4029. requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
  4030. requires_full_size_output_buffer
  4031. run_test "Authentication: server max_int+1 chain, client default" \
  4032. "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
  4033. key_file=data_files/dir-maxpath/10.key" \
  4034. "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
  4035. 1 \
  4036. -c "X509 - A fatal error occurred"
  4037. requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
  4038. requires_full_size_output_buffer
  4039. run_test "Authentication: server max_int+1 chain, client optional" \
  4040. "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
  4041. key_file=data_files/dir-maxpath/10.key" \
  4042. "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
  4043. auth_mode=optional" \
  4044. 1 \
  4045. -c "X509 - A fatal error occurred"
  4046. requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
  4047. requires_full_size_output_buffer
  4048. run_test "Authentication: server max_int+1 chain, client none" \
  4049. "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
  4050. key_file=data_files/dir-maxpath/10.key" \
  4051. "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
  4052. auth_mode=none" \
  4053. 0 \
  4054. -C "X509 - A fatal error occurred"
  4055. requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
  4056. requires_full_size_output_buffer
  4057. run_test "Authentication: client max_int+1 chain, server default" \
  4058. "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
  4059. "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
  4060. key_file=data_files/dir-maxpath/10.key" \
  4061. 0 \
  4062. -S "X509 - A fatal error occurred"
  4063. requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
  4064. requires_full_size_output_buffer
  4065. run_test "Authentication: client max_int+1 chain, server optional" \
  4066. "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
  4067. "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
  4068. key_file=data_files/dir-maxpath/10.key" \
  4069. 1 \
  4070. -s "X509 - A fatal error occurred"
  4071. requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
  4072. requires_full_size_output_buffer
  4073. run_test "Authentication: client max_int+1 chain, server required" \
  4074. "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
  4075. "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
  4076. key_file=data_files/dir-maxpath/10.key" \
  4077. 1 \
  4078. -s "X509 - A fatal error occurred"
  4079. requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
  4080. requires_full_size_output_buffer
  4081. run_test "Authentication: client max_int chain, server required" \
  4082. "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
  4083. "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
  4084. key_file=data_files/dir-maxpath/09.key" \
  4085. 0 \
  4086. -S "X509 - A fatal error occurred"
  4087. # Tests for CA list in CertificateRequest messages
  4088. run_test "Authentication: send CA list in CertificateRequest (default)" \
  4089. "$P_SRV debug_level=3 auth_mode=required" \
  4090. "$P_CLI crt_file=data_files/server6.crt \
  4091. key_file=data_files/server6.key" \
  4092. 0 \
  4093. -s "requested DN"
  4094. run_test "Authentication: do not send CA list in CertificateRequest" \
  4095. "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
  4096. "$P_CLI crt_file=data_files/server6.crt \
  4097. key_file=data_files/server6.key" \
  4098. 0 \
  4099. -S "requested DN"
  4100. run_test "Authentication: send CA list in CertificateRequest, client self signed" \
  4101. "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
  4102. "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
  4103. key_file=data_files/server5.key" \
  4104. 1 \
  4105. -S "requested DN" \
  4106. -s "x509_verify_cert() returned" \
  4107. -s "! The certificate is not correctly signed by the trusted CA" \
  4108. -s "! mbedtls_ssl_handshake returned" \
  4109. -c "! mbedtls_ssl_handshake returned" \
  4110. -s "X509 - Certificate verification failed"
  4111. # Tests for auth_mode, using CA callback, these are duplicated from the authentication tests
  4112. # When updating these tests, modify the matching authentication tests accordingly
  4113. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  4114. run_test "Authentication, CA callback: server badcert, client required" \
  4115. "$P_SRV crt_file=data_files/server5-badsign.crt \
  4116. key_file=data_files/server5.key" \
  4117. "$P_CLI ca_callback=1 debug_level=3 auth_mode=required" \
  4118. 1 \
  4119. -c "use CA callback for X.509 CRT verification" \
  4120. -c "x509_verify_cert() returned" \
  4121. -c "! The certificate is not correctly signed by the trusted CA" \
  4122. -c "! mbedtls_ssl_handshake returned" \
  4123. -c "X509 - Certificate verification failed"
  4124. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  4125. run_test "Authentication, CA callback: server badcert, client optional" \
  4126. "$P_SRV crt_file=data_files/server5-badsign.crt \
  4127. key_file=data_files/server5.key" \
  4128. "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional" \
  4129. 0 \
  4130. -c "use CA callback for X.509 CRT verification" \
  4131. -c "x509_verify_cert() returned" \
  4132. -c "! The certificate is not correctly signed by the trusted CA" \
  4133. -C "! mbedtls_ssl_handshake returned" \
  4134. -C "X509 - Certificate verification failed"
  4135. # The purpose of the next two tests is to test the client's behaviour when receiving a server
  4136. # certificate with an unsupported elliptic curve. This should usually not happen because
  4137. # the client informs the server about the supported curves - it does, though, in the
  4138. # corner case of a static ECDH suite, because the server doesn't check the curve on that
  4139. # occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
  4140. # different means to have the server ignoring the client's supported curve list.
  4141. requires_config_enabled MBEDTLS_ECP_C
  4142. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  4143. run_test "Authentication, CA callback: server ECDH p256v1, client required, p256v1 unsupported" \
  4144. "$P_SRV debug_level=1 key_file=data_files/server5.key \
  4145. crt_file=data_files/server5.ku-ka.crt" \
  4146. "$P_CLI ca_callback=1 debug_level=3 auth_mode=required curves=secp521r1" \
  4147. 1 \
  4148. -c "use CA callback for X.509 CRT verification" \
  4149. -c "bad certificate (EC key curve)" \
  4150. -c "! Certificate verification flags" \
  4151. -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
  4152. requires_config_enabled MBEDTLS_ECP_C
  4153. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  4154. run_test "Authentication, CA callback: server ECDH p256v1, client optional, p256v1 unsupported" \
  4155. "$P_SRV debug_level=1 key_file=data_files/server5.key \
  4156. crt_file=data_files/server5.ku-ka.crt" \
  4157. "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional curves=secp521r1" \
  4158. 1 \
  4159. -c "use CA callback for X.509 CRT verification" \
  4160. -c "bad certificate (EC key curve)"\
  4161. -c "! Certificate verification flags"\
  4162. -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
  4163. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  4164. run_test "Authentication, CA callback: client SHA256, server required" \
  4165. "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
  4166. "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
  4167. key_file=data_files/server6.key \
  4168. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
  4169. 0 \
  4170. -s "use CA callback for X.509 CRT verification" \
  4171. -c "Supported Signature Algorithm found: 4," \
  4172. -c "Supported Signature Algorithm found: 5,"
  4173. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  4174. run_test "Authentication, CA callback: client SHA384, server required" \
  4175. "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
  4176. "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
  4177. key_file=data_files/server6.key \
  4178. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
  4179. 0 \
  4180. -s "use CA callback for X.509 CRT verification" \
  4181. -c "Supported Signature Algorithm found: 4," \
  4182. -c "Supported Signature Algorithm found: 5,"
  4183. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  4184. run_test "Authentication, CA callback: client badcert, server required" \
  4185. "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
  4186. "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
  4187. key_file=data_files/server5.key" \
  4188. 1 \
  4189. -s "use CA callback for X.509 CRT verification" \
  4190. -S "skip write certificate request" \
  4191. -C "skip parse certificate request" \
  4192. -c "got a certificate request" \
  4193. -C "skip write certificate" \
  4194. -C "skip write certificate verify" \
  4195. -S "skip parse certificate verify" \
  4196. -s "x509_verify_cert() returned" \
  4197. -s "! The certificate is not correctly signed by the trusted CA" \
  4198. -s "! mbedtls_ssl_handshake returned" \
  4199. -s "send alert level=2 message=48" \
  4200. -c "! mbedtls_ssl_handshake returned" \
  4201. -s "X509 - Certificate verification failed"
  4202. # We don't check that the client receives the alert because it might
  4203. # detect that its write end of the connection is closed and abort
  4204. # before reading the alert message.
  4205. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  4206. run_test "Authentication, CA callback: client cert not trusted, server required" \
  4207. "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
  4208. "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
  4209. key_file=data_files/server5.key" \
  4210. 1 \
  4211. -s "use CA callback for X.509 CRT verification" \
  4212. -S "skip write certificate request" \
  4213. -C "skip parse certificate request" \
  4214. -c "got a certificate request" \
  4215. -C "skip write certificate" \
  4216. -C "skip write certificate verify" \
  4217. -S "skip parse certificate verify" \
  4218. -s "x509_verify_cert() returned" \
  4219. -s "! The certificate is not correctly signed by the trusted CA" \
  4220. -s "! mbedtls_ssl_handshake returned" \
  4221. -c "! mbedtls_ssl_handshake returned" \
  4222. -s "X509 - Certificate verification failed"
  4223. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  4224. run_test "Authentication, CA callback: client badcert, server optional" \
  4225. "$P_SRV ca_callback=1 debug_level=3 auth_mode=optional" \
  4226. "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
  4227. key_file=data_files/server5.key" \
  4228. 0 \
  4229. -s "use CA callback for X.509 CRT verification" \
  4230. -S "skip write certificate request" \
  4231. -C "skip parse certificate request" \
  4232. -c "got a certificate request" \
  4233. -C "skip write certificate" \
  4234. -C "skip write certificate verify" \
  4235. -S "skip parse certificate verify" \
  4236. -s "x509_verify_cert() returned" \
  4237. -s "! The certificate is not correctly signed by the trusted CA" \
  4238. -S "! mbedtls_ssl_handshake returned" \
  4239. -C "! mbedtls_ssl_handshake returned" \
  4240. -S "X509 - Certificate verification failed"
  4241. requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
  4242. requires_full_size_output_buffer
  4243. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  4244. run_test "Authentication, CA callback: server max_int chain, client default" \
  4245. "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
  4246. key_file=data_files/dir-maxpath/09.key" \
  4247. "$P_CLI ca_callback=1 debug_level=3 server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
  4248. 0 \
  4249. -c "use CA callback for X.509 CRT verification" \
  4250. -C "X509 - A fatal error occurred"
  4251. requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
  4252. requires_full_size_output_buffer
  4253. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  4254. run_test "Authentication, CA callback: server max_int+1 chain, client default" \
  4255. "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
  4256. key_file=data_files/dir-maxpath/10.key" \
  4257. "$P_CLI debug_level=3 ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
  4258. 1 \
  4259. -c "use CA callback for X.509 CRT verification" \
  4260. -c "X509 - A fatal error occurred"
  4261. requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
  4262. requires_full_size_output_buffer
  4263. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  4264. run_test "Authentication, CA callback: server max_int+1 chain, client optional" \
  4265. "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
  4266. key_file=data_files/dir-maxpath/10.key" \
  4267. "$P_CLI ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
  4268. debug_level=3 auth_mode=optional" \
  4269. 1 \
  4270. -c "use CA callback for X.509 CRT verification" \
  4271. -c "X509 - A fatal error occurred"
  4272. requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
  4273. requires_full_size_output_buffer
  4274. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  4275. run_test "Authentication, CA callback: client max_int+1 chain, server optional" \
  4276. "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
  4277. "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
  4278. key_file=data_files/dir-maxpath/10.key" \
  4279. 1 \
  4280. -s "use CA callback for X.509 CRT verification" \
  4281. -s "X509 - A fatal error occurred"
  4282. requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
  4283. requires_full_size_output_buffer
  4284. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  4285. run_test "Authentication, CA callback: client max_int+1 chain, server required" \
  4286. "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
  4287. "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
  4288. key_file=data_files/dir-maxpath/10.key" \
  4289. 1 \
  4290. -s "use CA callback for X.509 CRT verification" \
  4291. -s "X509 - A fatal error occurred"
  4292. requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
  4293. requires_full_size_output_buffer
  4294. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  4295. run_test "Authentication, CA callback: client max_int chain, server required" \
  4296. "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
  4297. "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
  4298. key_file=data_files/dir-maxpath/09.key" \
  4299. 0 \
  4300. -s "use CA callback for X.509 CRT verification" \
  4301. -S "X509 - A fatal error occurred"
  4302. # Tests for certificate selection based on SHA verson
  4303. run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
  4304. "$P_SRV crt_file=data_files/server5.crt \
  4305. key_file=data_files/server5.key \
  4306. crt_file2=data_files/server5-sha1.crt \
  4307. key_file2=data_files/server5.key" \
  4308. "$P_CLI force_version=tls12" \
  4309. 0 \
  4310. -c "signed using.*ECDSA with SHA256" \
  4311. -C "signed using.*ECDSA with SHA1"
  4312. run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
  4313. "$P_SRV crt_file=data_files/server5.crt \
  4314. key_file=data_files/server5.key \
  4315. crt_file2=data_files/server5-sha1.crt \
  4316. key_file2=data_files/server5.key" \
  4317. "$P_CLI force_version=tls1_1" \
  4318. 0 \
  4319. -C "signed using.*ECDSA with SHA256" \
  4320. -c "signed using.*ECDSA with SHA1"
  4321. run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
  4322. "$P_SRV crt_file=data_files/server5.crt \
  4323. key_file=data_files/server5.key \
  4324. crt_file2=data_files/server5-sha1.crt \
  4325. key_file2=data_files/server5.key" \
  4326. "$P_CLI force_version=tls1" \
  4327. 0 \
  4328. -C "signed using.*ECDSA with SHA256" \
  4329. -c "signed using.*ECDSA with SHA1"
  4330. run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
  4331. "$P_SRV crt_file=data_files/server5.crt \
  4332. key_file=data_files/server5.key \
  4333. crt_file2=data_files/server6.crt \
  4334. key_file2=data_files/server6.key" \
  4335. "$P_CLI force_version=tls1_1" \
  4336. 0 \
  4337. -c "serial number.*09" \
  4338. -c "signed using.*ECDSA with SHA256" \
  4339. -C "signed using.*ECDSA with SHA1"
  4340. run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
  4341. "$P_SRV crt_file=data_files/server6.crt \
  4342. key_file=data_files/server6.key \
  4343. crt_file2=data_files/server5.crt \
  4344. key_file2=data_files/server5.key" \
  4345. "$P_CLI force_version=tls1_1" \
  4346. 0 \
  4347. -c "serial number.*0A" \
  4348. -c "signed using.*ECDSA with SHA256" \
  4349. -C "signed using.*ECDSA with SHA1"
  4350. # tests for SNI
  4351. run_test "SNI: no SNI callback" \
  4352. "$P_SRV debug_level=3 \
  4353. crt_file=data_files/server5.crt key_file=data_files/server5.key" \
  4354. "$P_CLI server_name=localhost" \
  4355. 0 \
  4356. -S "parse ServerName extension" \
  4357. -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
  4358. -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
  4359. run_test "SNI: matching cert 1" \
  4360. "$P_SRV debug_level=3 \
  4361. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4362. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
  4363. "$P_CLI server_name=localhost" \
  4364. 0 \
  4365. -s "parse ServerName extension" \
  4366. -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
  4367. -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
  4368. run_test "SNI: matching cert 2" \
  4369. "$P_SRV debug_level=3 \
  4370. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4371. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
  4372. "$P_CLI server_name=polarssl.example" \
  4373. 0 \
  4374. -s "parse ServerName extension" \
  4375. -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
  4376. -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
  4377. run_test "SNI: no matching cert" \
  4378. "$P_SRV debug_level=3 \
  4379. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4380. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
  4381. "$P_CLI server_name=nonesuch.example" \
  4382. 1 \
  4383. -s "parse ServerName extension" \
  4384. -s "ssl_sni_wrapper() returned" \
  4385. -s "mbedtls_ssl_handshake returned" \
  4386. -c "mbedtls_ssl_handshake returned" \
  4387. -c "SSL - A fatal alert message was received from our peer"
  4388. run_test "SNI: client auth no override: optional" \
  4389. "$P_SRV debug_level=3 auth_mode=optional \
  4390. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4391. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
  4392. "$P_CLI debug_level=3 server_name=localhost" \
  4393. 0 \
  4394. -S "skip write certificate request" \
  4395. -C "skip parse certificate request" \
  4396. -c "got a certificate request" \
  4397. -C "skip write certificate" \
  4398. -C "skip write certificate verify" \
  4399. -S "skip parse certificate verify"
  4400. run_test "SNI: client auth override: none -> optional" \
  4401. "$P_SRV debug_level=3 auth_mode=none \
  4402. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4403. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
  4404. "$P_CLI debug_level=3 server_name=localhost" \
  4405. 0 \
  4406. -S "skip write certificate request" \
  4407. -C "skip parse certificate request" \
  4408. -c "got a certificate request" \
  4409. -C "skip write certificate" \
  4410. -C "skip write certificate verify" \
  4411. -S "skip parse certificate verify"
  4412. run_test "SNI: client auth override: optional -> none" \
  4413. "$P_SRV debug_level=3 auth_mode=optional \
  4414. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4415. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
  4416. "$P_CLI debug_level=3 server_name=localhost" \
  4417. 0 \
  4418. -s "skip write certificate request" \
  4419. -C "skip parse certificate request" \
  4420. -c "got no certificate request" \
  4421. -c "skip write certificate" \
  4422. -c "skip write certificate verify" \
  4423. -s "skip parse certificate verify"
  4424. run_test "SNI: CA no override" \
  4425. "$P_SRV debug_level=3 auth_mode=optional \
  4426. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4427. ca_file=data_files/test-ca.crt \
  4428. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
  4429. "$P_CLI debug_level=3 server_name=localhost \
  4430. crt_file=data_files/server6.crt key_file=data_files/server6.key" \
  4431. 1 \
  4432. -S "skip write certificate request" \
  4433. -C "skip parse certificate request" \
  4434. -c "got a certificate request" \
  4435. -C "skip write certificate" \
  4436. -C "skip write certificate verify" \
  4437. -S "skip parse certificate verify" \
  4438. -s "x509_verify_cert() returned" \
  4439. -s "! The certificate is not correctly signed by the trusted CA" \
  4440. -S "The certificate has been revoked (is on a CRL)"
  4441. run_test "SNI: CA override" \
  4442. "$P_SRV debug_level=3 auth_mode=optional \
  4443. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4444. ca_file=data_files/test-ca.crt \
  4445. sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
  4446. "$P_CLI debug_level=3 server_name=localhost \
  4447. crt_file=data_files/server6.crt key_file=data_files/server6.key" \
  4448. 0 \
  4449. -S "skip write certificate request" \
  4450. -C "skip parse certificate request" \
  4451. -c "got a certificate request" \
  4452. -C "skip write certificate" \
  4453. -C "skip write certificate verify" \
  4454. -S "skip parse certificate verify" \
  4455. -S "x509_verify_cert() returned" \
  4456. -S "! The certificate is not correctly signed by the trusted CA" \
  4457. -S "The certificate has been revoked (is on a CRL)"
  4458. run_test "SNI: CA override with CRL" \
  4459. "$P_SRV debug_level=3 auth_mode=optional \
  4460. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4461. ca_file=data_files/test-ca.crt \
  4462. sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
  4463. "$P_CLI debug_level=3 server_name=localhost \
  4464. crt_file=data_files/server6.crt key_file=data_files/server6.key" \
  4465. 1 \
  4466. -S "skip write certificate request" \
  4467. -C "skip parse certificate request" \
  4468. -c "got a certificate request" \
  4469. -C "skip write certificate" \
  4470. -C "skip write certificate verify" \
  4471. -S "skip parse certificate verify" \
  4472. -s "x509_verify_cert() returned" \
  4473. -S "! The certificate is not correctly signed by the trusted CA" \
  4474. -s "The certificate has been revoked (is on a CRL)"
  4475. # Tests for SNI and DTLS
  4476. run_test "SNI: DTLS, no SNI callback" \
  4477. "$P_SRV debug_level=3 dtls=1 \
  4478. crt_file=data_files/server5.crt key_file=data_files/server5.key" \
  4479. "$P_CLI server_name=localhost dtls=1" \
  4480. 0 \
  4481. -S "parse ServerName extension" \
  4482. -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
  4483. -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
  4484. run_test "SNI: DTLS, matching cert 1" \
  4485. "$P_SRV debug_level=3 dtls=1 \
  4486. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4487. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
  4488. "$P_CLI server_name=localhost dtls=1" \
  4489. 0 \
  4490. -s "parse ServerName extension" \
  4491. -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
  4492. -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
  4493. run_test "SNI: DTLS, matching cert 2" \
  4494. "$P_SRV debug_level=3 dtls=1 \
  4495. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4496. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
  4497. "$P_CLI server_name=polarssl.example dtls=1" \
  4498. 0 \
  4499. -s "parse ServerName extension" \
  4500. -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
  4501. -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
  4502. run_test "SNI: DTLS, no matching cert" \
  4503. "$P_SRV debug_level=3 dtls=1 \
  4504. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4505. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
  4506. "$P_CLI server_name=nonesuch.example dtls=1" \
  4507. 1 \
  4508. -s "parse ServerName extension" \
  4509. -s "ssl_sni_wrapper() returned" \
  4510. -s "mbedtls_ssl_handshake returned" \
  4511. -c "mbedtls_ssl_handshake returned" \
  4512. -c "SSL - A fatal alert message was received from our peer"
  4513. run_test "SNI: DTLS, client auth no override: optional" \
  4514. "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
  4515. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4516. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
  4517. "$P_CLI debug_level=3 server_name=localhost dtls=1" \
  4518. 0 \
  4519. -S "skip write certificate request" \
  4520. -C "skip parse certificate request" \
  4521. -c "got a certificate request" \
  4522. -C "skip write certificate" \
  4523. -C "skip write certificate verify" \
  4524. -S "skip parse certificate verify"
  4525. run_test "SNI: DTLS, client auth override: none -> optional" \
  4526. "$P_SRV debug_level=3 auth_mode=none dtls=1 \
  4527. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4528. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
  4529. "$P_CLI debug_level=3 server_name=localhost dtls=1" \
  4530. 0 \
  4531. -S "skip write certificate request" \
  4532. -C "skip parse certificate request" \
  4533. -c "got a certificate request" \
  4534. -C "skip write certificate" \
  4535. -C "skip write certificate verify" \
  4536. -S "skip parse certificate verify"
  4537. run_test "SNI: DTLS, client auth override: optional -> none" \
  4538. "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
  4539. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4540. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
  4541. "$P_CLI debug_level=3 server_name=localhost dtls=1" \
  4542. 0 \
  4543. -s "skip write certificate request" \
  4544. -C "skip parse certificate request" \
  4545. -c "got no certificate request" \
  4546. -c "skip write certificate" \
  4547. -c "skip write certificate verify" \
  4548. -s "skip parse certificate verify"
  4549. run_test "SNI: DTLS, CA no override" \
  4550. "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
  4551. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4552. ca_file=data_files/test-ca.crt \
  4553. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
  4554. "$P_CLI debug_level=3 server_name=localhost dtls=1 \
  4555. crt_file=data_files/server6.crt key_file=data_files/server6.key" \
  4556. 1 \
  4557. -S "skip write certificate request" \
  4558. -C "skip parse certificate request" \
  4559. -c "got a certificate request" \
  4560. -C "skip write certificate" \
  4561. -C "skip write certificate verify" \
  4562. -S "skip parse certificate verify" \
  4563. -s "x509_verify_cert() returned" \
  4564. -s "! The certificate is not correctly signed by the trusted CA" \
  4565. -S "The certificate has been revoked (is on a CRL)"
  4566. run_test "SNI: DTLS, CA override" \
  4567. "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
  4568. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4569. ca_file=data_files/test-ca.crt \
  4570. sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
  4571. "$P_CLI debug_level=3 server_name=localhost dtls=1 \
  4572. crt_file=data_files/server6.crt key_file=data_files/server6.key" \
  4573. 0 \
  4574. -S "skip write certificate request" \
  4575. -C "skip parse certificate request" \
  4576. -c "got a certificate request" \
  4577. -C "skip write certificate" \
  4578. -C "skip write certificate verify" \
  4579. -S "skip parse certificate verify" \
  4580. -S "x509_verify_cert() returned" \
  4581. -S "! The certificate is not correctly signed by the trusted CA" \
  4582. -S "The certificate has been revoked (is on a CRL)"
  4583. run_test "SNI: DTLS, CA override with CRL" \
  4584. "$P_SRV debug_level=3 auth_mode=optional \
  4585. crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
  4586. ca_file=data_files/test-ca.crt \
  4587. sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
  4588. "$P_CLI debug_level=3 server_name=localhost dtls=1 \
  4589. crt_file=data_files/server6.crt key_file=data_files/server6.key" \
  4590. 1 \
  4591. -S "skip write certificate request" \
  4592. -C "skip parse certificate request" \
  4593. -c "got a certificate request" \
  4594. -C "skip write certificate" \
  4595. -C "skip write certificate verify" \
  4596. -S "skip parse certificate verify" \
  4597. -s "x509_verify_cert() returned" \
  4598. -S "! The certificate is not correctly signed by the trusted CA" \
  4599. -s "The certificate has been revoked (is on a CRL)"
  4600. # Tests for non-blocking I/O: exercise a variety of handshake flows
  4601. run_test "Non-blocking I/O: basic handshake" \
  4602. "$P_SRV nbio=2 tickets=0 auth_mode=none" \
  4603. "$P_CLI nbio=2 tickets=0" \
  4604. 0 \
  4605. -S "mbedtls_ssl_handshake returned" \
  4606. -C "mbedtls_ssl_handshake returned" \
  4607. -c "Read from server: .* bytes read"
  4608. run_test "Non-blocking I/O: client auth" \
  4609. "$P_SRV nbio=2 tickets=0 auth_mode=required" \
  4610. "$P_CLI nbio=2 tickets=0" \
  4611. 0 \
  4612. -S "mbedtls_ssl_handshake returned" \
  4613. -C "mbedtls_ssl_handshake returned" \
  4614. -c "Read from server: .* bytes read"
  4615. run_test "Non-blocking I/O: ticket" \
  4616. "$P_SRV nbio=2 tickets=1 auth_mode=none" \
  4617. "$P_CLI nbio=2 tickets=1" \
  4618. 0 \
  4619. -S "mbedtls_ssl_handshake returned" \
  4620. -C "mbedtls_ssl_handshake returned" \
  4621. -c "Read from server: .* bytes read"
  4622. run_test "Non-blocking I/O: ticket + client auth" \
  4623. "$P_SRV nbio=2 tickets=1 auth_mode=required" \
  4624. "$P_CLI nbio=2 tickets=1" \
  4625. 0 \
  4626. -S "mbedtls_ssl_handshake returned" \
  4627. -C "mbedtls_ssl_handshake returned" \
  4628. -c "Read from server: .* bytes read"
  4629. run_test "Non-blocking I/O: ticket + client auth + resume" \
  4630. "$P_SRV nbio=2 tickets=1 auth_mode=required" \
  4631. "$P_CLI nbio=2 tickets=1 reconnect=1" \
  4632. 0 \
  4633. -S "mbedtls_ssl_handshake returned" \
  4634. -C "mbedtls_ssl_handshake returned" \
  4635. -c "Read from server: .* bytes read"
  4636. run_test "Non-blocking I/O: ticket + resume" \
  4637. "$P_SRV nbio=2 tickets=1 auth_mode=none" \
  4638. "$P_CLI nbio=2 tickets=1 reconnect=1" \
  4639. 0 \
  4640. -S "mbedtls_ssl_handshake returned" \
  4641. -C "mbedtls_ssl_handshake returned" \
  4642. -c "Read from server: .* bytes read"
  4643. run_test "Non-blocking I/O: session-id resume" \
  4644. "$P_SRV nbio=2 tickets=0 auth_mode=none" \
  4645. "$P_CLI nbio=2 tickets=0 reconnect=1" \
  4646. 0 \
  4647. -S "mbedtls_ssl_handshake returned" \
  4648. -C "mbedtls_ssl_handshake returned" \
  4649. -c "Read from server: .* bytes read"
  4650. # Tests for event-driven I/O: exercise a variety of handshake flows
  4651. run_test "Event-driven I/O: basic handshake" \
  4652. "$P_SRV event=1 tickets=0 auth_mode=none" \
  4653. "$P_CLI event=1 tickets=0" \
  4654. 0 \
  4655. -S "mbedtls_ssl_handshake returned" \
  4656. -C "mbedtls_ssl_handshake returned" \
  4657. -c "Read from server: .* bytes read"
  4658. run_test "Event-driven I/O: client auth" \
  4659. "$P_SRV event=1 tickets=0 auth_mode=required" \
  4660. "$P_CLI event=1 tickets=0" \
  4661. 0 \
  4662. -S "mbedtls_ssl_handshake returned" \
  4663. -C "mbedtls_ssl_handshake returned" \
  4664. -c "Read from server: .* bytes read"
  4665. run_test "Event-driven I/O: ticket" \
  4666. "$P_SRV event=1 tickets=1 auth_mode=none" \
  4667. "$P_CLI event=1 tickets=1" \
  4668. 0 \
  4669. -S "mbedtls_ssl_handshake returned" \
  4670. -C "mbedtls_ssl_handshake returned" \
  4671. -c "Read from server: .* bytes read"
  4672. run_test "Event-driven I/O: ticket + client auth" \
  4673. "$P_SRV event=1 tickets=1 auth_mode=required" \
  4674. "$P_CLI event=1 tickets=1" \
  4675. 0 \
  4676. -S "mbedtls_ssl_handshake returned" \
  4677. -C "mbedtls_ssl_handshake returned" \
  4678. -c "Read from server: .* bytes read"
  4679. run_test "Event-driven I/O: ticket + client auth + resume" \
  4680. "$P_SRV event=1 tickets=1 auth_mode=required" \
  4681. "$P_CLI event=1 tickets=1 reconnect=1" \
  4682. 0 \
  4683. -S "mbedtls_ssl_handshake returned" \
  4684. -C "mbedtls_ssl_handshake returned" \
  4685. -c "Read from server: .* bytes read"
  4686. run_test "Event-driven I/O: ticket + resume" \
  4687. "$P_SRV event=1 tickets=1 auth_mode=none" \
  4688. "$P_CLI event=1 tickets=1 reconnect=1" \
  4689. 0 \
  4690. -S "mbedtls_ssl_handshake returned" \
  4691. -C "mbedtls_ssl_handshake returned" \
  4692. -c "Read from server: .* bytes read"
  4693. run_test "Event-driven I/O: session-id resume" \
  4694. "$P_SRV event=1 tickets=0 auth_mode=none" \
  4695. "$P_CLI event=1 tickets=0 reconnect=1" \
  4696. 0 \
  4697. -S "mbedtls_ssl_handshake returned" \
  4698. -C "mbedtls_ssl_handshake returned" \
  4699. -c "Read from server: .* bytes read"
  4700. run_test "Event-driven I/O, DTLS: basic handshake" \
  4701. "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
  4702. "$P_CLI dtls=1 event=1 tickets=0" \
  4703. 0 \
  4704. -c "Read from server: .* bytes read"
  4705. run_test "Event-driven I/O, DTLS: client auth" \
  4706. "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
  4707. "$P_CLI dtls=1 event=1 tickets=0" \
  4708. 0 \
  4709. -c "Read from server: .* bytes read"
  4710. run_test "Event-driven I/O, DTLS: ticket" \
  4711. "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
  4712. "$P_CLI dtls=1 event=1 tickets=1" \
  4713. 0 \
  4714. -c "Read from server: .* bytes read"
  4715. run_test "Event-driven I/O, DTLS: ticket + client auth" \
  4716. "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
  4717. "$P_CLI dtls=1 event=1 tickets=1" \
  4718. 0 \
  4719. -c "Read from server: .* bytes read"
  4720. run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
  4721. "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
  4722. "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
  4723. 0 \
  4724. -c "Read from server: .* bytes read"
  4725. run_test "Event-driven I/O, DTLS: ticket + resume" \
  4726. "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
  4727. "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
  4728. 0 \
  4729. -c "Read from server: .* bytes read"
  4730. run_test "Event-driven I/O, DTLS: session-id resume" \
  4731. "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
  4732. "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
  4733. 0 \
  4734. -c "Read from server: .* bytes read"
  4735. # This test demonstrates the need for the mbedtls_ssl_check_pending function.
  4736. # During session resumption, the client will send its ApplicationData record
  4737. # within the same datagram as the Finished messages. In this situation, the
  4738. # server MUST NOT idle on the underlying transport after handshake completion,
  4739. # because the ApplicationData request has already been queued internally.
  4740. run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
  4741. -p "$P_PXY pack=50" \
  4742. "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
  4743. "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
  4744. 0 \
  4745. -c "Read from server: .* bytes read"
  4746. # Tests for version negotiation
  4747. run_test "Version check: all -> 1.2" \
  4748. "$P_SRV" \
  4749. "$P_CLI" \
  4750. 0 \
  4751. -S "mbedtls_ssl_handshake returned" \
  4752. -C "mbedtls_ssl_handshake returned" \
  4753. -s "Protocol is TLSv1.2" \
  4754. -c "Protocol is TLSv1.2"
  4755. run_test "Version check: cli max 1.1 -> 1.1" \
  4756. "$P_SRV" \
  4757. "$P_CLI max_version=tls1_1" \
  4758. 0 \
  4759. -S "mbedtls_ssl_handshake returned" \
  4760. -C "mbedtls_ssl_handshake returned" \
  4761. -s "Protocol is TLSv1.1" \
  4762. -c "Protocol is TLSv1.1"
  4763. run_test "Version check: srv max 1.1 -> 1.1" \
  4764. "$P_SRV max_version=tls1_1" \
  4765. "$P_CLI" \
  4766. 0 \
  4767. -S "mbedtls_ssl_handshake returned" \
  4768. -C "mbedtls_ssl_handshake returned" \
  4769. -s "Protocol is TLSv1.1" \
  4770. -c "Protocol is TLSv1.1"
  4771. run_test "Version check: cli+srv max 1.1 -> 1.1" \
  4772. "$P_SRV max_version=tls1_1" \
  4773. "$P_CLI max_version=tls1_1" \
  4774. 0 \
  4775. -S "mbedtls_ssl_handshake returned" \
  4776. -C "mbedtls_ssl_handshake returned" \
  4777. -s "Protocol is TLSv1.1" \
  4778. -c "Protocol is TLSv1.1"
  4779. run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
  4780. "$P_SRV min_version=tls1_1" \
  4781. "$P_CLI max_version=tls1_1" \
  4782. 0 \
  4783. -S "mbedtls_ssl_handshake returned" \
  4784. -C "mbedtls_ssl_handshake returned" \
  4785. -s "Protocol is TLSv1.1" \
  4786. -c "Protocol is TLSv1.1"
  4787. run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
  4788. "$P_SRV max_version=tls1_1" \
  4789. "$P_CLI min_version=tls1_1" \
  4790. 0 \
  4791. -S "mbedtls_ssl_handshake returned" \
  4792. -C "mbedtls_ssl_handshake returned" \
  4793. -s "Protocol is TLSv1.1" \
  4794. -c "Protocol is TLSv1.1"
  4795. run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
  4796. "$P_SRV max_version=tls1_1" \
  4797. "$P_CLI min_version=tls12" \
  4798. 1 \
  4799. -s "mbedtls_ssl_handshake returned" \
  4800. -c "mbedtls_ssl_handshake returned" \
  4801. -c "SSL - Handshake protocol not within min/max boundaries"
  4802. run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
  4803. "$P_SRV min_version=tls12" \
  4804. "$P_CLI max_version=tls1_1" \
  4805. 1 \
  4806. -s "mbedtls_ssl_handshake returned" \
  4807. -c "mbedtls_ssl_handshake returned" \
  4808. -s "SSL - Handshake protocol not within min/max boundaries"
  4809. # Tests for ALPN extension
  4810. run_test "ALPN: none" \
  4811. "$P_SRV debug_level=3" \
  4812. "$P_CLI debug_level=3" \
  4813. 0 \
  4814. -C "client hello, adding alpn extension" \
  4815. -S "found alpn extension" \
  4816. -C "got an alert message, type: \\[2:120]" \
  4817. -S "server hello, adding alpn extension" \
  4818. -C "found alpn extension " \
  4819. -C "Application Layer Protocol is" \
  4820. -S "Application Layer Protocol is"
  4821. run_test "ALPN: client only" \
  4822. "$P_SRV debug_level=3" \
  4823. "$P_CLI debug_level=3 alpn=abc,1234" \
  4824. 0 \
  4825. -c "client hello, adding alpn extension" \
  4826. -s "found alpn extension" \
  4827. -C "got an alert message, type: \\[2:120]" \
  4828. -S "server hello, adding alpn extension" \
  4829. -C "found alpn extension " \
  4830. -c "Application Layer Protocol is (none)" \
  4831. -S "Application Layer Protocol is"
  4832. run_test "ALPN: server only" \
  4833. "$P_SRV debug_level=3 alpn=abc,1234" \
  4834. "$P_CLI debug_level=3" \
  4835. 0 \
  4836. -C "client hello, adding alpn extension" \
  4837. -S "found alpn extension" \
  4838. -C "got an alert message, type: \\[2:120]" \
  4839. -S "server hello, adding alpn extension" \
  4840. -C "found alpn extension " \
  4841. -C "Application Layer Protocol is" \
  4842. -s "Application Layer Protocol is (none)"
  4843. run_test "ALPN: both, common cli1-srv1" \
  4844. "$P_SRV debug_level=3 alpn=abc,1234" \
  4845. "$P_CLI debug_level=3 alpn=abc,1234" \
  4846. 0 \
  4847. -c "client hello, adding alpn extension" \
  4848. -s "found alpn extension" \
  4849. -C "got an alert message, type: \\[2:120]" \
  4850. -s "server hello, adding alpn extension" \
  4851. -c "found alpn extension" \
  4852. -c "Application Layer Protocol is abc" \
  4853. -s "Application Layer Protocol is abc"
  4854. run_test "ALPN: both, common cli2-srv1" \
  4855. "$P_SRV debug_level=3 alpn=abc,1234" \
  4856. "$P_CLI debug_level=3 alpn=1234,abc" \
  4857. 0 \
  4858. -c "client hello, adding alpn extension" \
  4859. -s "found alpn extension" \
  4860. -C "got an alert message, type: \\[2:120]" \
  4861. -s "server hello, adding alpn extension" \
  4862. -c "found alpn extension" \
  4863. -c "Application Layer Protocol is abc" \
  4864. -s "Application Layer Protocol is abc"
  4865. run_test "ALPN: both, common cli1-srv2" \
  4866. "$P_SRV debug_level=3 alpn=abc,1234" \
  4867. "$P_CLI debug_level=3 alpn=1234,abcde" \
  4868. 0 \
  4869. -c "client hello, adding alpn extension" \
  4870. -s "found alpn extension" \
  4871. -C "got an alert message, type: \\[2:120]" \
  4872. -s "server hello, adding alpn extension" \
  4873. -c "found alpn extension" \
  4874. -c "Application Layer Protocol is 1234" \
  4875. -s "Application Layer Protocol is 1234"
  4876. run_test "ALPN: both, no common" \
  4877. "$P_SRV debug_level=3 alpn=abc,123" \
  4878. "$P_CLI debug_level=3 alpn=1234,abcde" \
  4879. 1 \
  4880. -c "client hello, adding alpn extension" \
  4881. -s "found alpn extension" \
  4882. -c "got an alert message, type: \\[2:120]" \
  4883. -S "server hello, adding alpn extension" \
  4884. -C "found alpn extension" \
  4885. -C "Application Layer Protocol is 1234" \
  4886. -S "Application Layer Protocol is 1234"
  4887. # Tests for keyUsage in leaf certificates, part 1:
  4888. # server-side certificate/suite selection
  4889. run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
  4890. "$P_SRV key_file=data_files/server2.key \
  4891. crt_file=data_files/server2.ku-ds.crt" \
  4892. "$P_CLI" \
  4893. 0 \
  4894. -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
  4895. run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
  4896. "$P_SRV key_file=data_files/server2.key \
  4897. crt_file=data_files/server2.ku-ke.crt" \
  4898. "$P_CLI" \
  4899. 0 \
  4900. -c "Ciphersuite is TLS-RSA-WITH-"
  4901. run_test "keyUsage srv: RSA, keyAgreement -> fail" \
  4902. "$P_SRV key_file=data_files/server2.key \
  4903. crt_file=data_files/server2.ku-ka.crt" \
  4904. "$P_CLI" \
  4905. 1 \
  4906. -C "Ciphersuite is "
  4907. run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
  4908. "$P_SRV key_file=data_files/server5.key \
  4909. crt_file=data_files/server5.ku-ds.crt" \
  4910. "$P_CLI" \
  4911. 0 \
  4912. -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
  4913. run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
  4914. "$P_SRV key_file=data_files/server5.key \
  4915. crt_file=data_files/server5.ku-ka.crt" \
  4916. "$P_CLI" \
  4917. 0 \
  4918. -c "Ciphersuite is TLS-ECDH-"
  4919. run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
  4920. "$P_SRV key_file=data_files/server5.key \
  4921. crt_file=data_files/server5.ku-ke.crt" \
  4922. "$P_CLI" \
  4923. 1 \
  4924. -C "Ciphersuite is "
  4925. # Tests for keyUsage in leaf certificates, part 2:
  4926. # client-side checking of server cert
  4927. run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
  4928. "$O_SRV -key data_files/server2.key \
  4929. -cert data_files/server2.ku-ds_ke.crt" \
  4930. "$P_CLI debug_level=1 \
  4931. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  4932. 0 \
  4933. -C "bad certificate (usage extensions)" \
  4934. -C "Processing of the Certificate handshake message failed" \
  4935. -c "Ciphersuite is TLS-"
  4936. run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
  4937. "$O_SRV -key data_files/server2.key \
  4938. -cert data_files/server2.ku-ds_ke.crt" \
  4939. "$P_CLI debug_level=1 \
  4940. force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
  4941. 0 \
  4942. -C "bad certificate (usage extensions)" \
  4943. -C "Processing of the Certificate handshake message failed" \
  4944. -c "Ciphersuite is TLS-"
  4945. run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
  4946. "$O_SRV -key data_files/server2.key \
  4947. -cert data_files/server2.ku-ke.crt" \
  4948. "$P_CLI debug_level=1 \
  4949. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  4950. 0 \
  4951. -C "bad certificate (usage extensions)" \
  4952. -C "Processing of the Certificate handshake message failed" \
  4953. -c "Ciphersuite is TLS-"
  4954. run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
  4955. "$O_SRV -key data_files/server2.key \
  4956. -cert data_files/server2.ku-ke.crt" \
  4957. "$P_CLI debug_level=1 \
  4958. force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
  4959. 1 \
  4960. -c "bad certificate (usage extensions)" \
  4961. -c "Processing of the Certificate handshake message failed" \
  4962. -C "Ciphersuite is TLS-"
  4963. run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
  4964. "$O_SRV -key data_files/server2.key \
  4965. -cert data_files/server2.ku-ke.crt" \
  4966. "$P_CLI debug_level=1 auth_mode=optional \
  4967. force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
  4968. 0 \
  4969. -c "bad certificate (usage extensions)" \
  4970. -C "Processing of the Certificate handshake message failed" \
  4971. -c "Ciphersuite is TLS-" \
  4972. -c "! Usage does not match the keyUsage extension"
  4973. run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
  4974. "$O_SRV -key data_files/server2.key \
  4975. -cert data_files/server2.ku-ds.crt" \
  4976. "$P_CLI debug_level=1 \
  4977. force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
  4978. 0 \
  4979. -C "bad certificate (usage extensions)" \
  4980. -C "Processing of the Certificate handshake message failed" \
  4981. -c "Ciphersuite is TLS-"
  4982. run_test "keyUsage cli: DigitalSignature, RSA: fail" \
  4983. "$O_SRV -key data_files/server2.key \
  4984. -cert data_files/server2.ku-ds.crt" \
  4985. "$P_CLI debug_level=1 \
  4986. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  4987. 1 \
  4988. -c "bad certificate (usage extensions)" \
  4989. -c "Processing of the Certificate handshake message failed" \
  4990. -C "Ciphersuite is TLS-"
  4991. run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
  4992. "$O_SRV -key data_files/server2.key \
  4993. -cert data_files/server2.ku-ds.crt" \
  4994. "$P_CLI debug_level=1 auth_mode=optional \
  4995. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  4996. 0 \
  4997. -c "bad certificate (usage extensions)" \
  4998. -C "Processing of the Certificate handshake message failed" \
  4999. -c "Ciphersuite is TLS-" \
  5000. -c "! Usage does not match the keyUsage extension"
  5001. # Tests for keyUsage in leaf certificates, part 3:
  5002. # server-side checking of client cert
  5003. run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
  5004. "$P_SRV debug_level=1 auth_mode=optional" \
  5005. "$O_CLI -key data_files/server2.key \
  5006. -cert data_files/server2.ku-ds.crt" \
  5007. 0 \
  5008. -S "bad certificate (usage extensions)" \
  5009. -S "Processing of the Certificate handshake message failed"
  5010. run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
  5011. "$P_SRV debug_level=1 auth_mode=optional" \
  5012. "$O_CLI -key data_files/server2.key \
  5013. -cert data_files/server2.ku-ke.crt" \
  5014. 0 \
  5015. -s "bad certificate (usage extensions)" \
  5016. -S "Processing of the Certificate handshake message failed"
  5017. run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
  5018. "$P_SRV debug_level=1 auth_mode=required" \
  5019. "$O_CLI -key data_files/server2.key \
  5020. -cert data_files/server2.ku-ke.crt" \
  5021. 1 \
  5022. -s "bad certificate (usage extensions)" \
  5023. -s "Processing of the Certificate handshake message failed"
  5024. run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
  5025. "$P_SRV debug_level=1 auth_mode=optional" \
  5026. "$O_CLI -key data_files/server5.key \
  5027. -cert data_files/server5.ku-ds.crt" \
  5028. 0 \
  5029. -S "bad certificate (usage extensions)" \
  5030. -S "Processing of the Certificate handshake message failed"
  5031. run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
  5032. "$P_SRV debug_level=1 auth_mode=optional" \
  5033. "$O_CLI -key data_files/server5.key \
  5034. -cert data_files/server5.ku-ka.crt" \
  5035. 0 \
  5036. -s "bad certificate (usage extensions)" \
  5037. -S "Processing of the Certificate handshake message failed"
  5038. # Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
  5039. run_test "extKeyUsage srv: serverAuth -> OK" \
  5040. "$P_SRV key_file=data_files/server5.key \
  5041. crt_file=data_files/server5.eku-srv.crt" \
  5042. "$P_CLI" \
  5043. 0
  5044. run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
  5045. "$P_SRV key_file=data_files/server5.key \
  5046. crt_file=data_files/server5.eku-srv.crt" \
  5047. "$P_CLI" \
  5048. 0
  5049. run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
  5050. "$P_SRV key_file=data_files/server5.key \
  5051. crt_file=data_files/server5.eku-cs_any.crt" \
  5052. "$P_CLI" \
  5053. 0
  5054. run_test "extKeyUsage srv: codeSign -> fail" \
  5055. "$P_SRV key_file=data_files/server5.key \
  5056. crt_file=data_files/server5.eku-cli.crt" \
  5057. "$P_CLI" \
  5058. 1
  5059. # Tests for extendedKeyUsage, part 2: client-side checking of server cert
  5060. run_test "extKeyUsage cli: serverAuth -> OK" \
  5061. "$O_SRV -key data_files/server5.key \
  5062. -cert data_files/server5.eku-srv.crt" \
  5063. "$P_CLI debug_level=1" \
  5064. 0 \
  5065. -C "bad certificate (usage extensions)" \
  5066. -C "Processing of the Certificate handshake message failed" \
  5067. -c "Ciphersuite is TLS-"
  5068. run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
  5069. "$O_SRV -key data_files/server5.key \
  5070. -cert data_files/server5.eku-srv_cli.crt" \
  5071. "$P_CLI debug_level=1" \
  5072. 0 \
  5073. -C "bad certificate (usage extensions)" \
  5074. -C "Processing of the Certificate handshake message failed" \
  5075. -c "Ciphersuite is TLS-"
  5076. run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
  5077. "$O_SRV -key data_files/server5.key \
  5078. -cert data_files/server5.eku-cs_any.crt" \
  5079. "$P_CLI debug_level=1" \
  5080. 0 \
  5081. -C "bad certificate (usage extensions)" \
  5082. -C "Processing of the Certificate handshake message failed" \
  5083. -c "Ciphersuite is TLS-"
  5084. run_test "extKeyUsage cli: codeSign -> fail" \
  5085. "$O_SRV -key data_files/server5.key \
  5086. -cert data_files/server5.eku-cs.crt" \
  5087. "$P_CLI debug_level=1" \
  5088. 1 \
  5089. -c "bad certificate (usage extensions)" \
  5090. -c "Processing of the Certificate handshake message failed" \
  5091. -C "Ciphersuite is TLS-"
  5092. # Tests for extendedKeyUsage, part 3: server-side checking of client cert
  5093. run_test "extKeyUsage cli-auth: clientAuth -> OK" \
  5094. "$P_SRV debug_level=1 auth_mode=optional" \
  5095. "$O_CLI -key data_files/server5.key \
  5096. -cert data_files/server5.eku-cli.crt" \
  5097. 0 \
  5098. -S "bad certificate (usage extensions)" \
  5099. -S "Processing of the Certificate handshake message failed"
  5100. run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
  5101. "$P_SRV debug_level=1 auth_mode=optional" \
  5102. "$O_CLI -key data_files/server5.key \
  5103. -cert data_files/server5.eku-srv_cli.crt" \
  5104. 0 \
  5105. -S "bad certificate (usage extensions)" \
  5106. -S "Processing of the Certificate handshake message failed"
  5107. run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
  5108. "$P_SRV debug_level=1 auth_mode=optional" \
  5109. "$O_CLI -key data_files/server5.key \
  5110. -cert data_files/server5.eku-cs_any.crt" \
  5111. 0 \
  5112. -S "bad certificate (usage extensions)" \
  5113. -S "Processing of the Certificate handshake message failed"
  5114. run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
  5115. "$P_SRV debug_level=1 auth_mode=optional" \
  5116. "$O_CLI -key data_files/server5.key \
  5117. -cert data_files/server5.eku-cs.crt" \
  5118. 0 \
  5119. -s "bad certificate (usage extensions)" \
  5120. -S "Processing of the Certificate handshake message failed"
  5121. run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
  5122. "$P_SRV debug_level=1 auth_mode=required" \
  5123. "$O_CLI -key data_files/server5.key \
  5124. -cert data_files/server5.eku-cs.crt" \
  5125. 1 \
  5126. -s "bad certificate (usage extensions)" \
  5127. -s "Processing of the Certificate handshake message failed"
  5128. # Tests for DHM parameters loading
  5129. run_test "DHM parameters: reference" \
  5130. "$P_SRV" \
  5131. "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
  5132. debug_level=3" \
  5133. 0 \
  5134. -c "value of 'DHM: P ' (2048 bits)" \
  5135. -c "value of 'DHM: G ' (2 bits)"
  5136. run_test "DHM parameters: other parameters" \
  5137. "$P_SRV dhm_file=data_files/dhparams.pem" \
  5138. "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
  5139. debug_level=3" \
  5140. 0 \
  5141. -c "value of 'DHM: P ' (1024 bits)" \
  5142. -c "value of 'DHM: G ' (2 bits)"
  5143. # Tests for DHM client-side size checking
  5144. run_test "DHM size: server default, client default, OK" \
  5145. "$P_SRV" \
  5146. "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
  5147. debug_level=1" \
  5148. 0 \
  5149. -C "DHM prime too short:"
  5150. run_test "DHM size: server default, client 2048, OK" \
  5151. "$P_SRV" \
  5152. "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
  5153. debug_level=1 dhmlen=2048" \
  5154. 0 \
  5155. -C "DHM prime too short:"
  5156. run_test "DHM size: server 1024, client default, OK" \
  5157. "$P_SRV dhm_file=data_files/dhparams.pem" \
  5158. "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
  5159. debug_level=1" \
  5160. 0 \
  5161. -C "DHM prime too short:"
  5162. run_test "DHM size: server 999, client 999, OK" \
  5163. "$P_SRV dhm_file=data_files/dh.999.pem" \
  5164. "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
  5165. debug_level=1 dhmlen=999" \
  5166. 0 \
  5167. -C "DHM prime too short:"
  5168. run_test "DHM size: server 1000, client 1000, OK" \
  5169. "$P_SRV dhm_file=data_files/dh.1000.pem" \
  5170. "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
  5171. debug_level=1 dhmlen=1000" \
  5172. 0 \
  5173. -C "DHM prime too short:"
  5174. run_test "DHM size: server 1000, client default, rejected" \
  5175. "$P_SRV dhm_file=data_files/dh.1000.pem" \
  5176. "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
  5177. debug_level=1" \
  5178. 1 \
  5179. -c "DHM prime too short:"
  5180. run_test "DHM size: server 1000, client 1001, rejected" \
  5181. "$P_SRV dhm_file=data_files/dh.1000.pem" \
  5182. "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
  5183. debug_level=1 dhmlen=1001" \
  5184. 1 \
  5185. -c "DHM prime too short:"
  5186. run_test "DHM size: server 999, client 1000, rejected" \
  5187. "$P_SRV dhm_file=data_files/dh.999.pem" \
  5188. "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
  5189. debug_level=1 dhmlen=1000" \
  5190. 1 \
  5191. -c "DHM prime too short:"
  5192. run_test "DHM size: server 998, client 999, rejected" \
  5193. "$P_SRV dhm_file=data_files/dh.998.pem" \
  5194. "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
  5195. debug_level=1 dhmlen=999" \
  5196. 1 \
  5197. -c "DHM prime too short:"
  5198. run_test "DHM size: server default, client 2049, rejected" \
  5199. "$P_SRV" \
  5200. "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
  5201. debug_level=1 dhmlen=2049" \
  5202. 1 \
  5203. -c "DHM prime too short:"
  5204. # Tests for PSK callback
  5205. run_test "PSK callback: psk, no callback" \
  5206. "$P_SRV psk=abc123 psk_identity=foo" \
  5207. "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5208. psk_identity=foo psk=abc123" \
  5209. 0 \
  5210. -S "SSL - None of the common ciphersuites is usable" \
  5211. -S "SSL - Unknown identity received" \
  5212. -S "SSL - Verification of the message MAC failed"
  5213. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5214. run_test "PSK callback: opaque psk on client, no callback" \
  5215. "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
  5216. "$P_CLI extended_ms=0 debug_level=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5217. psk_identity=foo psk=abc123 psk_opaque=1" \
  5218. 0 \
  5219. -c "skip PMS generation for opaque PSK"\
  5220. -S "skip PMS generation for opaque PSK"\
  5221. -C "session hash for extended master secret"\
  5222. -S "session hash for extended master secret"\
  5223. -S "SSL - None of the common ciphersuites is usable" \
  5224. -S "SSL - Unknown identity received" \
  5225. -S "SSL - Verification of the message MAC failed"
  5226. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5227. run_test "PSK callback: opaque psk on client, no callback, SHA-384" \
  5228. "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
  5229. "$P_CLI extended_ms=0 debug_level=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
  5230. psk_identity=foo psk=abc123 psk_opaque=1" \
  5231. 0 \
  5232. -c "skip PMS generation for opaque PSK"\
  5233. -S "skip PMS generation for opaque PSK"\
  5234. -C "session hash for extended master secret"\
  5235. -S "session hash for extended master secret"\
  5236. -S "SSL - None of the common ciphersuites is usable" \
  5237. -S "SSL - Unknown identity received" \
  5238. -S "SSL - Verification of the message MAC failed"
  5239. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5240. run_test "PSK callback: opaque psk on client, no callback, EMS" \
  5241. "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
  5242. "$P_CLI extended_ms=1 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5243. psk_identity=foo psk=abc123 psk_opaque=1" \
  5244. 0 \
  5245. -c "skip PMS generation for opaque PSK"\
  5246. -S "skip PMS generation for opaque PSK"\
  5247. -c "session hash for extended master secret"\
  5248. -s "session hash for extended master secret"\
  5249. -S "SSL - None of the common ciphersuites is usable" \
  5250. -S "SSL - Unknown identity received" \
  5251. -S "SSL - Verification of the message MAC failed"
  5252. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5253. run_test "PSK callback: opaque psk on client, no callback, SHA-384, EMS" \
  5254. "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
  5255. "$P_CLI extended_ms=1 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
  5256. psk_identity=foo psk=abc123 psk_opaque=1" \
  5257. 0 \
  5258. -c "skip PMS generation for opaque PSK"\
  5259. -S "skip PMS generation for opaque PSK"\
  5260. -c "session hash for extended master secret"\
  5261. -s "session hash for extended master secret"\
  5262. -S "SSL - None of the common ciphersuites is usable" \
  5263. -S "SSL - Unknown identity received" \
  5264. -S "SSL - Verification of the message MAC failed"
  5265. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5266. run_test "PSK callback: raw psk on client, static opaque on server, no callback" \
  5267. "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
  5268. "$P_CLI extended_ms=0 debug_level=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5269. psk_identity=foo psk=abc123" \
  5270. 0 \
  5271. -C "skip PMS generation for opaque PSK"\
  5272. -s "skip PMS generation for opaque PSK"\
  5273. -C "session hash for extended master secret"\
  5274. -S "session hash for extended master secret"\
  5275. -S "SSL - None of the common ciphersuites is usable" \
  5276. -S "SSL - Unknown identity received" \
  5277. -S "SSL - Verification of the message MAC failed"
  5278. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5279. run_test "PSK callback: raw psk on client, static opaque on server, no callback, SHA-384" \
  5280. "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384" \
  5281. "$P_CLI extended_ms=0 debug_level=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
  5282. psk_identity=foo psk=abc123" \
  5283. 0 \
  5284. -C "skip PMS generation for opaque PSK"\
  5285. -s "skip PMS generation for opaque PSK"\
  5286. -C "session hash for extended master secret"\
  5287. -S "session hash for extended master secret"\
  5288. -S "SSL - None of the common ciphersuites is usable" \
  5289. -S "SSL - Unknown identity received" \
  5290. -S "SSL - Verification of the message MAC failed"
  5291. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5292. run_test "PSK callback: raw psk on client, static opaque on server, no callback, EMS" \
  5293. "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls12 \
  5294. force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \
  5295. "$P_CLI debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5296. psk_identity=foo psk=abc123 extended_ms=1" \
  5297. 0 \
  5298. -c "session hash for extended master secret"\
  5299. -s "session hash for extended master secret"\
  5300. -C "skip PMS generation for opaque PSK"\
  5301. -s "skip PMS generation for opaque PSK"\
  5302. -S "SSL - None of the common ciphersuites is usable" \
  5303. -S "SSL - Unknown identity received" \
  5304. -S "SSL - Verification of the message MAC failed"
  5305. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5306. run_test "PSK callback: raw psk on client, static opaque on server, no callback, EMS, SHA384" \
  5307. "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls12 \
  5308. force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \
  5309. "$P_CLI debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
  5310. psk_identity=foo psk=abc123 extended_ms=1" \
  5311. 0 \
  5312. -c "session hash for extended master secret"\
  5313. -s "session hash for extended master secret"\
  5314. -C "skip PMS generation for opaque PSK"\
  5315. -s "skip PMS generation for opaque PSK"\
  5316. -S "SSL - None of the common ciphersuites is usable" \
  5317. -S "SSL - Unknown identity received" \
  5318. -S "SSL - Verification of the message MAC failed"
  5319. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5320. run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback" \
  5321. "$P_SRV extended_ms=0 debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
  5322. "$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5323. psk_identity=def psk=beef" \
  5324. 0 \
  5325. -C "skip PMS generation for opaque PSK"\
  5326. -s "skip PMS generation for opaque PSK"\
  5327. -C "session hash for extended master secret"\
  5328. -S "session hash for extended master secret"\
  5329. -S "SSL - None of the common ciphersuites is usable" \
  5330. -S "SSL - Unknown identity received" \
  5331. -S "SSL - Verification of the message MAC failed"
  5332. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5333. run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, SHA-384" \
  5334. "$P_SRV extended_ms=0 debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384" \
  5335. "$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
  5336. psk_identity=def psk=beef" \
  5337. 0 \
  5338. -C "skip PMS generation for opaque PSK"\
  5339. -s "skip PMS generation for opaque PSK"\
  5340. -C "session hash for extended master secret"\
  5341. -S "session hash for extended master secret"\
  5342. -S "SSL - None of the common ciphersuites is usable" \
  5343. -S "SSL - Unknown identity received" \
  5344. -S "SSL - Verification of the message MAC failed"
  5345. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5346. run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, EMS" \
  5347. "$P_SRV debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls12 \
  5348. force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \
  5349. "$P_CLI debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5350. psk_identity=abc psk=dead extended_ms=1" \
  5351. 0 \
  5352. -c "session hash for extended master secret"\
  5353. -s "session hash for extended master secret"\
  5354. -C "skip PMS generation for opaque PSK"\
  5355. -s "skip PMS generation for opaque PSK"\
  5356. -S "SSL - None of the common ciphersuites is usable" \
  5357. -S "SSL - Unknown identity received" \
  5358. -S "SSL - Verification of the message MAC failed"
  5359. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5360. run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, EMS, SHA384" \
  5361. "$P_SRV debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls12 \
  5362. force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \
  5363. "$P_CLI debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
  5364. psk_identity=abc psk=dead extended_ms=1" \
  5365. 0 \
  5366. -c "session hash for extended master secret"\
  5367. -s "session hash for extended master secret"\
  5368. -C "skip PMS generation for opaque PSK"\
  5369. -s "skip PMS generation for opaque PSK"\
  5370. -S "SSL - None of the common ciphersuites is usable" \
  5371. -S "SSL - Unknown identity received" \
  5372. -S "SSL - Verification of the message MAC failed"
  5373. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5374. run_test "PSK callback: raw psk on client, mismatching static raw PSK on server, opaque PSK from callback" \
  5375. "$P_SRV extended_ms=0 psk_identity=foo psk=abc123 debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
  5376. "$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5377. psk_identity=def psk=beef" \
  5378. 0 \
  5379. -C "skip PMS generation for opaque PSK"\
  5380. -s "skip PMS generation for opaque PSK"\
  5381. -C "session hash for extended master secret"\
  5382. -S "session hash for extended master secret"\
  5383. -S "SSL - None of the common ciphersuites is usable" \
  5384. -S "SSL - Unknown identity received" \
  5385. -S "SSL - Verification of the message MAC failed"
  5386. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5387. run_test "PSK callback: raw psk on client, mismatching static opaque PSK on server, opaque PSK from callback" \
  5388. "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=foo psk=abc123 debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
  5389. "$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5390. psk_identity=def psk=beef" \
  5391. 0 \
  5392. -C "skip PMS generation for opaque PSK"\
  5393. -s "skip PMS generation for opaque PSK"\
  5394. -C "session hash for extended master secret"\
  5395. -S "session hash for extended master secret"\
  5396. -S "SSL - None of the common ciphersuites is usable" \
  5397. -S "SSL - Unknown identity received" \
  5398. -S "SSL - Verification of the message MAC failed"
  5399. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5400. run_test "PSK callback: raw psk on client, mismatching static opaque PSK on server, raw PSK from callback" \
  5401. "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=foo psk=abc123 debug_level=3 psk_list=abc,dead,def,beef min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
  5402. "$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5403. psk_identity=def psk=beef" \
  5404. 0 \
  5405. -C "skip PMS generation for opaque PSK"\
  5406. -C "session hash for extended master secret"\
  5407. -S "session hash for extended master secret"\
  5408. -S "SSL - None of the common ciphersuites is usable" \
  5409. -S "SSL - Unknown identity received" \
  5410. -S "SSL - Verification of the message MAC failed"
  5411. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5412. run_test "PSK callback: raw psk on client, id-matching but wrong raw PSK on server, opaque PSK from callback" \
  5413. "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=def psk=abc123 debug_level=3 psk_list=abc,dead,def,beef min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
  5414. "$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5415. psk_identity=def psk=beef" \
  5416. 0 \
  5417. -C "skip PMS generation for opaque PSK"\
  5418. -C "session hash for extended master secret"\
  5419. -S "session hash for extended master secret"\
  5420. -S "SSL - None of the common ciphersuites is usable" \
  5421. -S "SSL - Unknown identity received" \
  5422. -S "SSL - Verification of the message MAC failed"
  5423. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5424. run_test "PSK callback: raw psk on client, matching opaque PSK on server, wrong opaque PSK from callback" \
  5425. "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=def psk=beef debug_level=3 psk_list=abc,dead,def,abc123 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
  5426. "$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5427. psk_identity=def psk=beef" \
  5428. 1 \
  5429. -s "SSL - Verification of the message MAC failed"
  5430. run_test "PSK callback: no psk, no callback" \
  5431. "$P_SRV" \
  5432. "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5433. psk_identity=foo psk=abc123" \
  5434. 1 \
  5435. -s "SSL - None of the common ciphersuites is usable" \
  5436. -S "SSL - Unknown identity received" \
  5437. -S "SSL - Verification of the message MAC failed"
  5438. run_test "PSK callback: callback overrides other settings" \
  5439. "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
  5440. "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5441. psk_identity=foo psk=abc123" \
  5442. 1 \
  5443. -S "SSL - None of the common ciphersuites is usable" \
  5444. -s "SSL - Unknown identity received" \
  5445. -S "SSL - Verification of the message MAC failed"
  5446. run_test "PSK callback: first id matches" \
  5447. "$P_SRV psk_list=abc,dead,def,beef" \
  5448. "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5449. psk_identity=abc psk=dead" \
  5450. 0 \
  5451. -S "SSL - None of the common ciphersuites is usable" \
  5452. -S "SSL - Unknown identity received" \
  5453. -S "SSL - Verification of the message MAC failed"
  5454. run_test "PSK callback: second id matches" \
  5455. "$P_SRV psk_list=abc,dead,def,beef" \
  5456. "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5457. psk_identity=def psk=beef" \
  5458. 0 \
  5459. -S "SSL - None of the common ciphersuites is usable" \
  5460. -S "SSL - Unknown identity received" \
  5461. -S "SSL - Verification of the message MAC failed"
  5462. run_test "PSK callback: no match" \
  5463. "$P_SRV psk_list=abc,dead,def,beef" \
  5464. "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5465. psk_identity=ghi psk=beef" \
  5466. 1 \
  5467. -S "SSL - None of the common ciphersuites is usable" \
  5468. -s "SSL - Unknown identity received" \
  5469. -S "SSL - Verification of the message MAC failed"
  5470. run_test "PSK callback: wrong key" \
  5471. "$P_SRV psk_list=abc,dead,def,beef" \
  5472. "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5473. psk_identity=abc psk=beef" \
  5474. 1 \
  5475. -S "SSL - None of the common ciphersuites is usable" \
  5476. -S "SSL - Unknown identity received" \
  5477. -s "SSL - Verification of the message MAC failed"
  5478. # Tests for EC J-PAKE
  5479. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
  5480. run_test "ECJPAKE: client not configured" \
  5481. "$P_SRV debug_level=3" \
  5482. "$P_CLI debug_level=3" \
  5483. 0 \
  5484. -C "add ciphersuite: 0xc0ff" \
  5485. -C "adding ecjpake_kkpp extension" \
  5486. -S "found ecjpake kkpp extension" \
  5487. -S "skip ecjpake kkpp extension" \
  5488. -S "ciphersuite mismatch: ecjpake not configured" \
  5489. -S "server hello, ecjpake kkpp extension" \
  5490. -C "found ecjpake_kkpp extension" \
  5491. -S "None of the common ciphersuites is usable"
  5492. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
  5493. run_test "ECJPAKE: server not configured" \
  5494. "$P_SRV debug_level=3" \
  5495. "$P_CLI debug_level=3 ecjpake_pw=bla \
  5496. force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
  5497. 1 \
  5498. -c "add ciphersuite: 0xc0ff" \
  5499. -c "adding ecjpake_kkpp extension" \
  5500. -s "found ecjpake kkpp extension" \
  5501. -s "skip ecjpake kkpp extension" \
  5502. -s "ciphersuite mismatch: ecjpake not configured" \
  5503. -S "server hello, ecjpake kkpp extension" \
  5504. -C "found ecjpake_kkpp extension" \
  5505. -s "None of the common ciphersuites is usable"
  5506. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
  5507. run_test "ECJPAKE: working, TLS" \
  5508. "$P_SRV debug_level=3 ecjpake_pw=bla" \
  5509. "$P_CLI debug_level=3 ecjpake_pw=bla \
  5510. force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
  5511. 0 \
  5512. -c "add ciphersuite: 0xc0ff" \
  5513. -c "adding ecjpake_kkpp extension" \
  5514. -C "re-using cached ecjpake parameters" \
  5515. -s "found ecjpake kkpp extension" \
  5516. -S "skip ecjpake kkpp extension" \
  5517. -S "ciphersuite mismatch: ecjpake not configured" \
  5518. -s "server hello, ecjpake kkpp extension" \
  5519. -c "found ecjpake_kkpp extension" \
  5520. -S "None of the common ciphersuites is usable" \
  5521. -S "SSL - Verification of the message MAC failed"
  5522. server_needs_more_time 1
  5523. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
  5524. run_test "ECJPAKE: password mismatch, TLS" \
  5525. "$P_SRV debug_level=3 ecjpake_pw=bla" \
  5526. "$P_CLI debug_level=3 ecjpake_pw=bad \
  5527. force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
  5528. 1 \
  5529. -C "re-using cached ecjpake parameters" \
  5530. -s "SSL - Verification of the message MAC failed"
  5531. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
  5532. run_test "ECJPAKE: working, DTLS" \
  5533. "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
  5534. "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
  5535. force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
  5536. 0 \
  5537. -c "re-using cached ecjpake parameters" \
  5538. -S "SSL - Verification of the message MAC failed"
  5539. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
  5540. run_test "ECJPAKE: working, DTLS, no cookie" \
  5541. "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
  5542. "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
  5543. force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
  5544. 0 \
  5545. -C "re-using cached ecjpake parameters" \
  5546. -S "SSL - Verification of the message MAC failed"
  5547. server_needs_more_time 1
  5548. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
  5549. run_test "ECJPAKE: password mismatch, DTLS" \
  5550. "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
  5551. "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
  5552. force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
  5553. 1 \
  5554. -c "re-using cached ecjpake parameters" \
  5555. -s "SSL - Verification of the message MAC failed"
  5556. # for tests with configs/config-thread.h
  5557. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
  5558. run_test "ECJPAKE: working, DTLS, nolog" \
  5559. "$P_SRV dtls=1 ecjpake_pw=bla" \
  5560. "$P_CLI dtls=1 ecjpake_pw=bla \
  5561. force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
  5562. 0
  5563. # Tests for ciphersuites per version
  5564. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  5565. requires_config_enabled MBEDTLS_CAMELLIA_C
  5566. requires_config_enabled MBEDTLS_AES_C
  5567. run_test "Per-version suites: SSL3" \
  5568. "$P_SRV min_version=ssl3 version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
  5569. "$P_CLI force_version=ssl3" \
  5570. 0 \
  5571. -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
  5572. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
  5573. requires_config_enabled MBEDTLS_CAMELLIA_C
  5574. requires_config_enabled MBEDTLS_AES_C
  5575. run_test "Per-version suites: TLS 1.0" \
  5576. "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
  5577. "$P_CLI force_version=tls1 arc4=1" \
  5578. 0 \
  5579. -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
  5580. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
  5581. requires_config_enabled MBEDTLS_CAMELLIA_C
  5582. requires_config_enabled MBEDTLS_AES_C
  5583. run_test "Per-version suites: TLS 1.1" \
  5584. "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
  5585. "$P_CLI force_version=tls1_1" \
  5586. 0 \
  5587. -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
  5588. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
  5589. requires_config_enabled MBEDTLS_CAMELLIA_C
  5590. requires_config_enabled MBEDTLS_AES_C
  5591. run_test "Per-version suites: TLS 1.2" \
  5592. "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
  5593. "$P_CLI force_version=tls12" \
  5594. 0 \
  5595. -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
  5596. # Test for ClientHello without extensions
  5597. requires_gnutls
  5598. run_test "ClientHello without extensions" \
  5599. "$P_SRV debug_level=3" \
  5600. "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
  5601. 0 \
  5602. -s "dumping 'client hello extensions' (0 bytes)"
  5603. # Tests for mbedtls_ssl_get_bytes_avail()
  5604. run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
  5605. "$P_SRV" \
  5606. "$P_CLI request_size=100" \
  5607. 0 \
  5608. -s "Read from client: 100 bytes read$"
  5609. run_test "mbedtls_ssl_get_bytes_avail: extra data" \
  5610. "$P_SRV" \
  5611. "$P_CLI request_size=500" \
  5612. 0 \
  5613. -s "Read from client: 500 bytes read (.*+.*)"
  5614. # Tests for small client packets
  5615. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  5616. run_test "Small client packet SSLv3 BlockCipher" \
  5617. "$P_SRV min_version=ssl3" \
  5618. "$P_CLI request_size=1 force_version=ssl3 \
  5619. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5620. 0 \
  5621. -s "Read from client: 1 bytes read"
  5622. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  5623. run_test "Small client packet SSLv3 StreamCipher" \
  5624. "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5625. "$P_CLI request_size=1 force_version=ssl3 \
  5626. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5627. 0 \
  5628. -s "Read from client: 1 bytes read"
  5629. run_test "Small client packet TLS 1.0 BlockCipher" \
  5630. "$P_SRV" \
  5631. "$P_CLI request_size=1 force_version=tls1 \
  5632. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5633. 0 \
  5634. -s "Read from client: 1 bytes read"
  5635. run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
  5636. "$P_SRV" \
  5637. "$P_CLI request_size=1 force_version=tls1 etm=0 \
  5638. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5639. 0 \
  5640. -s "Read from client: 1 bytes read"
  5641. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5642. run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
  5643. "$P_SRV trunc_hmac=1" \
  5644. "$P_CLI request_size=1 force_version=tls1 \
  5645. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  5646. 0 \
  5647. -s "Read from client: 1 bytes read"
  5648. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5649. run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
  5650. "$P_SRV trunc_hmac=1" \
  5651. "$P_CLI request_size=1 force_version=tls1 \
  5652. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
  5653. 0 \
  5654. -s "Read from client: 1 bytes read"
  5655. run_test "Small client packet TLS 1.0 StreamCipher" \
  5656. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5657. "$P_CLI request_size=1 force_version=tls1 \
  5658. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5659. 0 \
  5660. -s "Read from client: 1 bytes read"
  5661. run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
  5662. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5663. "$P_CLI request_size=1 force_version=tls1 \
  5664. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  5665. 0 \
  5666. -s "Read from client: 1 bytes read"
  5667. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5668. run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
  5669. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5670. "$P_CLI request_size=1 force_version=tls1 \
  5671. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5672. 0 \
  5673. -s "Read from client: 1 bytes read"
  5674. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5675. run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
  5676. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5677. "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
  5678. trunc_hmac=1 etm=0" \
  5679. 0 \
  5680. -s "Read from client: 1 bytes read"
  5681. run_test "Small client packet TLS 1.1 BlockCipher" \
  5682. "$P_SRV" \
  5683. "$P_CLI request_size=1 force_version=tls1_1 \
  5684. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5685. 0 \
  5686. -s "Read from client: 1 bytes read"
  5687. run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
  5688. "$P_SRV" \
  5689. "$P_CLI request_size=1 force_version=tls1_1 \
  5690. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
  5691. 0 \
  5692. -s "Read from client: 1 bytes read"
  5693. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5694. run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
  5695. "$P_SRV trunc_hmac=1" \
  5696. "$P_CLI request_size=1 force_version=tls1_1 \
  5697. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  5698. 0 \
  5699. -s "Read from client: 1 bytes read"
  5700. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5701. run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
  5702. "$P_SRV trunc_hmac=1" \
  5703. "$P_CLI request_size=1 force_version=tls1_1 \
  5704. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
  5705. 0 \
  5706. -s "Read from client: 1 bytes read"
  5707. run_test "Small client packet TLS 1.1 StreamCipher" \
  5708. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5709. "$P_CLI request_size=1 force_version=tls1_1 \
  5710. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5711. 0 \
  5712. -s "Read from client: 1 bytes read"
  5713. run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
  5714. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5715. "$P_CLI request_size=1 force_version=tls1_1 \
  5716. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  5717. 0 \
  5718. -s "Read from client: 1 bytes read"
  5719. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5720. run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
  5721. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5722. "$P_CLI request_size=1 force_version=tls1_1 \
  5723. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5724. 0 \
  5725. -s "Read from client: 1 bytes read"
  5726. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5727. run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
  5728. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5729. "$P_CLI request_size=1 force_version=tls1_1 \
  5730. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
  5731. 0 \
  5732. -s "Read from client: 1 bytes read"
  5733. run_test "Small client packet TLS 1.2 BlockCipher" \
  5734. "$P_SRV" \
  5735. "$P_CLI request_size=1 force_version=tls12 \
  5736. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5737. 0 \
  5738. -s "Read from client: 1 bytes read"
  5739. run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
  5740. "$P_SRV" \
  5741. "$P_CLI request_size=1 force_version=tls12 \
  5742. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
  5743. 0 \
  5744. -s "Read from client: 1 bytes read"
  5745. run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
  5746. "$P_SRV" \
  5747. "$P_CLI request_size=1 force_version=tls12 \
  5748. force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
  5749. 0 \
  5750. -s "Read from client: 1 bytes read"
  5751. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5752. run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
  5753. "$P_SRV trunc_hmac=1" \
  5754. "$P_CLI request_size=1 force_version=tls12 \
  5755. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  5756. 0 \
  5757. -s "Read from client: 1 bytes read"
  5758. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5759. run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
  5760. "$P_SRV trunc_hmac=1" \
  5761. "$P_CLI request_size=1 force_version=tls12 \
  5762. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
  5763. 0 \
  5764. -s "Read from client: 1 bytes read"
  5765. run_test "Small client packet TLS 1.2 StreamCipher" \
  5766. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5767. "$P_CLI request_size=1 force_version=tls12 \
  5768. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5769. 0 \
  5770. -s "Read from client: 1 bytes read"
  5771. run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
  5772. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5773. "$P_CLI request_size=1 force_version=tls12 \
  5774. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  5775. 0 \
  5776. -s "Read from client: 1 bytes read"
  5777. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5778. run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
  5779. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5780. "$P_CLI request_size=1 force_version=tls12 \
  5781. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5782. 0 \
  5783. -s "Read from client: 1 bytes read"
  5784. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5785. run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
  5786. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5787. "$P_CLI request_size=1 force_version=tls12 \
  5788. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
  5789. 0 \
  5790. -s "Read from client: 1 bytes read"
  5791. run_test "Small client packet TLS 1.2 AEAD" \
  5792. "$P_SRV" \
  5793. "$P_CLI request_size=1 force_version=tls12 \
  5794. force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
  5795. 0 \
  5796. -s "Read from client: 1 bytes read"
  5797. run_test "Small client packet TLS 1.2 AEAD shorter tag" \
  5798. "$P_SRV" \
  5799. "$P_CLI request_size=1 force_version=tls12 \
  5800. force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
  5801. 0 \
  5802. -s "Read from client: 1 bytes read"
  5803. # Tests for small client packets in DTLS
  5804. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5805. run_test "Small client packet DTLS 1.0" \
  5806. "$P_SRV dtls=1 force_version=dtls1" \
  5807. "$P_CLI dtls=1 request_size=1 \
  5808. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5809. 0 \
  5810. -s "Read from client: 1 bytes read"
  5811. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5812. run_test "Small client packet DTLS 1.0, without EtM" \
  5813. "$P_SRV dtls=1 force_version=dtls1 etm=0" \
  5814. "$P_CLI dtls=1 request_size=1 \
  5815. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5816. 0 \
  5817. -s "Read from client: 1 bytes read"
  5818. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5819. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5820. run_test "Small client packet DTLS 1.0, truncated hmac" \
  5821. "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
  5822. "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
  5823. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5824. 0 \
  5825. -s "Read from client: 1 bytes read"
  5826. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5827. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5828. run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
  5829. "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
  5830. "$P_CLI dtls=1 request_size=1 \
  5831. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
  5832. 0 \
  5833. -s "Read from client: 1 bytes read"
  5834. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5835. run_test "Small client packet DTLS 1.2" \
  5836. "$P_SRV dtls=1 force_version=dtls12" \
  5837. "$P_CLI dtls=1 request_size=1 \
  5838. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5839. 0 \
  5840. -s "Read from client: 1 bytes read"
  5841. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5842. run_test "Small client packet DTLS 1.2, without EtM" \
  5843. "$P_SRV dtls=1 force_version=dtls12 etm=0" \
  5844. "$P_CLI dtls=1 request_size=1 \
  5845. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5846. 0 \
  5847. -s "Read from client: 1 bytes read"
  5848. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5849. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5850. run_test "Small client packet DTLS 1.2, truncated hmac" \
  5851. "$P_SRV dtls=1 force_version=dtls12 trunc_hmac=1" \
  5852. "$P_CLI dtls=1 request_size=1 \
  5853. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  5854. 0 \
  5855. -s "Read from client: 1 bytes read"
  5856. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5857. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5858. run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
  5859. "$P_SRV dtls=1 force_version=dtls12 trunc_hmac=1 etm=0" \
  5860. "$P_CLI dtls=1 request_size=1 \
  5861. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
  5862. 0 \
  5863. -s "Read from client: 1 bytes read"
  5864. # Tests for small server packets
  5865. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  5866. run_test "Small server packet SSLv3 BlockCipher" \
  5867. "$P_SRV response_size=1 min_version=ssl3" \
  5868. "$P_CLI force_version=ssl3 \
  5869. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5870. 0 \
  5871. -c "Read from server: 1 bytes read"
  5872. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  5873. run_test "Small server packet SSLv3 StreamCipher" \
  5874. "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5875. "$P_CLI force_version=ssl3 \
  5876. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5877. 0 \
  5878. -c "Read from server: 1 bytes read"
  5879. run_test "Small server packet TLS 1.0 BlockCipher" \
  5880. "$P_SRV response_size=1" \
  5881. "$P_CLI force_version=tls1 \
  5882. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5883. 0 \
  5884. -c "Read from server: 1 bytes read"
  5885. run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
  5886. "$P_SRV response_size=1" \
  5887. "$P_CLI force_version=tls1 etm=0 \
  5888. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5889. 0 \
  5890. -c "Read from server: 1 bytes read"
  5891. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5892. run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
  5893. "$P_SRV response_size=1 trunc_hmac=1" \
  5894. "$P_CLI force_version=tls1 \
  5895. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  5896. 0 \
  5897. -c "Read from server: 1 bytes read"
  5898. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5899. run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
  5900. "$P_SRV response_size=1 trunc_hmac=1" \
  5901. "$P_CLI force_version=tls1 \
  5902. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
  5903. 0 \
  5904. -c "Read from server: 1 bytes read"
  5905. run_test "Small server packet TLS 1.0 StreamCipher" \
  5906. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5907. "$P_CLI force_version=tls1 \
  5908. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5909. 0 \
  5910. -c "Read from server: 1 bytes read"
  5911. run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
  5912. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5913. "$P_CLI force_version=tls1 \
  5914. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  5915. 0 \
  5916. -c "Read from server: 1 bytes read"
  5917. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5918. run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
  5919. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5920. "$P_CLI force_version=tls1 \
  5921. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5922. 0 \
  5923. -c "Read from server: 1 bytes read"
  5924. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5925. run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
  5926. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5927. "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
  5928. trunc_hmac=1 etm=0" \
  5929. 0 \
  5930. -c "Read from server: 1 bytes read"
  5931. run_test "Small server packet TLS 1.1 BlockCipher" \
  5932. "$P_SRV response_size=1" \
  5933. "$P_CLI force_version=tls1_1 \
  5934. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5935. 0 \
  5936. -c "Read from server: 1 bytes read"
  5937. run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
  5938. "$P_SRV response_size=1" \
  5939. "$P_CLI force_version=tls1_1 \
  5940. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
  5941. 0 \
  5942. -c "Read from server: 1 bytes read"
  5943. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5944. run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
  5945. "$P_SRV response_size=1 trunc_hmac=1" \
  5946. "$P_CLI force_version=tls1_1 \
  5947. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  5948. 0 \
  5949. -c "Read from server: 1 bytes read"
  5950. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5951. run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
  5952. "$P_SRV response_size=1 trunc_hmac=1" \
  5953. "$P_CLI force_version=tls1_1 \
  5954. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
  5955. 0 \
  5956. -c "Read from server: 1 bytes read"
  5957. run_test "Small server packet TLS 1.1 StreamCipher" \
  5958. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5959. "$P_CLI force_version=tls1_1 \
  5960. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5961. 0 \
  5962. -c "Read from server: 1 bytes read"
  5963. run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
  5964. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5965. "$P_CLI force_version=tls1_1 \
  5966. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  5967. 0 \
  5968. -c "Read from server: 1 bytes read"
  5969. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5970. run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
  5971. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5972. "$P_CLI force_version=tls1_1 \
  5973. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5974. 0 \
  5975. -c "Read from server: 1 bytes read"
  5976. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5977. run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
  5978. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5979. "$P_CLI force_version=tls1_1 \
  5980. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
  5981. 0 \
  5982. -c "Read from server: 1 bytes read"
  5983. run_test "Small server packet TLS 1.2 BlockCipher" \
  5984. "$P_SRV response_size=1" \
  5985. "$P_CLI force_version=tls12 \
  5986. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5987. 0 \
  5988. -c "Read from server: 1 bytes read"
  5989. run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
  5990. "$P_SRV response_size=1" \
  5991. "$P_CLI force_version=tls12 \
  5992. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
  5993. 0 \
  5994. -c "Read from server: 1 bytes read"
  5995. run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
  5996. "$P_SRV response_size=1" \
  5997. "$P_CLI force_version=tls12 \
  5998. force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
  5999. 0 \
  6000. -c "Read from server: 1 bytes read"
  6001. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6002. run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
  6003. "$P_SRV response_size=1 trunc_hmac=1" \
  6004. "$P_CLI force_version=tls12 \
  6005. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  6006. 0 \
  6007. -c "Read from server: 1 bytes read"
  6008. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6009. run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
  6010. "$P_SRV response_size=1 trunc_hmac=1" \
  6011. "$P_CLI force_version=tls12 \
  6012. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
  6013. 0 \
  6014. -c "Read from server: 1 bytes read"
  6015. run_test "Small server packet TLS 1.2 StreamCipher" \
  6016. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6017. "$P_CLI force_version=tls12 \
  6018. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6019. 0 \
  6020. -c "Read from server: 1 bytes read"
  6021. run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
  6022. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6023. "$P_CLI force_version=tls12 \
  6024. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  6025. 0 \
  6026. -c "Read from server: 1 bytes read"
  6027. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6028. run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
  6029. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6030. "$P_CLI force_version=tls12 \
  6031. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6032. 0 \
  6033. -c "Read from server: 1 bytes read"
  6034. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6035. run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
  6036. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6037. "$P_CLI force_version=tls12 \
  6038. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
  6039. 0 \
  6040. -c "Read from server: 1 bytes read"
  6041. run_test "Small server packet TLS 1.2 AEAD" \
  6042. "$P_SRV response_size=1" \
  6043. "$P_CLI force_version=tls12 \
  6044. force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
  6045. 0 \
  6046. -c "Read from server: 1 bytes read"
  6047. run_test "Small server packet TLS 1.2 AEAD shorter tag" \
  6048. "$P_SRV response_size=1" \
  6049. "$P_CLI force_version=tls12 \
  6050. force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
  6051. 0 \
  6052. -c "Read from server: 1 bytes read"
  6053. # Tests for small server packets in DTLS
  6054. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  6055. run_test "Small server packet DTLS 1.0" \
  6056. "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
  6057. "$P_CLI dtls=1 \
  6058. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6059. 0 \
  6060. -c "Read from server: 1 bytes read"
  6061. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  6062. run_test "Small server packet DTLS 1.0, without EtM" \
  6063. "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
  6064. "$P_CLI dtls=1 \
  6065. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6066. 0 \
  6067. -c "Read from server: 1 bytes read"
  6068. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  6069. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6070. run_test "Small server packet DTLS 1.0, truncated hmac" \
  6071. "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
  6072. "$P_CLI dtls=1 trunc_hmac=1 \
  6073. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6074. 0 \
  6075. -c "Read from server: 1 bytes read"
  6076. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  6077. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6078. run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
  6079. "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
  6080. "$P_CLI dtls=1 \
  6081. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
  6082. 0 \
  6083. -c "Read from server: 1 bytes read"
  6084. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  6085. run_test "Small server packet DTLS 1.2" \
  6086. "$P_SRV dtls=1 response_size=1 force_version=dtls12" \
  6087. "$P_CLI dtls=1 \
  6088. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6089. 0 \
  6090. -c "Read from server: 1 bytes read"
  6091. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  6092. run_test "Small server packet DTLS 1.2, without EtM" \
  6093. "$P_SRV dtls=1 response_size=1 force_version=dtls12 etm=0" \
  6094. "$P_CLI dtls=1 \
  6095. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6096. 0 \
  6097. -c "Read from server: 1 bytes read"
  6098. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  6099. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6100. run_test "Small server packet DTLS 1.2, truncated hmac" \
  6101. "$P_SRV dtls=1 response_size=1 force_version=dtls12 trunc_hmac=1" \
  6102. "$P_CLI dtls=1 \
  6103. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  6104. 0 \
  6105. -c "Read from server: 1 bytes read"
  6106. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  6107. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6108. run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
  6109. "$P_SRV dtls=1 response_size=1 force_version=dtls12 trunc_hmac=1 etm=0" \
  6110. "$P_CLI dtls=1 \
  6111. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
  6112. 0 \
  6113. -c "Read from server: 1 bytes read"
  6114. # A test for extensions in SSLv3
  6115. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  6116. requires_max_content_len 4096
  6117. run_test "SSLv3 with extensions, server side" \
  6118. "$P_SRV min_version=ssl3 debug_level=3" \
  6119. "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
  6120. 0 \
  6121. -S "dumping 'client hello extensions'" \
  6122. -S "server hello, total extension length:"
  6123. # Test for large client packets
  6124. # How many fragments do we expect to write $1 bytes?
  6125. fragments_for_write() {
  6126. echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
  6127. }
  6128. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  6129. run_test "Large client packet SSLv3 BlockCipher" \
  6130. "$P_SRV min_version=ssl3" \
  6131. "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
  6132. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6133. 0 \
  6134. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  6135. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6136. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  6137. run_test "Large client packet SSLv3 StreamCipher" \
  6138. "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6139. "$P_CLI request_size=16384 force_version=ssl3 \
  6140. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6141. 0 \
  6142. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  6143. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6144. run_test "Large client packet TLS 1.0 BlockCipher" \
  6145. "$P_SRV" \
  6146. "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
  6147. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6148. 0 \
  6149. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  6150. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6151. run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
  6152. "$P_SRV" \
  6153. "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
  6154. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6155. 0 \
  6156. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6157. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6158. run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
  6159. "$P_SRV trunc_hmac=1" \
  6160. "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
  6161. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  6162. 0 \
  6163. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  6164. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6165. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6166. run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
  6167. "$P_SRV trunc_hmac=1" \
  6168. "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
  6169. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  6170. 0 \
  6171. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6172. run_test "Large client packet TLS 1.0 StreamCipher" \
  6173. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6174. "$P_CLI request_size=16384 force_version=tls1 \
  6175. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6176. 0 \
  6177. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6178. run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
  6179. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6180. "$P_CLI request_size=16384 force_version=tls1 \
  6181. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  6182. 0 \
  6183. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6184. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6185. run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
  6186. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6187. "$P_CLI request_size=16384 force_version=tls1 \
  6188. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6189. 0 \
  6190. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6191. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6192. run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
  6193. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6194. "$P_CLI request_size=16384 force_version=tls1 \
  6195. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
  6196. 0 \
  6197. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  6198. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6199. run_test "Large client packet TLS 1.1 BlockCipher" \
  6200. "$P_SRV" \
  6201. "$P_CLI request_size=16384 force_version=tls1_1 \
  6202. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6203. 0 \
  6204. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  6205. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6206. run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
  6207. "$P_SRV" \
  6208. "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
  6209. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6210. 0 \
  6211. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6212. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6213. run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
  6214. "$P_SRV trunc_hmac=1" \
  6215. "$P_CLI request_size=16384 force_version=tls1_1 \
  6216. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  6217. 0 \
  6218. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6219. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6220. run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
  6221. "$P_SRV trunc_hmac=1" \
  6222. "$P_CLI request_size=16384 force_version=tls1_1 \
  6223. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
  6224. 0 \
  6225. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6226. run_test "Large client packet TLS 1.1 StreamCipher" \
  6227. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6228. "$P_CLI request_size=16384 force_version=tls1_1 \
  6229. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6230. 0 \
  6231. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  6232. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6233. run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
  6234. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6235. "$P_CLI request_size=16384 force_version=tls1_1 \
  6236. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  6237. 0 \
  6238. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  6239. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6240. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6241. run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
  6242. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6243. "$P_CLI request_size=16384 force_version=tls1_1 \
  6244. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6245. 0 \
  6246. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6247. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6248. run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
  6249. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6250. "$P_CLI request_size=16384 force_version=tls1_1 \
  6251. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
  6252. 0 \
  6253. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  6254. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6255. run_test "Large client packet TLS 1.2 BlockCipher" \
  6256. "$P_SRV" \
  6257. "$P_CLI request_size=16384 force_version=tls12 \
  6258. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6259. 0 \
  6260. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  6261. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6262. run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
  6263. "$P_SRV" \
  6264. "$P_CLI request_size=16384 force_version=tls12 etm=0 \
  6265. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6266. 0 \
  6267. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6268. run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
  6269. "$P_SRV" \
  6270. "$P_CLI request_size=16384 force_version=tls12 \
  6271. force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
  6272. 0 \
  6273. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  6274. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6275. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6276. run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
  6277. "$P_SRV trunc_hmac=1" \
  6278. "$P_CLI request_size=16384 force_version=tls12 \
  6279. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  6280. 0 \
  6281. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6282. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6283. run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
  6284. "$P_SRV trunc_hmac=1" \
  6285. "$P_CLI request_size=16384 force_version=tls12 \
  6286. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
  6287. 0 \
  6288. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  6289. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6290. run_test "Large client packet TLS 1.2 StreamCipher" \
  6291. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6292. "$P_CLI request_size=16384 force_version=tls12 \
  6293. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6294. 0 \
  6295. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  6296. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6297. run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
  6298. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6299. "$P_CLI request_size=16384 force_version=tls12 \
  6300. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  6301. 0 \
  6302. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6303. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6304. run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
  6305. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6306. "$P_CLI request_size=16384 force_version=tls12 \
  6307. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6308. 0 \
  6309. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6310. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6311. run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
  6312. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6313. "$P_CLI request_size=16384 force_version=tls12 \
  6314. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
  6315. 0 \
  6316. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  6317. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6318. run_test "Large client packet TLS 1.2 AEAD" \
  6319. "$P_SRV" \
  6320. "$P_CLI request_size=16384 force_version=tls12 \
  6321. force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
  6322. 0 \
  6323. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  6324. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6325. run_test "Large client packet TLS 1.2 AEAD shorter tag" \
  6326. "$P_SRV" \
  6327. "$P_CLI request_size=16384 force_version=tls12 \
  6328. force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
  6329. 0 \
  6330. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  6331. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6332. # Test for large server packets
  6333. # The tests below fail when the server's OUT_CONTENT_LEN is less than 16384.
  6334. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  6335. run_test "Large server packet SSLv3 StreamCipher" \
  6336. "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6337. "$P_CLI force_version=ssl3 \
  6338. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6339. 0 \
  6340. -c "Read from server: 16384 bytes read"
  6341. # Checking next 4 tests logs for 1n-1 split against BEAST too
  6342. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  6343. run_test "Large server packet SSLv3 BlockCipher" \
  6344. "$P_SRV response_size=16384 min_version=ssl3" \
  6345. "$P_CLI force_version=ssl3 recsplit=0 \
  6346. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6347. 0 \
  6348. -c "Read from server: 1 bytes read"\
  6349. -c "16383 bytes read"\
  6350. -C "Read from server: 16384 bytes read"
  6351. run_test "Large server packet TLS 1.0 BlockCipher" \
  6352. "$P_SRV response_size=16384" \
  6353. "$P_CLI force_version=tls1 recsplit=0 \
  6354. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6355. 0 \
  6356. -c "Read from server: 1 bytes read"\
  6357. -c "16383 bytes read"\
  6358. -C "Read from server: 16384 bytes read"
  6359. run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
  6360. "$P_SRV response_size=16384" \
  6361. "$P_CLI force_version=tls1 etm=0 recsplit=0 \
  6362. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6363. 0 \
  6364. -c "Read from server: 1 bytes read"\
  6365. -c "16383 bytes read"\
  6366. -C "Read from server: 16384 bytes read"
  6367. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6368. run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
  6369. "$P_SRV response_size=16384" \
  6370. "$P_CLI force_version=tls1 recsplit=0 \
  6371. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
  6372. trunc_hmac=1" \
  6373. 0 \
  6374. -c "Read from server: 1 bytes read"\
  6375. -c "16383 bytes read"\
  6376. -C "Read from server: 16384 bytes read"
  6377. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6378. run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
  6379. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6380. "$P_CLI force_version=tls1 \
  6381. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
  6382. trunc_hmac=1" \
  6383. 0 \
  6384. -s "16384 bytes written in 1 fragments" \
  6385. -c "Read from server: 16384 bytes read"
  6386. run_test "Large server packet TLS 1.0 StreamCipher" \
  6387. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6388. "$P_CLI force_version=tls1 \
  6389. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6390. 0 \
  6391. -s "16384 bytes written in 1 fragments" \
  6392. -c "Read from server: 16384 bytes read"
  6393. run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
  6394. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6395. "$P_CLI force_version=tls1 \
  6396. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  6397. 0 \
  6398. -s "16384 bytes written in 1 fragments" \
  6399. -c "Read from server: 16384 bytes read"
  6400. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6401. run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
  6402. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6403. "$P_CLI force_version=tls1 \
  6404. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6405. 0 \
  6406. -s "16384 bytes written in 1 fragments" \
  6407. -c "Read from server: 16384 bytes read"
  6408. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6409. run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
  6410. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6411. "$P_CLI force_version=tls1 \
  6412. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
  6413. 0 \
  6414. -s "16384 bytes written in 1 fragments" \
  6415. -c "Read from server: 16384 bytes read"
  6416. run_test "Large server packet TLS 1.1 BlockCipher" \
  6417. "$P_SRV response_size=16384" \
  6418. "$P_CLI force_version=tls1_1 \
  6419. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6420. 0 \
  6421. -c "Read from server: 16384 bytes read"
  6422. run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
  6423. "$P_SRV response_size=16384" \
  6424. "$P_CLI force_version=tls1_1 etm=0 \
  6425. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6426. 0 \
  6427. -s "16384 bytes written in 1 fragments" \
  6428. -c "Read from server: 16384 bytes read"
  6429. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6430. run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
  6431. "$P_SRV response_size=16384" \
  6432. "$P_CLI force_version=tls1_1 \
  6433. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
  6434. trunc_hmac=1" \
  6435. 0 \
  6436. -c "Read from server: 16384 bytes read"
  6437. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6438. run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
  6439. "$P_SRV response_size=16384 trunc_hmac=1" \
  6440. "$P_CLI force_version=tls1_1 \
  6441. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
  6442. 0 \
  6443. -s "16384 bytes written in 1 fragments" \
  6444. -c "Read from server: 16384 bytes read"
  6445. run_test "Large server packet TLS 1.1 StreamCipher" \
  6446. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6447. "$P_CLI force_version=tls1_1 \
  6448. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6449. 0 \
  6450. -c "Read from server: 16384 bytes read"
  6451. run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
  6452. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6453. "$P_CLI force_version=tls1_1 \
  6454. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  6455. 0 \
  6456. -s "16384 bytes written in 1 fragments" \
  6457. -c "Read from server: 16384 bytes read"
  6458. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6459. run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
  6460. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6461. "$P_CLI force_version=tls1_1 \
  6462. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
  6463. trunc_hmac=1" \
  6464. 0 \
  6465. -c "Read from server: 16384 bytes read"
  6466. run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
  6467. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6468. "$P_CLI force_version=tls1_1 \
  6469. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
  6470. 0 \
  6471. -s "16384 bytes written in 1 fragments" \
  6472. -c "Read from server: 16384 bytes read"
  6473. run_test "Large server packet TLS 1.2 BlockCipher" \
  6474. "$P_SRV response_size=16384" \
  6475. "$P_CLI force_version=tls12 \
  6476. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6477. 0 \
  6478. -c "Read from server: 16384 bytes read"
  6479. run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
  6480. "$P_SRV response_size=16384" \
  6481. "$P_CLI force_version=tls12 etm=0 \
  6482. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6483. 0 \
  6484. -s "16384 bytes written in 1 fragments" \
  6485. -c "Read from server: 16384 bytes read"
  6486. run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
  6487. "$P_SRV response_size=16384" \
  6488. "$P_CLI force_version=tls12 \
  6489. force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
  6490. 0 \
  6491. -c "Read from server: 16384 bytes read"
  6492. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6493. run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
  6494. "$P_SRV response_size=16384" \
  6495. "$P_CLI force_version=tls12 \
  6496. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
  6497. trunc_hmac=1" \
  6498. 0 \
  6499. -c "Read from server: 16384 bytes read"
  6500. run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
  6501. "$P_SRV response_size=16384 trunc_hmac=1" \
  6502. "$P_CLI force_version=tls12 \
  6503. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
  6504. 0 \
  6505. -s "16384 bytes written in 1 fragments" \
  6506. -c "Read from server: 16384 bytes read"
  6507. run_test "Large server packet TLS 1.2 StreamCipher" \
  6508. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6509. "$P_CLI force_version=tls12 \
  6510. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6511. 0 \
  6512. -s "16384 bytes written in 1 fragments" \
  6513. -c "Read from server: 16384 bytes read"
  6514. run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
  6515. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6516. "$P_CLI force_version=tls12 \
  6517. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  6518. 0 \
  6519. -s "16384 bytes written in 1 fragments" \
  6520. -c "Read from server: 16384 bytes read"
  6521. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6522. run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
  6523. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6524. "$P_CLI force_version=tls12 \
  6525. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
  6526. trunc_hmac=1" \
  6527. 0 \
  6528. -c "Read from server: 16384 bytes read"
  6529. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6530. run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
  6531. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6532. "$P_CLI force_version=tls12 \
  6533. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
  6534. 0 \
  6535. -s "16384 bytes written in 1 fragments" \
  6536. -c "Read from server: 16384 bytes read"
  6537. run_test "Large server packet TLS 1.2 AEAD" \
  6538. "$P_SRV response_size=16384" \
  6539. "$P_CLI force_version=tls12 \
  6540. force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
  6541. 0 \
  6542. -c "Read from server: 16384 bytes read"
  6543. run_test "Large server packet TLS 1.2 AEAD shorter tag" \
  6544. "$P_SRV response_size=16384" \
  6545. "$P_CLI force_version=tls12 \
  6546. force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
  6547. 0 \
  6548. -c "Read from server: 16384 bytes read"
  6549. # Tests for restartable ECC
  6550. requires_config_enabled MBEDTLS_ECP_RESTARTABLE
  6551. run_test "EC restart: TLS, default" \
  6552. "$P_SRV auth_mode=required" \
  6553. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  6554. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6555. debug_level=1" \
  6556. 0 \
  6557. -C "x509_verify_cert.*4b00" \
  6558. -C "mbedtls_pk_verify.*4b00" \
  6559. -C "mbedtls_ecdh_make_public.*4b00" \
  6560. -C "mbedtls_pk_sign.*4b00"
  6561. requires_config_enabled MBEDTLS_ECP_RESTARTABLE
  6562. run_test "EC restart: TLS, max_ops=0" \
  6563. "$P_SRV auth_mode=required" \
  6564. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  6565. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6566. debug_level=1 ec_max_ops=0" \
  6567. 0 \
  6568. -C "x509_verify_cert.*4b00" \
  6569. -C "mbedtls_pk_verify.*4b00" \
  6570. -C "mbedtls_ecdh_make_public.*4b00" \
  6571. -C "mbedtls_pk_sign.*4b00"
  6572. requires_config_enabled MBEDTLS_ECP_RESTARTABLE
  6573. run_test "EC restart: TLS, max_ops=65535" \
  6574. "$P_SRV auth_mode=required" \
  6575. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  6576. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6577. debug_level=1 ec_max_ops=65535" \
  6578. 0 \
  6579. -C "x509_verify_cert.*4b00" \
  6580. -C "mbedtls_pk_verify.*4b00" \
  6581. -C "mbedtls_ecdh_make_public.*4b00" \
  6582. -C "mbedtls_pk_sign.*4b00"
  6583. requires_config_enabled MBEDTLS_ECP_RESTARTABLE
  6584. run_test "EC restart: TLS, max_ops=1000" \
  6585. "$P_SRV auth_mode=required" \
  6586. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  6587. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6588. debug_level=1 ec_max_ops=1000" \
  6589. 0 \
  6590. -c "x509_verify_cert.*4b00" \
  6591. -c "mbedtls_pk_verify.*4b00" \
  6592. -c "mbedtls_ecdh_make_public.*4b00" \
  6593. -c "mbedtls_pk_sign.*4b00"
  6594. requires_config_enabled MBEDTLS_ECP_RESTARTABLE
  6595. run_test "EC restart: TLS, max_ops=1000, badsign" \
  6596. "$P_SRV auth_mode=required \
  6597. crt_file=data_files/server5-badsign.crt \
  6598. key_file=data_files/server5.key" \
  6599. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  6600. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6601. debug_level=1 ec_max_ops=1000" \
  6602. 1 \
  6603. -c "x509_verify_cert.*4b00" \
  6604. -C "mbedtls_pk_verify.*4b00" \
  6605. -C "mbedtls_ecdh_make_public.*4b00" \
  6606. -C "mbedtls_pk_sign.*4b00" \
  6607. -c "! The certificate is not correctly signed by the trusted CA" \
  6608. -c "! mbedtls_ssl_handshake returned" \
  6609. -c "X509 - Certificate verification failed"
  6610. requires_config_enabled MBEDTLS_ECP_RESTARTABLE
  6611. run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
  6612. "$P_SRV auth_mode=required \
  6613. crt_file=data_files/server5-badsign.crt \
  6614. key_file=data_files/server5.key" \
  6615. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  6616. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6617. debug_level=1 ec_max_ops=1000 auth_mode=optional" \
  6618. 0 \
  6619. -c "x509_verify_cert.*4b00" \
  6620. -c "mbedtls_pk_verify.*4b00" \
  6621. -c "mbedtls_ecdh_make_public.*4b00" \
  6622. -c "mbedtls_pk_sign.*4b00" \
  6623. -c "! The certificate is not correctly signed by the trusted CA" \
  6624. -C "! mbedtls_ssl_handshake returned" \
  6625. -C "X509 - Certificate verification failed"
  6626. requires_config_enabled MBEDTLS_ECP_RESTARTABLE
  6627. run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
  6628. "$P_SRV auth_mode=required \
  6629. crt_file=data_files/server5-badsign.crt \
  6630. key_file=data_files/server5.key" \
  6631. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  6632. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6633. debug_level=1 ec_max_ops=1000 auth_mode=none" \
  6634. 0 \
  6635. -C "x509_verify_cert.*4b00" \
  6636. -c "mbedtls_pk_verify.*4b00" \
  6637. -c "mbedtls_ecdh_make_public.*4b00" \
  6638. -c "mbedtls_pk_sign.*4b00" \
  6639. -C "! The certificate is not correctly signed by the trusted CA" \
  6640. -C "! mbedtls_ssl_handshake returned" \
  6641. -C "X509 - Certificate verification failed"
  6642. requires_config_enabled MBEDTLS_ECP_RESTARTABLE
  6643. run_test "EC restart: DTLS, max_ops=1000" \
  6644. "$P_SRV auth_mode=required dtls=1" \
  6645. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  6646. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6647. dtls=1 debug_level=1 ec_max_ops=1000" \
  6648. 0 \
  6649. -c "x509_verify_cert.*4b00" \
  6650. -c "mbedtls_pk_verify.*4b00" \
  6651. -c "mbedtls_ecdh_make_public.*4b00" \
  6652. -c "mbedtls_pk_sign.*4b00"
  6653. requires_config_enabled MBEDTLS_ECP_RESTARTABLE
  6654. run_test "EC restart: TLS, max_ops=1000 no client auth" \
  6655. "$P_SRV" \
  6656. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  6657. debug_level=1 ec_max_ops=1000" \
  6658. 0 \
  6659. -c "x509_verify_cert.*4b00" \
  6660. -c "mbedtls_pk_verify.*4b00" \
  6661. -c "mbedtls_ecdh_make_public.*4b00" \
  6662. -C "mbedtls_pk_sign.*4b00"
  6663. requires_config_enabled MBEDTLS_ECP_RESTARTABLE
  6664. run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
  6665. "$P_SRV psk=abc123" \
  6666. "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
  6667. psk=abc123 debug_level=1 ec_max_ops=1000" \
  6668. 0 \
  6669. -C "x509_verify_cert.*4b00" \
  6670. -C "mbedtls_pk_verify.*4b00" \
  6671. -C "mbedtls_ecdh_make_public.*4b00" \
  6672. -C "mbedtls_pk_sign.*4b00"
  6673. # Tests of asynchronous private key support in SSL
  6674. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6675. run_test "SSL async private: sign, delay=0" \
  6676. "$P_SRV \
  6677. async_operations=s async_private_delay1=0 async_private_delay2=0" \
  6678. "$P_CLI" \
  6679. 0 \
  6680. -s "Async sign callback: using key slot " \
  6681. -s "Async resume (slot [0-9]): sign done, status=0"
  6682. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6683. run_test "SSL async private: sign, delay=1" \
  6684. "$P_SRV \
  6685. async_operations=s async_private_delay1=1 async_private_delay2=1" \
  6686. "$P_CLI" \
  6687. 0 \
  6688. -s "Async sign callback: using key slot " \
  6689. -s "Async resume (slot [0-9]): call 0 more times." \
  6690. -s "Async resume (slot [0-9]): sign done, status=0"
  6691. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6692. run_test "SSL async private: sign, delay=2" \
  6693. "$P_SRV \
  6694. async_operations=s async_private_delay1=2 async_private_delay2=2" \
  6695. "$P_CLI" \
  6696. 0 \
  6697. -s "Async sign callback: using key slot " \
  6698. -U "Async sign callback: using key slot " \
  6699. -s "Async resume (slot [0-9]): call 1 more times." \
  6700. -s "Async resume (slot [0-9]): call 0 more times." \
  6701. -s "Async resume (slot [0-9]): sign done, status=0"
  6702. # Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
  6703. # with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
  6704. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6705. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
  6706. run_test "SSL async private: sign, RSA, TLS 1.1" \
  6707. "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
  6708. async_operations=s async_private_delay1=0 async_private_delay2=0" \
  6709. "$P_CLI force_version=tls1_1" \
  6710. 0 \
  6711. -s "Async sign callback: using key slot " \
  6712. -s "Async resume (slot [0-9]): sign done, status=0"
  6713. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6714. run_test "SSL async private: sign, SNI" \
  6715. "$P_SRV debug_level=3 \
  6716. async_operations=s async_private_delay1=0 async_private_delay2=0 \
  6717. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  6718. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
  6719. "$P_CLI server_name=polarssl.example" \
  6720. 0 \
  6721. -s "Async sign callback: using key slot " \
  6722. -s "Async resume (slot [0-9]): sign done, status=0" \
  6723. -s "parse ServerName extension" \
  6724. -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
  6725. -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
  6726. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6727. run_test "SSL async private: decrypt, delay=0" \
  6728. "$P_SRV \
  6729. async_operations=d async_private_delay1=0 async_private_delay2=0" \
  6730. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  6731. 0 \
  6732. -s "Async decrypt callback: using key slot " \
  6733. -s "Async resume (slot [0-9]): decrypt done, status=0"
  6734. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6735. run_test "SSL async private: decrypt, delay=1" \
  6736. "$P_SRV \
  6737. async_operations=d async_private_delay1=1 async_private_delay2=1" \
  6738. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  6739. 0 \
  6740. -s "Async decrypt callback: using key slot " \
  6741. -s "Async resume (slot [0-9]): call 0 more times." \
  6742. -s "Async resume (slot [0-9]): decrypt done, status=0"
  6743. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6744. run_test "SSL async private: decrypt RSA-PSK, delay=0" \
  6745. "$P_SRV psk=abc123 \
  6746. async_operations=d async_private_delay1=0 async_private_delay2=0" \
  6747. "$P_CLI psk=abc123 \
  6748. force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
  6749. 0 \
  6750. -s "Async decrypt callback: using key slot " \
  6751. -s "Async resume (slot [0-9]): decrypt done, status=0"
  6752. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6753. run_test "SSL async private: decrypt RSA-PSK, delay=1" \
  6754. "$P_SRV psk=abc123 \
  6755. async_operations=d async_private_delay1=1 async_private_delay2=1" \
  6756. "$P_CLI psk=abc123 \
  6757. force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
  6758. 0 \
  6759. -s "Async decrypt callback: using key slot " \
  6760. -s "Async resume (slot [0-9]): call 0 more times." \
  6761. -s "Async resume (slot [0-9]): decrypt done, status=0"
  6762. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6763. run_test "SSL async private: sign callback not present" \
  6764. "$P_SRV \
  6765. async_operations=d async_private_delay1=1 async_private_delay2=1" \
  6766. "$P_CLI; [ \$? -eq 1 ] &&
  6767. $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  6768. 0 \
  6769. -S "Async sign callback" \
  6770. -s "! mbedtls_ssl_handshake returned" \
  6771. -s "The own private key or pre-shared key is not set, but needed" \
  6772. -s "Async resume (slot [0-9]): decrypt done, status=0" \
  6773. -s "Successful connection"
  6774. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6775. run_test "SSL async private: decrypt callback not present" \
  6776. "$P_SRV debug_level=1 \
  6777. async_operations=s async_private_delay1=1 async_private_delay2=1" \
  6778. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
  6779. [ \$? -eq 1 ] && $P_CLI" \
  6780. 0 \
  6781. -S "Async decrypt callback" \
  6782. -s "! mbedtls_ssl_handshake returned" \
  6783. -s "got no RSA private key" \
  6784. -s "Async resume (slot [0-9]): sign done, status=0" \
  6785. -s "Successful connection"
  6786. # key1: ECDSA, key2: RSA; use key1 from slot 0
  6787. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6788. run_test "SSL async private: slot 0 used with key1" \
  6789. "$P_SRV \
  6790. async_operations=s async_private_delay1=1 \
  6791. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6792. key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
  6793. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
  6794. 0 \
  6795. -s "Async sign callback: using key slot 0," \
  6796. -s "Async resume (slot 0): call 0 more times." \
  6797. -s "Async resume (slot 0): sign done, status=0"
  6798. # key1: ECDSA, key2: RSA; use key2 from slot 0
  6799. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6800. run_test "SSL async private: slot 0 used with key2" \
  6801. "$P_SRV \
  6802. async_operations=s async_private_delay2=1 \
  6803. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6804. key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
  6805. "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
  6806. 0 \
  6807. -s "Async sign callback: using key slot 0," \
  6808. -s "Async resume (slot 0): call 0 more times." \
  6809. -s "Async resume (slot 0): sign done, status=0"
  6810. # key1: ECDSA, key2: RSA; use key2 from slot 1
  6811. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6812. run_test "SSL async private: slot 1 used with key2" \
  6813. "$P_SRV \
  6814. async_operations=s async_private_delay1=1 async_private_delay2=1 \
  6815. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6816. key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
  6817. "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
  6818. 0 \
  6819. -s "Async sign callback: using key slot 1," \
  6820. -s "Async resume (slot 1): call 0 more times." \
  6821. -s "Async resume (slot 1): sign done, status=0"
  6822. # key1: ECDSA, key2: RSA; use key2 directly
  6823. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6824. run_test "SSL async private: fall back to transparent key" \
  6825. "$P_SRV \
  6826. async_operations=s async_private_delay1=1 \
  6827. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6828. key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
  6829. "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
  6830. 0 \
  6831. -s "Async sign callback: no key matches this certificate."
  6832. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6833. run_test "SSL async private: sign, error in start" \
  6834. "$P_SRV \
  6835. async_operations=s async_private_delay1=1 async_private_delay2=1 \
  6836. async_private_error=1" \
  6837. "$P_CLI" \
  6838. 1 \
  6839. -s "Async sign callback: injected error" \
  6840. -S "Async resume" \
  6841. -S "Async cancel" \
  6842. -s "! mbedtls_ssl_handshake returned"
  6843. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6844. run_test "SSL async private: sign, cancel after start" \
  6845. "$P_SRV \
  6846. async_operations=s async_private_delay1=1 async_private_delay2=1 \
  6847. async_private_error=2" \
  6848. "$P_CLI" \
  6849. 1 \
  6850. -s "Async sign callback: using key slot " \
  6851. -S "Async resume" \
  6852. -s "Async cancel"
  6853. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6854. run_test "SSL async private: sign, error in resume" \
  6855. "$P_SRV \
  6856. async_operations=s async_private_delay1=1 async_private_delay2=1 \
  6857. async_private_error=3" \
  6858. "$P_CLI" \
  6859. 1 \
  6860. -s "Async sign callback: using key slot " \
  6861. -s "Async resume callback: sign done but injected error" \
  6862. -S "Async cancel" \
  6863. -s "! mbedtls_ssl_handshake returned"
  6864. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6865. run_test "SSL async private: decrypt, error in start" \
  6866. "$P_SRV \
  6867. async_operations=d async_private_delay1=1 async_private_delay2=1 \
  6868. async_private_error=1" \
  6869. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  6870. 1 \
  6871. -s "Async decrypt callback: injected error" \
  6872. -S "Async resume" \
  6873. -S "Async cancel" \
  6874. -s "! mbedtls_ssl_handshake returned"
  6875. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6876. run_test "SSL async private: decrypt, cancel after start" \
  6877. "$P_SRV \
  6878. async_operations=d async_private_delay1=1 async_private_delay2=1 \
  6879. async_private_error=2" \
  6880. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  6881. 1 \
  6882. -s "Async decrypt callback: using key slot " \
  6883. -S "Async resume" \
  6884. -s "Async cancel"
  6885. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6886. run_test "SSL async private: decrypt, error in resume" \
  6887. "$P_SRV \
  6888. async_operations=d async_private_delay1=1 async_private_delay2=1 \
  6889. async_private_error=3" \
  6890. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  6891. 1 \
  6892. -s "Async decrypt callback: using key slot " \
  6893. -s "Async resume callback: decrypt done but injected error" \
  6894. -S "Async cancel" \
  6895. -s "! mbedtls_ssl_handshake returned"
  6896. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6897. run_test "SSL async private: cancel after start then operate correctly" \
  6898. "$P_SRV \
  6899. async_operations=s async_private_delay1=1 async_private_delay2=1 \
  6900. async_private_error=-2" \
  6901. "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
  6902. 0 \
  6903. -s "Async cancel" \
  6904. -s "! mbedtls_ssl_handshake returned" \
  6905. -s "Async resume" \
  6906. -s "Successful connection"
  6907. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6908. run_test "SSL async private: error in resume then operate correctly" \
  6909. "$P_SRV \
  6910. async_operations=s async_private_delay1=1 async_private_delay2=1 \
  6911. async_private_error=-3" \
  6912. "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
  6913. 0 \
  6914. -s "! mbedtls_ssl_handshake returned" \
  6915. -s "Async resume" \
  6916. -s "Successful connection"
  6917. # key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
  6918. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6919. run_test "SSL async private: cancel after start then fall back to transparent key" \
  6920. "$P_SRV \
  6921. async_operations=s async_private_delay1=1 async_private_error=-2 \
  6922. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6923. key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
  6924. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
  6925. [ \$? -eq 1 ] &&
  6926. $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
  6927. 0 \
  6928. -s "Async sign callback: using key slot 0" \
  6929. -S "Async resume" \
  6930. -s "Async cancel" \
  6931. -s "! mbedtls_ssl_handshake returned" \
  6932. -s "Async sign callback: no key matches this certificate." \
  6933. -s "Successful connection"
  6934. # key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
  6935. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6936. run_test "SSL async private: sign, error in resume then fall back to transparent key" \
  6937. "$P_SRV \
  6938. async_operations=s async_private_delay1=1 async_private_error=-3 \
  6939. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6940. key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
  6941. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
  6942. [ \$? -eq 1 ] &&
  6943. $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
  6944. 0 \
  6945. -s "Async resume" \
  6946. -s "! mbedtls_ssl_handshake returned" \
  6947. -s "Async sign callback: no key matches this certificate." \
  6948. -s "Successful connection"
  6949. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6950. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  6951. run_test "SSL async private: renegotiation: client-initiated, sign" \
  6952. "$P_SRV \
  6953. async_operations=s async_private_delay1=1 async_private_delay2=1 \
  6954. exchanges=2 renegotiation=1" \
  6955. "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
  6956. 0 \
  6957. -s "Async sign callback: using key slot " \
  6958. -s "Async resume (slot [0-9]): sign done, status=0"
  6959. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6960. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  6961. run_test "SSL async private: renegotiation: server-initiated, sign" \
  6962. "$P_SRV \
  6963. async_operations=s async_private_delay1=1 async_private_delay2=1 \
  6964. exchanges=2 renegotiation=1 renegotiate=1" \
  6965. "$P_CLI exchanges=2 renegotiation=1" \
  6966. 0 \
  6967. -s "Async sign callback: using key slot " \
  6968. -s "Async resume (slot [0-9]): sign done, status=0"
  6969. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6970. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  6971. run_test "SSL async private: renegotiation: client-initiated, decrypt" \
  6972. "$P_SRV \
  6973. async_operations=d async_private_delay1=1 async_private_delay2=1 \
  6974. exchanges=2 renegotiation=1" \
  6975. "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
  6976. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  6977. 0 \
  6978. -s "Async decrypt callback: using key slot " \
  6979. -s "Async resume (slot [0-9]): decrypt done, status=0"
  6980. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6981. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  6982. run_test "SSL async private: renegotiation: server-initiated, decrypt" \
  6983. "$P_SRV \
  6984. async_operations=d async_private_delay1=1 async_private_delay2=1 \
  6985. exchanges=2 renegotiation=1 renegotiate=1" \
  6986. "$P_CLI exchanges=2 renegotiation=1 \
  6987. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  6988. 0 \
  6989. -s "Async decrypt callback: using key slot " \
  6990. -s "Async resume (slot [0-9]): decrypt done, status=0"
  6991. # Tests for ECC extensions (rfc 4492)
  6992. requires_config_enabled MBEDTLS_AES_C
  6993. requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
  6994. requires_config_enabled MBEDTLS_SHA256_C
  6995. requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
  6996. run_test "Force a non ECC ciphersuite in the client side" \
  6997. "$P_SRV debug_level=3" \
  6998. "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
  6999. 0 \
  7000. -C "client hello, adding supported_elliptic_curves extension" \
  7001. -C "client hello, adding supported_point_formats extension" \
  7002. -S "found supported elliptic curves extension" \
  7003. -S "found supported point formats extension"
  7004. requires_config_enabled MBEDTLS_AES_C
  7005. requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
  7006. requires_config_enabled MBEDTLS_SHA256_C
  7007. requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
  7008. run_test "Force a non ECC ciphersuite in the server side" \
  7009. "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
  7010. "$P_CLI debug_level=3" \
  7011. 0 \
  7012. -C "found supported_point_formats extension" \
  7013. -S "server hello, supported_point_formats extension"
  7014. requires_config_enabled MBEDTLS_AES_C
  7015. requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
  7016. requires_config_enabled MBEDTLS_SHA256_C
  7017. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
  7018. run_test "Force an ECC ciphersuite in the client side" \
  7019. "$P_SRV debug_level=3" \
  7020. "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
  7021. 0 \
  7022. -c "client hello, adding supported_elliptic_curves extension" \
  7023. -c "client hello, adding supported_point_formats extension" \
  7024. -s "found supported elliptic curves extension" \
  7025. -s "found supported point formats extension"
  7026. requires_config_enabled MBEDTLS_AES_C
  7027. requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
  7028. requires_config_enabled MBEDTLS_SHA256_C
  7029. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
  7030. run_test "Force an ECC ciphersuite in the server side" \
  7031. "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
  7032. "$P_CLI debug_level=3" \
  7033. 0 \
  7034. -c "found supported_point_formats extension" \
  7035. -s "server hello, supported_point_formats extension"
  7036. # Tests for DTLS HelloVerifyRequest
  7037. run_test "DTLS cookie: enabled" \
  7038. "$P_SRV dtls=1 debug_level=2" \
  7039. "$P_CLI dtls=1 debug_level=2" \
  7040. 0 \
  7041. -s "cookie verification failed" \
  7042. -s "cookie verification passed" \
  7043. -S "cookie verification skipped" \
  7044. -c "received hello verify request" \
  7045. -s "hello verification requested" \
  7046. -S "SSL - The requested feature is not available"
  7047. run_test "DTLS cookie: disabled" \
  7048. "$P_SRV dtls=1 debug_level=2 cookies=0" \
  7049. "$P_CLI dtls=1 debug_level=2" \
  7050. 0 \
  7051. -S "cookie verification failed" \
  7052. -S "cookie verification passed" \
  7053. -s "cookie verification skipped" \
  7054. -C "received hello verify request" \
  7055. -S "hello verification requested" \
  7056. -S "SSL - The requested feature is not available"
  7057. run_test "DTLS cookie: default (failing)" \
  7058. "$P_SRV dtls=1 debug_level=2 cookies=-1" \
  7059. "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
  7060. 1 \
  7061. -s "cookie verification failed" \
  7062. -S "cookie verification passed" \
  7063. -S "cookie verification skipped" \
  7064. -C "received hello verify request" \
  7065. -S "hello verification requested" \
  7066. -s "SSL - The requested feature is not available"
  7067. requires_ipv6
  7068. run_test "DTLS cookie: enabled, IPv6" \
  7069. "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
  7070. "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
  7071. 0 \
  7072. -s "cookie verification failed" \
  7073. -s "cookie verification passed" \
  7074. -S "cookie verification skipped" \
  7075. -c "received hello verify request" \
  7076. -s "hello verification requested" \
  7077. -S "SSL - The requested feature is not available"
  7078. run_test "DTLS cookie: enabled, nbio" \
  7079. "$P_SRV dtls=1 nbio=2 debug_level=2" \
  7080. "$P_CLI dtls=1 nbio=2 debug_level=2" \
  7081. 0 \
  7082. -s "cookie verification failed" \
  7083. -s "cookie verification passed" \
  7084. -S "cookie verification skipped" \
  7085. -c "received hello verify request" \
  7086. -s "hello verification requested" \
  7087. -S "SSL - The requested feature is not available"
  7088. # Tests for client reconnecting from the same port with DTLS
  7089. not_with_valgrind # spurious resend
  7090. run_test "DTLS client reconnect from same port: reference" \
  7091. "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
  7092. "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
  7093. 0 \
  7094. -C "resend" \
  7095. -S "The operation timed out" \
  7096. -S "Client initiated reconnection from same port"
  7097. not_with_valgrind # spurious resend
  7098. run_test "DTLS client reconnect from same port: reconnect" \
  7099. "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
  7100. "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000 reconnect_hard=1" \
  7101. 0 \
  7102. -C "resend" \
  7103. -S "The operation timed out" \
  7104. -s "Client initiated reconnection from same port"
  7105. not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
  7106. run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
  7107. "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
  7108. "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000 reconnect_hard=1" \
  7109. 0 \
  7110. -S "The operation timed out" \
  7111. -s "Client initiated reconnection from same port"
  7112. only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
  7113. run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
  7114. "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
  7115. "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
  7116. 0 \
  7117. -S "The operation timed out" \
  7118. -s "Client initiated reconnection from same port"
  7119. run_test "DTLS client reconnect from same port: no cookies" \
  7120. "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
  7121. "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
  7122. 0 \
  7123. -s "The operation timed out" \
  7124. -S "Client initiated reconnection from same port"
  7125. run_test "DTLS client reconnect from same port: attacker-injected" \
  7126. -p "$P_PXY inject_clihlo=1" \
  7127. "$P_SRV dtls=1 exchanges=2 debug_level=1" \
  7128. "$P_CLI dtls=1 exchanges=2" \
  7129. 0 \
  7130. -s "possible client reconnect from the same port" \
  7131. -S "Client initiated reconnection from same port"
  7132. # Tests for various cases of client authentication with DTLS
  7133. # (focused on handshake flows and message parsing)
  7134. run_test "DTLS client auth: required" \
  7135. "$P_SRV dtls=1 auth_mode=required" \
  7136. "$P_CLI dtls=1" \
  7137. 0 \
  7138. -s "Verifying peer X.509 certificate... ok"
  7139. run_test "DTLS client auth: optional, client has no cert" \
  7140. "$P_SRV dtls=1 auth_mode=optional" \
  7141. "$P_CLI dtls=1 crt_file=none key_file=none" \
  7142. 0 \
  7143. -s "! Certificate was missing"
  7144. run_test "DTLS client auth: none, client has no cert" \
  7145. "$P_SRV dtls=1 auth_mode=none" \
  7146. "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
  7147. 0 \
  7148. -c "skip write certificate$" \
  7149. -s "! Certificate verification was skipped"
  7150. run_test "DTLS wrong PSK: badmac alert" \
  7151. "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
  7152. "$P_CLI dtls=1 psk=abc124" \
  7153. 1 \
  7154. -s "SSL - Verification of the message MAC failed" \
  7155. -c "SSL - A fatal alert message was received from our peer"
  7156. # Tests for receiving fragmented handshake messages with DTLS
  7157. requires_gnutls
  7158. run_test "DTLS reassembly: no fragmentation (gnutls server)" \
  7159. "$G_SRV -u --mtu 2048 -a" \
  7160. "$P_CLI dtls=1 debug_level=2" \
  7161. 0 \
  7162. -C "found fragmented DTLS handshake message" \
  7163. -C "error"
  7164. requires_gnutls
  7165. run_test "DTLS reassembly: some fragmentation (gnutls server)" \
  7166. "$G_SRV -u --mtu 512" \
  7167. "$P_CLI dtls=1 debug_level=2" \
  7168. 0 \
  7169. -c "found fragmented DTLS handshake message" \
  7170. -C "error"
  7171. requires_gnutls
  7172. run_test "DTLS reassembly: more fragmentation (gnutls server)" \
  7173. "$G_SRV -u --mtu 128" \
  7174. "$P_CLI dtls=1 debug_level=2" \
  7175. 0 \
  7176. -c "found fragmented DTLS handshake message" \
  7177. -C "error"
  7178. requires_gnutls
  7179. run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
  7180. "$G_SRV -u --mtu 128" \
  7181. "$P_CLI dtls=1 nbio=2 debug_level=2" \
  7182. 0 \
  7183. -c "found fragmented DTLS handshake message" \
  7184. -C "error"
  7185. requires_gnutls
  7186. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  7187. run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
  7188. "$G_SRV -u --mtu 256" \
  7189. "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
  7190. 0 \
  7191. -c "found fragmented DTLS handshake message" \
  7192. -c "client hello, adding renegotiation extension" \
  7193. -c "found renegotiation extension" \
  7194. -c "=> renegotiate" \
  7195. -C "mbedtls_ssl_handshake returned" \
  7196. -C "error" \
  7197. -s "Extra-header:"
  7198. requires_gnutls
  7199. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  7200. run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
  7201. "$G_SRV -u --mtu 256" \
  7202. "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
  7203. 0 \
  7204. -c "found fragmented DTLS handshake message" \
  7205. -c "client hello, adding renegotiation extension" \
  7206. -c "found renegotiation extension" \
  7207. -c "=> renegotiate" \
  7208. -C "mbedtls_ssl_handshake returned" \
  7209. -C "error" \
  7210. -s "Extra-header:"
  7211. run_test "DTLS reassembly: no fragmentation (openssl server)" \
  7212. "$O_SRV -dtls1 -mtu 2048" \
  7213. "$P_CLI dtls=1 debug_level=2" \
  7214. 0 \
  7215. -C "found fragmented DTLS handshake message" \
  7216. -C "error"
  7217. run_test "DTLS reassembly: some fragmentation (openssl server)" \
  7218. "$O_SRV -dtls1 -mtu 768" \
  7219. "$P_CLI dtls=1 debug_level=2" \
  7220. 0 \
  7221. -c "found fragmented DTLS handshake message" \
  7222. -C "error"
  7223. run_test "DTLS reassembly: more fragmentation (openssl server)" \
  7224. "$O_SRV -dtls1 -mtu 256" \
  7225. "$P_CLI dtls=1 debug_level=2" \
  7226. 0 \
  7227. -c "found fragmented DTLS handshake message" \
  7228. -C "error"
  7229. run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
  7230. "$O_SRV -dtls1 -mtu 256" \
  7231. "$P_CLI dtls=1 nbio=2 debug_level=2" \
  7232. 0 \
  7233. -c "found fragmented DTLS handshake message" \
  7234. -C "error"
  7235. # Tests for sending fragmented handshake messages with DTLS
  7236. #
  7237. # Use client auth when we need the client to send large messages,
  7238. # and use large cert chains on both sides too (the long chains we have all use
  7239. # both RSA and ECDSA, but ideally we should have long chains with either).
  7240. # Sizes reached (UDP payload):
  7241. # - 2037B for server certificate
  7242. # - 1542B for client certificate
  7243. # - 1013B for newsessionticket
  7244. # - all others below 512B
  7245. # All those tests assume MAX_CONTENT_LEN is at least 2048
  7246. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7247. requires_config_enabled MBEDTLS_RSA_C
  7248. requires_config_enabled MBEDTLS_ECDSA_C
  7249. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  7250. requires_max_content_len 4096
  7251. run_test "DTLS fragmenting: none (for reference)" \
  7252. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7253. crt_file=data_files/server7_int-ca.crt \
  7254. key_file=data_files/server7.key \
  7255. hs_timeout=2500-60000 \
  7256. max_frag_len=4096" \
  7257. "$P_CLI dtls=1 debug_level=2 \
  7258. crt_file=data_files/server8_int-ca2.crt \
  7259. key_file=data_files/server8.key \
  7260. hs_timeout=2500-60000 \
  7261. max_frag_len=4096" \
  7262. 0 \
  7263. -S "found fragmented DTLS handshake message" \
  7264. -C "found fragmented DTLS handshake message" \
  7265. -C "error"
  7266. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7267. requires_config_enabled MBEDTLS_RSA_C
  7268. requires_config_enabled MBEDTLS_ECDSA_C
  7269. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  7270. requires_max_content_len 2048
  7271. run_test "DTLS fragmenting: server only (max_frag_len)" \
  7272. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7273. crt_file=data_files/server7_int-ca.crt \
  7274. key_file=data_files/server7.key \
  7275. hs_timeout=2500-60000 \
  7276. max_frag_len=1024" \
  7277. "$P_CLI dtls=1 debug_level=2 \
  7278. crt_file=data_files/server8_int-ca2.crt \
  7279. key_file=data_files/server8.key \
  7280. hs_timeout=2500-60000 \
  7281. max_frag_len=2048" \
  7282. 0 \
  7283. -S "found fragmented DTLS handshake message" \
  7284. -c "found fragmented DTLS handshake message" \
  7285. -C "error"
  7286. # With the MFL extension, the server has no way of forcing
  7287. # the client to not exceed a certain MTU; hence, the following
  7288. # test can't be replicated with an MTU proxy such as the one
  7289. # `client-initiated, server only (max_frag_len)` below.
  7290. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7291. requires_config_enabled MBEDTLS_RSA_C
  7292. requires_config_enabled MBEDTLS_ECDSA_C
  7293. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  7294. requires_max_content_len 4096
  7295. run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
  7296. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7297. crt_file=data_files/server7_int-ca.crt \
  7298. key_file=data_files/server7.key \
  7299. hs_timeout=2500-60000 \
  7300. max_frag_len=512" \
  7301. "$P_CLI dtls=1 debug_level=2 \
  7302. crt_file=data_files/server8_int-ca2.crt \
  7303. key_file=data_files/server8.key \
  7304. hs_timeout=2500-60000 \
  7305. max_frag_len=4096" \
  7306. 0 \
  7307. -S "found fragmented DTLS handshake message" \
  7308. -c "found fragmented DTLS handshake message" \
  7309. -C "error"
  7310. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7311. requires_config_enabled MBEDTLS_RSA_C
  7312. requires_config_enabled MBEDTLS_ECDSA_C
  7313. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  7314. requires_max_content_len 2048
  7315. run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
  7316. "$P_SRV dtls=1 debug_level=2 auth_mode=none \
  7317. crt_file=data_files/server7_int-ca.crt \
  7318. key_file=data_files/server7.key \
  7319. hs_timeout=2500-60000 \
  7320. max_frag_len=2048" \
  7321. "$P_CLI dtls=1 debug_level=2 \
  7322. crt_file=data_files/server8_int-ca2.crt \
  7323. key_file=data_files/server8.key \
  7324. hs_timeout=2500-60000 \
  7325. max_frag_len=1024" \
  7326. 0 \
  7327. -S "found fragmented DTLS handshake message" \
  7328. -c "found fragmented DTLS handshake message" \
  7329. -C "error"
  7330. # While not required by the standard defining the MFL extension
  7331. # (according to which it only applies to records, not to datagrams),
  7332. # Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
  7333. # as otherwise there wouldn't be any means to communicate MTU restrictions
  7334. # to the peer.
  7335. # The next test checks that no datagrams significantly larger than the
  7336. # negotiated MFL are sent.
  7337. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7338. requires_config_enabled MBEDTLS_RSA_C
  7339. requires_config_enabled MBEDTLS_ECDSA_C
  7340. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  7341. requires_max_content_len 2048
  7342. run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
  7343. -p "$P_PXY mtu=1110" \
  7344. "$P_SRV dtls=1 debug_level=2 auth_mode=none \
  7345. crt_file=data_files/server7_int-ca.crt \
  7346. key_file=data_files/server7.key \
  7347. hs_timeout=2500-60000 \
  7348. max_frag_len=2048" \
  7349. "$P_CLI dtls=1 debug_level=2 \
  7350. crt_file=data_files/server8_int-ca2.crt \
  7351. key_file=data_files/server8.key \
  7352. hs_timeout=2500-60000 \
  7353. max_frag_len=1024" \
  7354. 0 \
  7355. -S "found fragmented DTLS handshake message" \
  7356. -c "found fragmented DTLS handshake message" \
  7357. -C "error"
  7358. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7359. requires_config_enabled MBEDTLS_RSA_C
  7360. requires_config_enabled MBEDTLS_ECDSA_C
  7361. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  7362. requires_max_content_len 2048
  7363. run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
  7364. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7365. crt_file=data_files/server7_int-ca.crt \
  7366. key_file=data_files/server7.key \
  7367. hs_timeout=2500-60000 \
  7368. max_frag_len=2048" \
  7369. "$P_CLI dtls=1 debug_level=2 \
  7370. crt_file=data_files/server8_int-ca2.crt \
  7371. key_file=data_files/server8.key \
  7372. hs_timeout=2500-60000 \
  7373. max_frag_len=1024" \
  7374. 0 \
  7375. -s "found fragmented DTLS handshake message" \
  7376. -c "found fragmented DTLS handshake message" \
  7377. -C "error"
  7378. # While not required by the standard defining the MFL extension
  7379. # (according to which it only applies to records, not to datagrams),
  7380. # Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
  7381. # as otherwise there wouldn't be any means to communicate MTU restrictions
  7382. # to the peer.
  7383. # The next test checks that no datagrams significantly larger than the
  7384. # negotiated MFL are sent.
  7385. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7386. requires_config_enabled MBEDTLS_RSA_C
  7387. requires_config_enabled MBEDTLS_ECDSA_C
  7388. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  7389. requires_max_content_len 2048
  7390. run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
  7391. -p "$P_PXY mtu=1110" \
  7392. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7393. crt_file=data_files/server7_int-ca.crt \
  7394. key_file=data_files/server7.key \
  7395. hs_timeout=2500-60000 \
  7396. max_frag_len=2048" \
  7397. "$P_CLI dtls=1 debug_level=2 \
  7398. crt_file=data_files/server8_int-ca2.crt \
  7399. key_file=data_files/server8.key \
  7400. hs_timeout=2500-60000 \
  7401. max_frag_len=1024" \
  7402. 0 \
  7403. -s "found fragmented DTLS handshake message" \
  7404. -c "found fragmented DTLS handshake message" \
  7405. -C "error"
  7406. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7407. requires_config_enabled MBEDTLS_RSA_C
  7408. requires_config_enabled MBEDTLS_ECDSA_C
  7409. requires_max_content_len 4096
  7410. run_test "DTLS fragmenting: none (for reference) (MTU)" \
  7411. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7412. crt_file=data_files/server7_int-ca.crt \
  7413. key_file=data_files/server7.key \
  7414. hs_timeout=2500-60000 \
  7415. mtu=4096" \
  7416. "$P_CLI dtls=1 debug_level=2 \
  7417. crt_file=data_files/server8_int-ca2.crt \
  7418. key_file=data_files/server8.key \
  7419. hs_timeout=2500-60000 \
  7420. mtu=4096" \
  7421. 0 \
  7422. -S "found fragmented DTLS handshake message" \
  7423. -C "found fragmented DTLS handshake message" \
  7424. -C "error"
  7425. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7426. requires_config_enabled MBEDTLS_RSA_C
  7427. requires_config_enabled MBEDTLS_ECDSA_C
  7428. requires_max_content_len 4096
  7429. run_test "DTLS fragmenting: client (MTU)" \
  7430. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7431. crt_file=data_files/server7_int-ca.crt \
  7432. key_file=data_files/server7.key \
  7433. hs_timeout=3500-60000 \
  7434. mtu=4096" \
  7435. "$P_CLI dtls=1 debug_level=2 \
  7436. crt_file=data_files/server8_int-ca2.crt \
  7437. key_file=data_files/server8.key \
  7438. hs_timeout=3500-60000 \
  7439. mtu=1024" \
  7440. 0 \
  7441. -s "found fragmented DTLS handshake message" \
  7442. -C "found fragmented DTLS handshake message" \
  7443. -C "error"
  7444. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7445. requires_config_enabled MBEDTLS_RSA_C
  7446. requires_config_enabled MBEDTLS_ECDSA_C
  7447. requires_max_content_len 2048
  7448. run_test "DTLS fragmenting: server (MTU)" \
  7449. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7450. crt_file=data_files/server7_int-ca.crt \
  7451. key_file=data_files/server7.key \
  7452. hs_timeout=2500-60000 \
  7453. mtu=512" \
  7454. "$P_CLI dtls=1 debug_level=2 \
  7455. crt_file=data_files/server8_int-ca2.crt \
  7456. key_file=data_files/server8.key \
  7457. hs_timeout=2500-60000 \
  7458. mtu=2048" \
  7459. 0 \
  7460. -S "found fragmented DTLS handshake message" \
  7461. -c "found fragmented DTLS handshake message" \
  7462. -C "error"
  7463. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7464. requires_config_enabled MBEDTLS_RSA_C
  7465. requires_config_enabled MBEDTLS_ECDSA_C
  7466. requires_max_content_len 2048
  7467. run_test "DTLS fragmenting: both (MTU=1024)" \
  7468. -p "$P_PXY mtu=1024" \
  7469. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7470. crt_file=data_files/server7_int-ca.crt \
  7471. key_file=data_files/server7.key \
  7472. hs_timeout=2500-60000 \
  7473. mtu=1024" \
  7474. "$P_CLI dtls=1 debug_level=2 \
  7475. crt_file=data_files/server8_int-ca2.crt \
  7476. key_file=data_files/server8.key \
  7477. hs_timeout=2500-60000 \
  7478. mtu=1024" \
  7479. 0 \
  7480. -s "found fragmented DTLS handshake message" \
  7481. -c "found fragmented DTLS handshake message" \
  7482. -C "error"
  7483. # Forcing ciphersuite for this test to fit the MTU of 512 with full config.
  7484. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7485. requires_config_enabled MBEDTLS_RSA_C
  7486. requires_config_enabled MBEDTLS_ECDSA_C
  7487. requires_config_enabled MBEDTLS_SHA256_C
  7488. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
  7489. requires_config_enabled MBEDTLS_AES_C
  7490. requires_config_enabled MBEDTLS_GCM_C
  7491. requires_max_content_len 2048
  7492. run_test "DTLS fragmenting: both (MTU=512)" \
  7493. -p "$P_PXY mtu=512" \
  7494. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7495. crt_file=data_files/server7_int-ca.crt \
  7496. key_file=data_files/server7.key \
  7497. hs_timeout=2500-60000 \
  7498. mtu=512" \
  7499. "$P_CLI dtls=1 debug_level=2 \
  7500. crt_file=data_files/server8_int-ca2.crt \
  7501. key_file=data_files/server8.key \
  7502. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  7503. hs_timeout=2500-60000 \
  7504. mtu=512" \
  7505. 0 \
  7506. -s "found fragmented DTLS handshake message" \
  7507. -c "found fragmented DTLS handshake message" \
  7508. -C "error"
  7509. # Test for automatic MTU reduction on repeated resend.
  7510. # Forcing ciphersuite for this test to fit the MTU of 508 with full config.
  7511. # The ratio of max/min timeout should ideally equal 4 to accept two
  7512. # retransmissions, but in some cases (like both the server and client using
  7513. # fragmentation and auto-reduction) an extra retransmission might occur,
  7514. # hence the ratio of 8.
  7515. not_with_valgrind
  7516. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7517. requires_config_enabled MBEDTLS_RSA_C
  7518. requires_config_enabled MBEDTLS_ECDSA_C
  7519. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
  7520. requires_config_enabled MBEDTLS_AES_C
  7521. requires_config_enabled MBEDTLS_GCM_C
  7522. requires_max_content_len 2048
  7523. run_test "DTLS fragmenting: proxy MTU: auto-reduction (not valgrind)" \
  7524. -p "$P_PXY mtu=508" \
  7525. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7526. crt_file=data_files/server7_int-ca.crt \
  7527. key_file=data_files/server7.key \
  7528. hs_timeout=400-3200" \
  7529. "$P_CLI dtls=1 debug_level=2 \
  7530. crt_file=data_files/server8_int-ca2.crt \
  7531. key_file=data_files/server8.key \
  7532. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  7533. hs_timeout=400-3200" \
  7534. 0 \
  7535. -s "found fragmented DTLS handshake message" \
  7536. -c "found fragmented DTLS handshake message" \
  7537. -C "error"
  7538. # Forcing ciphersuite for this test to fit the MTU of 508 with full config.
  7539. only_with_valgrind
  7540. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7541. requires_config_enabled MBEDTLS_RSA_C
  7542. requires_config_enabled MBEDTLS_ECDSA_C
  7543. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
  7544. requires_config_enabled MBEDTLS_AES_C
  7545. requires_config_enabled MBEDTLS_GCM_C
  7546. requires_max_content_len 2048
  7547. run_test "DTLS fragmenting: proxy MTU: auto-reduction (with valgrind)" \
  7548. -p "$P_PXY mtu=508" \
  7549. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7550. crt_file=data_files/server7_int-ca.crt \
  7551. key_file=data_files/server7.key \
  7552. hs_timeout=250-10000" \
  7553. "$P_CLI dtls=1 debug_level=2 \
  7554. crt_file=data_files/server8_int-ca2.crt \
  7555. key_file=data_files/server8.key \
  7556. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  7557. hs_timeout=250-10000" \
  7558. 0 \
  7559. -s "found fragmented DTLS handshake message" \
  7560. -c "found fragmented DTLS handshake message" \
  7561. -C "error"
  7562. # the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
  7563. # OTOH the client might resend if the server is to slow to reset after sending
  7564. # a HelloVerifyRequest, so only check for no retransmission server-side
  7565. not_with_valgrind # spurious autoreduction due to timeout
  7566. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7567. requires_config_enabled MBEDTLS_RSA_C
  7568. requires_config_enabled MBEDTLS_ECDSA_C
  7569. requires_max_content_len 2048
  7570. run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
  7571. -p "$P_PXY mtu=1024" \
  7572. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7573. crt_file=data_files/server7_int-ca.crt \
  7574. key_file=data_files/server7.key \
  7575. hs_timeout=10000-60000 \
  7576. mtu=1024" \
  7577. "$P_CLI dtls=1 debug_level=2 \
  7578. crt_file=data_files/server8_int-ca2.crt \
  7579. key_file=data_files/server8.key \
  7580. hs_timeout=10000-60000 \
  7581. mtu=1024" \
  7582. 0 \
  7583. -S "autoreduction" \
  7584. -s "found fragmented DTLS handshake message" \
  7585. -c "found fragmented DTLS handshake message" \
  7586. -C "error"
  7587. # Forcing ciphersuite for this test to fit the MTU of 512 with full config.
  7588. # the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
  7589. # OTOH the client might resend if the server is to slow to reset after sending
  7590. # a HelloVerifyRequest, so only check for no retransmission server-side
  7591. not_with_valgrind # spurious autoreduction due to timeout
  7592. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7593. requires_config_enabled MBEDTLS_RSA_C
  7594. requires_config_enabled MBEDTLS_ECDSA_C
  7595. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
  7596. requires_config_enabled MBEDTLS_AES_C
  7597. requires_config_enabled MBEDTLS_GCM_C
  7598. requires_max_content_len 2048
  7599. run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
  7600. -p "$P_PXY mtu=512" \
  7601. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7602. crt_file=data_files/server7_int-ca.crt \
  7603. key_file=data_files/server7.key \
  7604. hs_timeout=10000-60000 \
  7605. mtu=512" \
  7606. "$P_CLI dtls=1 debug_level=2 \
  7607. crt_file=data_files/server8_int-ca2.crt \
  7608. key_file=data_files/server8.key \
  7609. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  7610. hs_timeout=10000-60000 \
  7611. mtu=512" \
  7612. 0 \
  7613. -S "autoreduction" \
  7614. -s "found fragmented DTLS handshake message" \
  7615. -c "found fragmented DTLS handshake message" \
  7616. -C "error"
  7617. not_with_valgrind # spurious autoreduction due to timeout
  7618. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7619. requires_config_enabled MBEDTLS_RSA_C
  7620. requires_config_enabled MBEDTLS_ECDSA_C
  7621. requires_max_content_len 2048
  7622. run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
  7623. -p "$P_PXY mtu=1024" \
  7624. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7625. crt_file=data_files/server7_int-ca.crt \
  7626. key_file=data_files/server7.key \
  7627. hs_timeout=10000-60000 \
  7628. mtu=1024 nbio=2" \
  7629. "$P_CLI dtls=1 debug_level=2 \
  7630. crt_file=data_files/server8_int-ca2.crt \
  7631. key_file=data_files/server8.key \
  7632. hs_timeout=10000-60000 \
  7633. mtu=1024 nbio=2" \
  7634. 0 \
  7635. -S "autoreduction" \
  7636. -s "found fragmented DTLS handshake message" \
  7637. -c "found fragmented DTLS handshake message" \
  7638. -C "error"
  7639. # Forcing ciphersuite for this test to fit the MTU of 512 with full config.
  7640. not_with_valgrind # spurious autoreduction due to timeout
  7641. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7642. requires_config_enabled MBEDTLS_RSA_C
  7643. requires_config_enabled MBEDTLS_ECDSA_C
  7644. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
  7645. requires_config_enabled MBEDTLS_AES_C
  7646. requires_config_enabled MBEDTLS_GCM_C
  7647. requires_max_content_len 2048
  7648. run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
  7649. -p "$P_PXY mtu=512" \
  7650. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7651. crt_file=data_files/server7_int-ca.crt \
  7652. key_file=data_files/server7.key \
  7653. hs_timeout=10000-60000 \
  7654. mtu=512 nbio=2" \
  7655. "$P_CLI dtls=1 debug_level=2 \
  7656. crt_file=data_files/server8_int-ca2.crt \
  7657. key_file=data_files/server8.key \
  7658. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  7659. hs_timeout=10000-60000 \
  7660. mtu=512 nbio=2" \
  7661. 0 \
  7662. -S "autoreduction" \
  7663. -s "found fragmented DTLS handshake message" \
  7664. -c "found fragmented DTLS handshake message" \
  7665. -C "error"
  7666. # Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
  7667. # This ensures things still work after session_reset().
  7668. # It also exercises the "resumed handshake" flow.
  7669. # Since we don't support reading fragmented ClientHello yet,
  7670. # up the MTU to 1450 (larger than ClientHello with session ticket,
  7671. # but still smaller than client's Certificate to ensure fragmentation).
  7672. # An autoreduction on the client-side might happen if the server is
  7673. # slow to reset, therefore omitting '-C "autoreduction"' below.
  7674. # reco_delay avoids races where the client reconnects before the server has
  7675. # resumed listening, which would result in a spurious autoreduction.
  7676. not_with_valgrind # spurious autoreduction due to timeout
  7677. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7678. requires_config_enabled MBEDTLS_RSA_C
  7679. requires_config_enabled MBEDTLS_ECDSA_C
  7680. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
  7681. requires_config_enabled MBEDTLS_AES_C
  7682. requires_config_enabled MBEDTLS_GCM_C
  7683. requires_max_content_len 2048
  7684. run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
  7685. -p "$P_PXY mtu=1450" \
  7686. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7687. crt_file=data_files/server7_int-ca.crt \
  7688. key_file=data_files/server7.key \
  7689. hs_timeout=10000-60000 \
  7690. mtu=1450" \
  7691. "$P_CLI dtls=1 debug_level=2 \
  7692. crt_file=data_files/server8_int-ca2.crt \
  7693. key_file=data_files/server8.key \
  7694. hs_timeout=10000-60000 \
  7695. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  7696. mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
  7697. 0 \
  7698. -S "autoreduction" \
  7699. -s "found fragmented DTLS handshake message" \
  7700. -c "found fragmented DTLS handshake message" \
  7701. -C "error"
  7702. # An autoreduction on the client-side might happen if the server is
  7703. # slow to reset, therefore omitting '-C "autoreduction"' below.
  7704. not_with_valgrind # spurious autoreduction due to timeout
  7705. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7706. requires_config_enabled MBEDTLS_RSA_C
  7707. requires_config_enabled MBEDTLS_ECDSA_C
  7708. requires_config_enabled MBEDTLS_SHA256_C
  7709. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
  7710. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  7711. requires_config_enabled MBEDTLS_CHACHAPOLY_C
  7712. requires_max_content_len 2048
  7713. run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
  7714. -p "$P_PXY mtu=512" \
  7715. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7716. crt_file=data_files/server7_int-ca.crt \
  7717. key_file=data_files/server7.key \
  7718. exchanges=2 renegotiation=1 \
  7719. hs_timeout=10000-60000 \
  7720. mtu=512" \
  7721. "$P_CLI dtls=1 debug_level=2 \
  7722. crt_file=data_files/server8_int-ca2.crt \
  7723. key_file=data_files/server8.key \
  7724. exchanges=2 renegotiation=1 renegotiate=1 \
  7725. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  7726. hs_timeout=10000-60000 \
  7727. mtu=512" \
  7728. 0 \
  7729. -S "autoreduction" \
  7730. -s "found fragmented DTLS handshake message" \
  7731. -c "found fragmented DTLS handshake message" \
  7732. -C "error"
  7733. # An autoreduction on the client-side might happen if the server is
  7734. # slow to reset, therefore omitting '-C "autoreduction"' below.
  7735. not_with_valgrind # spurious autoreduction due to timeout
  7736. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7737. requires_config_enabled MBEDTLS_RSA_C
  7738. requires_config_enabled MBEDTLS_ECDSA_C
  7739. requires_config_enabled MBEDTLS_SHA256_C
  7740. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
  7741. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  7742. requires_config_enabled MBEDTLS_AES_C
  7743. requires_config_enabled MBEDTLS_GCM_C
  7744. requires_max_content_len 2048
  7745. run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
  7746. -p "$P_PXY mtu=512" \
  7747. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7748. crt_file=data_files/server7_int-ca.crt \
  7749. key_file=data_files/server7.key \
  7750. exchanges=2 renegotiation=1 \
  7751. hs_timeout=10000-60000 \
  7752. mtu=512" \
  7753. "$P_CLI dtls=1 debug_level=2 \
  7754. crt_file=data_files/server8_int-ca2.crt \
  7755. key_file=data_files/server8.key \
  7756. exchanges=2 renegotiation=1 renegotiate=1 \
  7757. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  7758. hs_timeout=10000-60000 \
  7759. mtu=512" \
  7760. 0 \
  7761. -S "autoreduction" \
  7762. -s "found fragmented DTLS handshake message" \
  7763. -c "found fragmented DTLS handshake message" \
  7764. -C "error"
  7765. # An autoreduction on the client-side might happen if the server is
  7766. # slow to reset, therefore omitting '-C "autoreduction"' below.
  7767. not_with_valgrind # spurious autoreduction due to timeout
  7768. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7769. requires_config_enabled MBEDTLS_RSA_C
  7770. requires_config_enabled MBEDTLS_ECDSA_C
  7771. requires_config_enabled MBEDTLS_SHA256_C
  7772. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
  7773. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  7774. requires_config_enabled MBEDTLS_AES_C
  7775. requires_config_enabled MBEDTLS_CCM_C
  7776. requires_max_content_len 2048
  7777. run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
  7778. -p "$P_PXY mtu=1024" \
  7779. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7780. crt_file=data_files/server7_int-ca.crt \
  7781. key_file=data_files/server7.key \
  7782. exchanges=2 renegotiation=1 \
  7783. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
  7784. hs_timeout=10000-60000 \
  7785. mtu=1024" \
  7786. "$P_CLI dtls=1 debug_level=2 \
  7787. crt_file=data_files/server8_int-ca2.crt \
  7788. key_file=data_files/server8.key \
  7789. exchanges=2 renegotiation=1 renegotiate=1 \
  7790. hs_timeout=10000-60000 \
  7791. mtu=1024" \
  7792. 0 \
  7793. -S "autoreduction" \
  7794. -s "found fragmented DTLS handshake message" \
  7795. -c "found fragmented DTLS handshake message" \
  7796. -C "error"
  7797. # An autoreduction on the client-side might happen if the server is
  7798. # slow to reset, therefore omitting '-C "autoreduction"' below.
  7799. not_with_valgrind # spurious autoreduction due to timeout
  7800. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7801. requires_config_enabled MBEDTLS_RSA_C
  7802. requires_config_enabled MBEDTLS_ECDSA_C
  7803. requires_config_enabled MBEDTLS_SHA256_C
  7804. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
  7805. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  7806. requires_config_enabled MBEDTLS_AES_C
  7807. requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
  7808. requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
  7809. requires_max_content_len 2048
  7810. run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
  7811. -p "$P_PXY mtu=1024" \
  7812. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7813. crt_file=data_files/server7_int-ca.crt \
  7814. key_file=data_files/server7.key \
  7815. exchanges=2 renegotiation=1 \
  7816. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
  7817. hs_timeout=10000-60000 \
  7818. mtu=1024" \
  7819. "$P_CLI dtls=1 debug_level=2 \
  7820. crt_file=data_files/server8_int-ca2.crt \
  7821. key_file=data_files/server8.key \
  7822. exchanges=2 renegotiation=1 renegotiate=1 \
  7823. hs_timeout=10000-60000 \
  7824. mtu=1024" \
  7825. 0 \
  7826. -S "autoreduction" \
  7827. -s "found fragmented DTLS handshake message" \
  7828. -c "found fragmented DTLS handshake message" \
  7829. -C "error"
  7830. # An autoreduction on the client-side might happen if the server is
  7831. # slow to reset, therefore omitting '-C "autoreduction"' below.
  7832. not_with_valgrind # spurious autoreduction due to timeout
  7833. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7834. requires_config_enabled MBEDTLS_RSA_C
  7835. requires_config_enabled MBEDTLS_ECDSA_C
  7836. requires_config_enabled MBEDTLS_SHA256_C
  7837. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
  7838. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  7839. requires_config_enabled MBEDTLS_AES_C
  7840. requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
  7841. requires_max_content_len 2048
  7842. run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
  7843. -p "$P_PXY mtu=1024" \
  7844. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7845. crt_file=data_files/server7_int-ca.crt \
  7846. key_file=data_files/server7.key \
  7847. exchanges=2 renegotiation=1 \
  7848. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
  7849. hs_timeout=10000-60000 \
  7850. mtu=1024" \
  7851. "$P_CLI dtls=1 debug_level=2 \
  7852. crt_file=data_files/server8_int-ca2.crt \
  7853. key_file=data_files/server8.key \
  7854. exchanges=2 renegotiation=1 renegotiate=1 \
  7855. hs_timeout=10000-60000 \
  7856. mtu=1024" \
  7857. 0 \
  7858. -S "autoreduction" \
  7859. -s "found fragmented DTLS handshake message" \
  7860. -c "found fragmented DTLS handshake message" \
  7861. -C "error"
  7862. # Forcing ciphersuite for this test to fit the MTU of 512 with full config.
  7863. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7864. requires_config_enabled MBEDTLS_RSA_C
  7865. requires_config_enabled MBEDTLS_ECDSA_C
  7866. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
  7867. requires_config_enabled MBEDTLS_AES_C
  7868. requires_config_enabled MBEDTLS_GCM_C
  7869. client_needs_more_time 2
  7870. requires_max_content_len 2048
  7871. run_test "DTLS fragmenting: proxy MTU + 3d" \
  7872. -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
  7873. "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
  7874. crt_file=data_files/server7_int-ca.crt \
  7875. key_file=data_files/server7.key \
  7876. hs_timeout=250-10000 mtu=512" \
  7877. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  7878. crt_file=data_files/server8_int-ca2.crt \
  7879. key_file=data_files/server8.key \
  7880. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  7881. hs_timeout=250-10000 mtu=512" \
  7882. 0 \
  7883. -s "found fragmented DTLS handshake message" \
  7884. -c "found fragmented DTLS handshake message" \
  7885. -C "error"
  7886. # Forcing ciphersuite for this test to fit the MTU of 512 with full config.
  7887. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7888. requires_config_enabled MBEDTLS_RSA_C
  7889. requires_config_enabled MBEDTLS_ECDSA_C
  7890. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
  7891. requires_config_enabled MBEDTLS_AES_C
  7892. requires_config_enabled MBEDTLS_GCM_C
  7893. client_needs_more_time 2
  7894. requires_max_content_len 2048
  7895. run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
  7896. -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
  7897. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7898. crt_file=data_files/server7_int-ca.crt \
  7899. key_file=data_files/server7.key \
  7900. hs_timeout=250-10000 mtu=512 nbio=2" \
  7901. "$P_CLI dtls=1 debug_level=2 \
  7902. crt_file=data_files/server8_int-ca2.crt \
  7903. key_file=data_files/server8.key \
  7904. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  7905. hs_timeout=250-10000 mtu=512 nbio=2" \
  7906. 0 \
  7907. -s "found fragmented DTLS handshake message" \
  7908. -c "found fragmented DTLS handshake message" \
  7909. -C "error"
  7910. # interop tests for DTLS fragmentating with reliable connection
  7911. #
  7912. # here and below we just want to test that the we fragment in a way that
  7913. # pleases other implementations, so we don't need the peer to fragment
  7914. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7915. requires_config_enabled MBEDTLS_RSA_C
  7916. requires_config_enabled MBEDTLS_ECDSA_C
  7917. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
  7918. requires_gnutls
  7919. requires_max_content_len 2048
  7920. run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
  7921. "$G_SRV -u" \
  7922. "$P_CLI dtls=1 debug_level=2 \
  7923. crt_file=data_files/server8_int-ca2.crt \
  7924. key_file=data_files/server8.key \
  7925. mtu=512 force_version=dtls12" \
  7926. 0 \
  7927. -c "fragmenting handshake message" \
  7928. -C "error"
  7929. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7930. requires_config_enabled MBEDTLS_RSA_C
  7931. requires_config_enabled MBEDTLS_ECDSA_C
  7932. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
  7933. requires_gnutls
  7934. requires_max_content_len 2048
  7935. run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
  7936. "$G_SRV -u" \
  7937. "$P_CLI dtls=1 debug_level=2 \
  7938. crt_file=data_files/server8_int-ca2.crt \
  7939. key_file=data_files/server8.key \
  7940. mtu=512 force_version=dtls1" \
  7941. 0 \
  7942. -c "fragmenting handshake message" \
  7943. -C "error"
  7944. # We use --insecure for the GnuTLS client because it expects
  7945. # the hostname / IP it connects to to be the name used in the
  7946. # certificate obtained from the server. Here, however, it
  7947. # connects to 127.0.0.1 while our test certificates use 'localhost'
  7948. # as the server name in the certificate. This will make the
  7949. # certifiate validation fail, but passing --insecure makes
  7950. # GnuTLS continue the connection nonetheless.
  7951. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7952. requires_config_enabled MBEDTLS_RSA_C
  7953. requires_config_enabled MBEDTLS_ECDSA_C
  7954. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
  7955. requires_gnutls
  7956. requires_not_i686
  7957. requires_max_content_len 2048
  7958. run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
  7959. "$P_SRV dtls=1 debug_level=2 \
  7960. crt_file=data_files/server7_int-ca.crt \
  7961. key_file=data_files/server7.key \
  7962. mtu=512 force_version=dtls12" \
  7963. "$G_CLI -u --insecure 127.0.0.1" \
  7964. 0 \
  7965. -s "fragmenting handshake message"
  7966. # See previous test for the reason to use --insecure
  7967. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7968. requires_config_enabled MBEDTLS_RSA_C
  7969. requires_config_enabled MBEDTLS_ECDSA_C
  7970. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
  7971. requires_gnutls
  7972. requires_not_i686
  7973. requires_max_content_len 2048
  7974. run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
  7975. "$P_SRV dtls=1 debug_level=2 \
  7976. crt_file=data_files/server7_int-ca.crt \
  7977. key_file=data_files/server7.key \
  7978. mtu=512 force_version=dtls1" \
  7979. "$G_CLI -u --insecure 127.0.0.1" \
  7980. 0 \
  7981. -s "fragmenting handshake message"
  7982. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7983. requires_config_enabled MBEDTLS_RSA_C
  7984. requires_config_enabled MBEDTLS_ECDSA_C
  7985. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
  7986. requires_max_content_len 2048
  7987. run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
  7988. "$O_SRV -dtls1_2 -verify 10" \
  7989. "$P_CLI dtls=1 debug_level=2 \
  7990. crt_file=data_files/server8_int-ca2.crt \
  7991. key_file=data_files/server8.key \
  7992. mtu=512 force_version=dtls12" \
  7993. 0 \
  7994. -c "fragmenting handshake message" \
  7995. -C "error"
  7996. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7997. requires_config_enabled MBEDTLS_RSA_C
  7998. requires_config_enabled MBEDTLS_ECDSA_C
  7999. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
  8000. requires_max_content_len 2048
  8001. run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
  8002. "$O_SRV -dtls1 -verify 10" \
  8003. "$P_CLI dtls=1 debug_level=2 \
  8004. crt_file=data_files/server8_int-ca2.crt \
  8005. key_file=data_files/server8.key \
  8006. mtu=512 force_version=dtls1" \
  8007. 0 \
  8008. -c "fragmenting handshake message" \
  8009. -C "error"
  8010. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  8011. requires_config_enabled MBEDTLS_RSA_C
  8012. requires_config_enabled MBEDTLS_ECDSA_C
  8013. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
  8014. requires_max_content_len 2048
  8015. run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
  8016. "$P_SRV dtls=1 debug_level=2 \
  8017. crt_file=data_files/server7_int-ca.crt \
  8018. key_file=data_files/server7.key \
  8019. mtu=512 force_version=dtls12" \
  8020. "$O_CLI -dtls1_2" \
  8021. 0 \
  8022. -s "fragmenting handshake message"
  8023. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  8024. requires_config_enabled MBEDTLS_RSA_C
  8025. requires_config_enabled MBEDTLS_ECDSA_C
  8026. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
  8027. requires_max_content_len 2048
  8028. run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
  8029. "$P_SRV dtls=1 debug_level=2 \
  8030. crt_file=data_files/server7_int-ca.crt \
  8031. key_file=data_files/server7.key \
  8032. mtu=512 force_version=dtls1" \
  8033. "$O_CLI -dtls1" \
  8034. 0 \
  8035. -s "fragmenting handshake message"
  8036. # interop tests for DTLS fragmentating with unreliable connection
  8037. #
  8038. # again we just want to test that the we fragment in a way that
  8039. # pleases other implementations, so we don't need the peer to fragment
  8040. requires_gnutls_next
  8041. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  8042. requires_config_enabled MBEDTLS_RSA_C
  8043. requires_config_enabled MBEDTLS_ECDSA_C
  8044. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
  8045. client_needs_more_time 4
  8046. requires_max_content_len 2048
  8047. run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
  8048. -p "$P_PXY drop=8 delay=8 duplicate=8" \
  8049. "$G_NEXT_SRV -u" \
  8050. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  8051. crt_file=data_files/server8_int-ca2.crt \
  8052. key_file=data_files/server8.key \
  8053. hs_timeout=250-60000 mtu=512 force_version=dtls12" \
  8054. 0 \
  8055. -c "fragmenting handshake message" \
  8056. -C "error"
  8057. requires_gnutls_next
  8058. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  8059. requires_config_enabled MBEDTLS_RSA_C
  8060. requires_config_enabled MBEDTLS_ECDSA_C
  8061. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
  8062. client_needs_more_time 4
  8063. requires_max_content_len 2048
  8064. run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
  8065. -p "$P_PXY drop=8 delay=8 duplicate=8" \
  8066. "$G_NEXT_SRV -u" \
  8067. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  8068. crt_file=data_files/server8_int-ca2.crt \
  8069. key_file=data_files/server8.key \
  8070. hs_timeout=250-60000 mtu=512 force_version=dtls1" \
  8071. 0 \
  8072. -c "fragmenting handshake message" \
  8073. -C "error"
  8074. requires_gnutls_next
  8075. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  8076. requires_config_enabled MBEDTLS_RSA_C
  8077. requires_config_enabled MBEDTLS_ECDSA_C
  8078. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
  8079. client_needs_more_time 4
  8080. requires_max_content_len 2048
  8081. run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
  8082. -p "$P_PXY drop=8 delay=8 duplicate=8" \
  8083. "$P_SRV dtls=1 debug_level=2 \
  8084. crt_file=data_files/server7_int-ca.crt \
  8085. key_file=data_files/server7.key \
  8086. hs_timeout=250-60000 mtu=512 force_version=dtls12" \
  8087. "$G_NEXT_CLI -u --insecure 127.0.0.1" \
  8088. 0 \
  8089. -s "fragmenting handshake message"
  8090. requires_gnutls_next
  8091. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  8092. requires_config_enabled MBEDTLS_RSA_C
  8093. requires_config_enabled MBEDTLS_ECDSA_C
  8094. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
  8095. client_needs_more_time 4
  8096. requires_max_content_len 2048
  8097. run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
  8098. -p "$P_PXY drop=8 delay=8 duplicate=8" \
  8099. "$P_SRV dtls=1 debug_level=2 \
  8100. crt_file=data_files/server7_int-ca.crt \
  8101. key_file=data_files/server7.key \
  8102. hs_timeout=250-60000 mtu=512 force_version=dtls1" \
  8103. "$G_NEXT_CLI -u --insecure 127.0.0.1" \
  8104. 0 \
  8105. -s "fragmenting handshake message"
  8106. ## Interop test with OpenSSL might trigger a bug in recent versions (including
  8107. ## all versions installed on the CI machines), reported here:
  8108. ## Bug report: https://github.com/openssl/openssl/issues/6902
  8109. ## They should be re-enabled once a fixed version of OpenSSL is available
  8110. ## (this should happen in some 1.1.1_ release according to the ticket).
  8111. skip_next_test
  8112. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  8113. requires_config_enabled MBEDTLS_RSA_C
  8114. requires_config_enabled MBEDTLS_ECDSA_C
  8115. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
  8116. client_needs_more_time 4
  8117. requires_max_content_len 2048
  8118. run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
  8119. -p "$P_PXY drop=8 delay=8 duplicate=8" \
  8120. "$O_SRV -dtls1_2 -verify 10" \
  8121. "$P_CLI dtls=1 debug_level=2 \
  8122. crt_file=data_files/server8_int-ca2.crt \
  8123. key_file=data_files/server8.key \
  8124. hs_timeout=250-60000 mtu=512 force_version=dtls12" \
  8125. 0 \
  8126. -c "fragmenting handshake message" \
  8127. -C "error"
  8128. skip_next_test
  8129. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  8130. requires_config_enabled MBEDTLS_RSA_C
  8131. requires_config_enabled MBEDTLS_ECDSA_C
  8132. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
  8133. client_needs_more_time 4
  8134. requires_max_content_len 2048
  8135. run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
  8136. -p "$P_PXY drop=8 delay=8 duplicate=8" \
  8137. "$O_SRV -dtls1 -verify 10" \
  8138. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  8139. crt_file=data_files/server8_int-ca2.crt \
  8140. key_file=data_files/server8.key \
  8141. hs_timeout=250-60000 mtu=512 force_version=dtls1" \
  8142. 0 \
  8143. -c "fragmenting handshake message" \
  8144. -C "error"
  8145. skip_next_test
  8146. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  8147. requires_config_enabled MBEDTLS_RSA_C
  8148. requires_config_enabled MBEDTLS_ECDSA_C
  8149. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
  8150. client_needs_more_time 4
  8151. requires_max_content_len 2048
  8152. run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
  8153. -p "$P_PXY drop=8 delay=8 duplicate=8" \
  8154. "$P_SRV dtls=1 debug_level=2 \
  8155. crt_file=data_files/server7_int-ca.crt \
  8156. key_file=data_files/server7.key \
  8157. hs_timeout=250-60000 mtu=512 force_version=dtls12" \
  8158. "$O_CLI -dtls1_2" \
  8159. 0 \
  8160. -s "fragmenting handshake message"
  8161. # -nbio is added to prevent s_client from blocking in case of duplicated
  8162. # messages at the end of the handshake
  8163. skip_next_test
  8164. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  8165. requires_config_enabled MBEDTLS_RSA_C
  8166. requires_config_enabled MBEDTLS_ECDSA_C
  8167. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
  8168. client_needs_more_time 4
  8169. requires_max_content_len 2048
  8170. run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
  8171. -p "$P_PXY drop=8 delay=8 duplicate=8" \
  8172. "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
  8173. crt_file=data_files/server7_int-ca.crt \
  8174. key_file=data_files/server7.key \
  8175. hs_timeout=250-60000 mtu=512 force_version=dtls1" \
  8176. "$O_CLI -nbio -dtls1" \
  8177. 0 \
  8178. -s "fragmenting handshake message"
  8179. # Tests for DTLS-SRTP (RFC 5764)
  8180. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8181. run_test "DTLS-SRTP all profiles supported" \
  8182. "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
  8183. "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
  8184. 0 \
  8185. -s "found use_srtp extension" \
  8186. -s "found srtp profile" \
  8187. -s "selected srtp profile" \
  8188. -s "server hello, adding use_srtp extension" \
  8189. -s "DTLS-SRTP key material is"\
  8190. -c "client hello, adding use_srtp extension" \
  8191. -c "found use_srtp extension" \
  8192. -c "found srtp profile" \
  8193. -c "selected srtp profile" \
  8194. -c "DTLS-SRTP key material is"\
  8195. -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
  8196. -C "error"
  8197. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8198. run_test "DTLS-SRTP server supports all profiles. Client supports one profile." \
  8199. "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
  8200. "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=5 debug_level=3" \
  8201. 0 \
  8202. -s "found use_srtp extension" \
  8203. -s "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80" \
  8204. -s "selected srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80" \
  8205. -s "server hello, adding use_srtp extension" \
  8206. -s "DTLS-SRTP key material is"\
  8207. -c "client hello, adding use_srtp extension" \
  8208. -c "found use_srtp extension" \
  8209. -c "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80" \
  8210. -c "selected srtp profile" \
  8211. -c "DTLS-SRTP key material is"\
  8212. -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
  8213. -C "error"
  8214. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8215. run_test "DTLS-SRTP server supports one profile. Client supports all profiles." \
  8216. "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \
  8217. "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
  8218. 0 \
  8219. -s "found use_srtp extension" \
  8220. -s "found srtp profile" \
  8221. -s "selected srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32" \
  8222. -s "server hello, adding use_srtp extension" \
  8223. -s "DTLS-SRTP key material is"\
  8224. -c "client hello, adding use_srtp extension" \
  8225. -c "found use_srtp extension" \
  8226. -c "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32" \
  8227. -c "selected srtp profile" \
  8228. -c "DTLS-SRTP key material is"\
  8229. -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
  8230. -C "error"
  8231. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8232. run_test "DTLS-SRTP server and Client support only one matching profile." \
  8233. "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
  8234. "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
  8235. 0 \
  8236. -s "found use_srtp extension" \
  8237. -s "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
  8238. -s "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
  8239. -s "server hello, adding use_srtp extension" \
  8240. -s "DTLS-SRTP key material is"\
  8241. -c "client hello, adding use_srtp extension" \
  8242. -c "found use_srtp extension" \
  8243. -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
  8244. -c "selected srtp profile" \
  8245. -c "DTLS-SRTP key material is"\
  8246. -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
  8247. -C "error"
  8248. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8249. run_test "DTLS-SRTP server and Client support only one different profile." \
  8250. "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
  8251. "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \
  8252. 0 \
  8253. -s "found use_srtp extension" \
  8254. -s "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32" \
  8255. -S "selected srtp profile" \
  8256. -S "server hello, adding use_srtp extension" \
  8257. -S "DTLS-SRTP key material is"\
  8258. -c "client hello, adding use_srtp extension" \
  8259. -C "found use_srtp extension" \
  8260. -C "found srtp profile" \
  8261. -C "selected srtp profile" \
  8262. -C "DTLS-SRTP key material is"\
  8263. -C "error"
  8264. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8265. run_test "DTLS-SRTP server doesn't support use_srtp extension." \
  8266. "$P_SRV dtls=1 debug_level=3" \
  8267. "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
  8268. 0 \
  8269. -s "found use_srtp extension" \
  8270. -S "server hello, adding use_srtp extension" \
  8271. -S "DTLS-SRTP key material is"\
  8272. -c "client hello, adding use_srtp extension" \
  8273. -C "found use_srtp extension" \
  8274. -C "found srtp profile" \
  8275. -C "selected srtp profile" \
  8276. -C "DTLS-SRTP key material is"\
  8277. -C "error"
  8278. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8279. run_test "DTLS-SRTP all profiles supported. mki used" \
  8280. "$P_SRV dtls=1 use_srtp=1 support_mki=1 debug_level=3" \
  8281. "$P_CLI dtls=1 use_srtp=1 mki=542310ab34290481 debug_level=3" \
  8282. 0 \
  8283. -s "found use_srtp extension" \
  8284. -s "found srtp profile" \
  8285. -s "selected srtp profile" \
  8286. -s "server hello, adding use_srtp extension" \
  8287. -s "dumping 'using mki' (8 bytes)" \
  8288. -s "DTLS-SRTP key material is"\
  8289. -c "client hello, adding use_srtp extension" \
  8290. -c "found use_srtp extension" \
  8291. -c "found srtp profile" \
  8292. -c "selected srtp profile" \
  8293. -c "dumping 'sending mki' (8 bytes)" \
  8294. -c "dumping 'received mki' (8 bytes)" \
  8295. -c "DTLS-SRTP key material is"\
  8296. -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
  8297. -g "find_in_both '^ *DTLS-SRTP mki value: [0-9A-F]*$'"\
  8298. -C "error"
  8299. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8300. run_test "DTLS-SRTP all profiles supported. server doesn't support mki." \
  8301. "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
  8302. "$P_CLI dtls=1 use_srtp=1 mki=542310ab34290481 debug_level=3" \
  8303. 0 \
  8304. -s "found use_srtp extension" \
  8305. -s "found srtp profile" \
  8306. -s "selected srtp profile" \
  8307. -s "server hello, adding use_srtp extension" \
  8308. -s "DTLS-SRTP key material is"\
  8309. -s "DTLS-SRTP no mki value negotiated"\
  8310. -S "dumping 'using mki' (8 bytes)" \
  8311. -c "client hello, adding use_srtp extension" \
  8312. -c "found use_srtp extension" \
  8313. -c "found srtp profile" \
  8314. -c "selected srtp profile" \
  8315. -c "DTLS-SRTP key material is"\
  8316. -c "DTLS-SRTP no mki value negotiated"\
  8317. -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
  8318. -c "dumping 'sending mki' (8 bytes)" \
  8319. -C "dumping 'received mki' (8 bytes)" \
  8320. -C "error"
  8321. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8322. run_test "DTLS-SRTP all profiles supported. openssl client." \
  8323. "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
  8324. "$O_CLI -dtls1 -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8325. 0 \
  8326. -s "found use_srtp extension" \
  8327. -s "found srtp profile" \
  8328. -s "selected srtp profile" \
  8329. -s "server hello, adding use_srtp extension" \
  8330. -s "DTLS-SRTP key material is"\
  8331. -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
  8332. -c "SRTP Extension negotiated, profile=SRTP_AES128_CM_SHA1_80"
  8333. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8334. run_test "DTLS-SRTP server supports all profiles. Client supports all profiles, in different order. openssl client." \
  8335. "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
  8336. "$O_CLI -dtls1 -use_srtp SRTP_AES128_CM_SHA1_32:SRTP_AES128_CM_SHA1_80 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8337. 0 \
  8338. -s "found use_srtp extension" \
  8339. -s "found srtp profile" \
  8340. -s "selected srtp profile" \
  8341. -s "server hello, adding use_srtp extension" \
  8342. -s "DTLS-SRTP key material is"\
  8343. -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
  8344. -c "SRTP Extension negotiated, profile=SRTP_AES128_CM_SHA1_32"
  8345. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8346. run_test "DTLS-SRTP server supports all profiles. Client supports one profile. openssl client." \
  8347. "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
  8348. "$O_CLI -dtls1 -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8349. 0 \
  8350. -s "found use_srtp extension" \
  8351. -s "found srtp profile" \
  8352. -s "selected srtp profile" \
  8353. -s "server hello, adding use_srtp extension" \
  8354. -s "DTLS-SRTP key material is"\
  8355. -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
  8356. -c "SRTP Extension negotiated, profile=SRTP_AES128_CM_SHA1_32"
  8357. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8358. run_test "DTLS-SRTP server supports one profile. Client supports all profiles. openssl client." \
  8359. "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
  8360. "$O_CLI -dtls1 -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8361. 0 \
  8362. -s "found use_srtp extension" \
  8363. -s "found srtp profile" \
  8364. -s "selected srtp profile" \
  8365. -s "server hello, adding use_srtp extension" \
  8366. -s "DTLS-SRTP key material is"\
  8367. -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
  8368. -c "SRTP Extension negotiated, profile=SRTP_AES128_CM_SHA1_32"
  8369. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8370. run_test "DTLS-SRTP server and Client support only one matching profile. openssl client." \
  8371. "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
  8372. "$O_CLI -dtls1 -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8373. 0 \
  8374. -s "found use_srtp extension" \
  8375. -s "found srtp profile" \
  8376. -s "selected srtp profile" \
  8377. -s "server hello, adding use_srtp extension" \
  8378. -s "DTLS-SRTP key material is"\
  8379. -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
  8380. -c "SRTP Extension negotiated, profile=SRTP_AES128_CM_SHA1_32"
  8381. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8382. run_test "DTLS-SRTP server and Client support only one different profile. openssl client." \
  8383. "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=1 debug_level=3" \
  8384. "$O_CLI -dtls1 -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8385. 0 \
  8386. -s "found use_srtp extension" \
  8387. -s "found srtp profile" \
  8388. -S "selected srtp profile" \
  8389. -S "server hello, adding use_srtp extension" \
  8390. -S "DTLS-SRTP key material is"\
  8391. -C "SRTP Extension negotiated, profile"
  8392. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8393. run_test "DTLS-SRTP server doesn't support use_srtp extension. openssl client" \
  8394. "$P_SRV dtls=1 debug_level=3" \
  8395. "$O_CLI -dtls1 -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8396. 0 \
  8397. -s "found use_srtp extension" \
  8398. -S "server hello, adding use_srtp extension" \
  8399. -S "DTLS-SRTP key material is"\
  8400. -C "SRTP Extension negotiated, profile"
  8401. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8402. run_test "DTLS-SRTP all profiles supported. openssl server" \
  8403. "$O_SRV -dtls1 -verify 0 -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8404. "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
  8405. 0 \
  8406. -c "client hello, adding use_srtp extension" \
  8407. -c "found use_srtp extension" \
  8408. -c "found srtp profile" \
  8409. -c "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_80" \
  8410. -c "DTLS-SRTP key material is"\
  8411. -C "error"
  8412. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8413. run_test "DTLS-SRTP server supports all profiles. Client supports all profiles, in different order. openssl server." \
  8414. "$O_SRV -dtls1 -verify 0 -use_srtp SRTP_AES128_CM_SHA1_32:SRTP_AES128_CM_SHA1_80 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8415. "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
  8416. 0 \
  8417. -c "client hello, adding use_srtp extension" \
  8418. -c "found use_srtp extension" \
  8419. -c "found srtp profile" \
  8420. -c "selected srtp profile" \
  8421. -c "DTLS-SRTP key material is"\
  8422. -C "error"
  8423. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8424. run_test "DTLS-SRTP server supports all profiles. Client supports one profile. openssl server." \
  8425. "$O_SRV -dtls1 -verify 0 -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8426. "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
  8427. 0 \
  8428. -c "client hello, adding use_srtp extension" \
  8429. -c "found use_srtp extension" \
  8430. -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
  8431. -c "selected srtp profile" \
  8432. -c "DTLS-SRTP key material is"\
  8433. -C "error"
  8434. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8435. run_test "DTLS-SRTP server supports one profile. Client supports all profiles. openssl server." \
  8436. "$O_SRV -dtls1 -verify 0 -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8437. "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
  8438. 0 \
  8439. -c "client hello, adding use_srtp extension" \
  8440. -c "found use_srtp extension" \
  8441. -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
  8442. -c "selected srtp profile" \
  8443. -c "DTLS-SRTP key material is"\
  8444. -C "error"
  8445. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8446. run_test "DTLS-SRTP server and Client support only one matching profile. openssl server." \
  8447. "$O_SRV -dtls1 -verify 0 -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8448. "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
  8449. 0 \
  8450. -c "client hello, adding use_srtp extension" \
  8451. -c "found use_srtp extension" \
  8452. -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
  8453. -c "selected srtp profile" \
  8454. -c "DTLS-SRTP key material is"\
  8455. -C "error"
  8456. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8457. run_test "DTLS-SRTP server and Client support only one different profile. openssl server." \
  8458. "$O_SRV -dtls1 -verify 0 -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8459. "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \
  8460. 0 \
  8461. -c "client hello, adding use_srtp extension" \
  8462. -C "found use_srtp extension" \
  8463. -C "found srtp profile" \
  8464. -C "selected srtp profile" \
  8465. -C "DTLS-SRTP key material is"\
  8466. -C "error"
  8467. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8468. run_test "DTLS-SRTP server doesn't support use_srtp extension. openssl server" \
  8469. "$O_SRV -dtls1" \
  8470. "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
  8471. 0 \
  8472. -c "client hello, adding use_srtp extension" \
  8473. -C "found use_srtp extension" \
  8474. -C "found srtp profile" \
  8475. -C "selected srtp profile" \
  8476. -C "DTLS-SRTP key material is"\
  8477. -C "error"
  8478. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8479. run_test "DTLS-SRTP all profiles supported. server doesn't support mki. openssl server." \
  8480. "$O_SRV -dtls1 -verify 0 -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8481. "$P_CLI dtls=1 use_srtp=1 mki=542310ab34290481 debug_level=3" \
  8482. 0 \
  8483. -c "client hello, adding use_srtp extension" \
  8484. -c "found use_srtp extension" \
  8485. -c "found srtp profile" \
  8486. -c "selected srtp profile" \
  8487. -c "DTLS-SRTP key material is"\
  8488. -c "DTLS-SRTP no mki value negotiated"\
  8489. -c "dumping 'sending mki' (8 bytes)" \
  8490. -C "dumping 'received mki' (8 bytes)" \
  8491. -C "error"
  8492. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8493. requires_gnutls
  8494. run_test "DTLS-SRTP all profiles supported. gnutls client." \
  8495. "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
  8496. "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_80:SRTP_AES128_CM_HMAC_SHA1_32:SRTP_NULL_HMAC_SHA1_80:SRTP_NULL_SHA1_32 --insecure 127.0.0.1" \
  8497. 0 \
  8498. -s "found use_srtp extension" \
  8499. -s "found srtp profile" \
  8500. -s "selected srtp profile" \
  8501. -s "server hello, adding use_srtp extension" \
  8502. -s "DTLS-SRTP key material is"\
  8503. -c "SRTP profile: SRTP_AES128_CM_HMAC_SHA1_80"
  8504. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8505. requires_gnutls
  8506. run_test "DTLS-SRTP server supports all profiles. Client supports all profiles, in different order. gnutls client." \
  8507. "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
  8508. "$G_CLI -u --srtp-profiles=SRTP_NULL_HMAC_SHA1_80:SRTP_AES128_CM_HMAC_SHA1_80:SRTP_NULL_SHA1_32:SRTP_AES128_CM_HMAC_SHA1_32 --insecure 127.0.0.1" \
  8509. 0 \
  8510. -s "found use_srtp extension" \
  8511. -s "found srtp profile" \
  8512. -s "selected srtp profile" \
  8513. -s "server hello, adding use_srtp extension" \
  8514. -s "DTLS-SRTP key material is"\
  8515. -c "SRTP profile: SRTP_NULL_HMAC_SHA1_80"
  8516. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8517. requires_gnutls
  8518. run_test "DTLS-SRTP server supports all profiles. Client supports one profile. gnutls client." \
  8519. "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
  8520. "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32 --insecure 127.0.0.1" \
  8521. 0 \
  8522. -s "found use_srtp extension" \
  8523. -s "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
  8524. -s "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
  8525. -s "server hello, adding use_srtp extension" \
  8526. -s "DTLS-SRTP key material is"\
  8527. -c "SRTP profile: SRTP_AES128_CM_HMAC_SHA1_32"
  8528. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8529. requires_gnutls
  8530. run_test "DTLS-SRTP server supports one profile. Client supports all profiles. gnutls client." \
  8531. "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \
  8532. "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_80:SRTP_AES128_CM_HMAC_SHA1_32:SRTP_NULL_HMAC_SHA1_80:SRTP_NULL_SHA1_32 --insecure 127.0.0.1" \
  8533. 0 \
  8534. -s "found use_srtp extension" \
  8535. -s "found srtp profile" \
  8536. -s "selected srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32" \
  8537. -s "server hello, adding use_srtp extension" \
  8538. -s "DTLS-SRTP key material is"\
  8539. -c "SRTP profile: SRTP_NULL_SHA1_32"
  8540. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8541. requires_gnutls
  8542. run_test "DTLS-SRTP server and Client support only one matching profile. gnutls client." \
  8543. "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
  8544. "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32 --insecure 127.0.0.1" \
  8545. 0 \
  8546. -s "found use_srtp extension" \
  8547. -s "found srtp profile" \
  8548. -s "selected srtp profile" \
  8549. -s "server hello, adding use_srtp extension" \
  8550. -s "DTLS-SRTP key material is"\
  8551. -c "SRTP profile: SRTP_AES128_CM_HMAC_SHA1_32"
  8552. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8553. requires_gnutls
  8554. run_test "DTLS-SRTP server and Client support only one different profile. gnutls client." \
  8555. "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=1 debug_level=3" \
  8556. "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32 --insecure 127.0.0.1" \
  8557. 0 \
  8558. -s "found use_srtp extension" \
  8559. -s "found srtp profile" \
  8560. -S "selected srtp profile" \
  8561. -S "server hello, adding use_srtp extension" \
  8562. -S "DTLS-SRTP key material is"\
  8563. -C "SRTP profile:"
  8564. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8565. requires_gnutls
  8566. run_test "DTLS-SRTP server doesn't support use_srtp extension. gnutls client" \
  8567. "$P_SRV dtls=1 debug_level=3" \
  8568. "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_80:SRTP_AES128_CM_HMAC_SHA1_32:SRTP_NULL_HMAC_SHA1_80:SRTP_NULL_SHA1_32 --insecure 127.0.0.1" \
  8569. 0 \
  8570. -s "found use_srtp extension" \
  8571. -S "server hello, adding use_srtp extension" \
  8572. -S "DTLS-SRTP key material is"\
  8573. -C "SRTP profile:"
  8574. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8575. requires_gnutls
  8576. run_test "DTLS-SRTP all profiles supported. gnutls server" \
  8577. "$G_SRV -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_80:SRTP_AES128_CM_HMAC_SHA1_32:SRTP_NULL_HMAC_SHA1_80:SRTP_NULL_SHA1_32" \
  8578. "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
  8579. 0 \
  8580. -c "client hello, adding use_srtp extension" \
  8581. -c "found use_srtp extension" \
  8582. -c "found srtp profile" \
  8583. -c "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_80" \
  8584. -c "DTLS-SRTP key material is"\
  8585. -C "error"
  8586. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8587. requires_gnutls
  8588. run_test "DTLS-SRTP server supports all profiles. Client supports all profiles, in different order. gnutls server." \
  8589. "$G_SRV -u --srtp-profiles=SRTP_NULL_SHA1_32:SRTP_AES128_CM_HMAC_SHA1_32:SRTP_AES128_CM_HMAC_SHA1_80:SRTP_NULL_HMAC_SHA1_80:SRTP_NULL_SHA1_32" \
  8590. "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
  8591. 0 \
  8592. -c "client hello, adding use_srtp extension" \
  8593. -c "found use_srtp extension" \
  8594. -c "found srtp profile" \
  8595. -c "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_80" \
  8596. -c "DTLS-SRTP key material is"\
  8597. -C "error"
  8598. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8599. requires_gnutls
  8600. run_test "DTLS-SRTP server supports all profiles. Client supports one profile. gnutls server." \
  8601. "$G_SRV -u --srtp-profiles=SRTP_NULL_SHA1_32:SRTP_AES128_CM_HMAC_SHA1_32:SRTP_AES128_CM_HMAC_SHA1_80:SRTP_NULL_HMAC_SHA1_80:SRTP_NULL_SHA1_32" \
  8602. "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
  8603. 0 \
  8604. -c "client hello, adding use_srtp extension" \
  8605. -c "found use_srtp extension" \
  8606. -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
  8607. -c "selected srtp profile" \
  8608. -c "DTLS-SRTP key material is"\
  8609. -C "error"
  8610. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8611. requires_gnutls
  8612. run_test "DTLS-SRTP server supports one profile. Client supports all profiles. gnutls server." \
  8613. "$G_SRV -u --srtp-profiles=SRTP_NULL_HMAC_SHA1_80" \
  8614. "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
  8615. 0 \
  8616. -c "client hello, adding use_srtp extension" \
  8617. -c "found use_srtp extension" \
  8618. -c "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80" \
  8619. -c "selected srtp profile" \
  8620. -c "DTLS-SRTP key material is"\
  8621. -C "error"
  8622. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8623. requires_gnutls
  8624. run_test "DTLS-SRTP server and Client support only one matching profile. gnutls server." \
  8625. "$G_SRV -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32" \
  8626. "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
  8627. 0 \
  8628. -c "client hello, adding use_srtp extension" \
  8629. -c "found use_srtp extension" \
  8630. -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
  8631. -c "selected srtp profile" \
  8632. -c "DTLS-SRTP key material is"\
  8633. -C "error"
  8634. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8635. requires_gnutls
  8636. run_test "DTLS-SRTP server and Client support only one different profile. gnutls server." \
  8637. "$G_SRV -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32" \
  8638. "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \
  8639. 0 \
  8640. -c "client hello, adding use_srtp extension" \
  8641. -C "found use_srtp extension" \
  8642. -C "found srtp profile" \
  8643. -C "selected srtp profile" \
  8644. -C "DTLS-SRTP key material is"\
  8645. -C "error"
  8646. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8647. requires_gnutls
  8648. run_test "DTLS-SRTP server doesn't support use_srtp extension. gnutls server" \
  8649. "$G_SRV -u" \
  8650. "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
  8651. 0 \
  8652. -c "client hello, adding use_srtp extension" \
  8653. -C "found use_srtp extension" \
  8654. -C "found srtp profile" \
  8655. -C "selected srtp profile" \
  8656. -C "DTLS-SRTP key material is"\
  8657. -C "error"
  8658. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8659. requires_gnutls
  8660. run_test "DTLS-SRTP all profiles supported. mki used. gnutls server." \
  8661. "$G_SRV -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_80:SRTP_AES128_CM_HMAC_SHA1_32:SRTP_NULL_HMAC_SHA1_80:SRTP_NULL_SHA1_32" \
  8662. "$P_CLI dtls=1 use_srtp=1 mki=542310ab34290481 debug_level=3" \
  8663. 0 \
  8664. -c "client hello, adding use_srtp extension" \
  8665. -c "found use_srtp extension" \
  8666. -c "found srtp profile" \
  8667. -c "selected srtp profile" \
  8668. -c "DTLS-SRTP key material is"\
  8669. -c "DTLS-SRTP mki value:"\
  8670. -c "dumping 'sending mki' (8 bytes)" \
  8671. -c "dumping 'received mki' (8 bytes)" \
  8672. -C "error"
  8673. # Tests for specific things with "unreliable" UDP connection
  8674. not_with_valgrind # spurious resend due to timeout
  8675. run_test "DTLS proxy: reference" \
  8676. -p "$P_PXY" \
  8677. "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
  8678. "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
  8679. 0 \
  8680. -C "replayed record" \
  8681. -S "replayed record" \
  8682. -C "Buffer record from epoch" \
  8683. -S "Buffer record from epoch" \
  8684. -C "ssl_buffer_message" \
  8685. -S "ssl_buffer_message" \
  8686. -C "discarding invalid record" \
  8687. -S "discarding invalid record" \
  8688. -S "resend" \
  8689. -s "Extra-header:" \
  8690. -c "HTTP/1.0 200 OK"
  8691. not_with_valgrind # spurious resend due to timeout
  8692. run_test "DTLS proxy: duplicate every packet" \
  8693. -p "$P_PXY duplicate=1" \
  8694. "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
  8695. "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
  8696. 0 \
  8697. -c "replayed record" \
  8698. -s "replayed record" \
  8699. -c "record from another epoch" \
  8700. -s "record from another epoch" \
  8701. -S "resend" \
  8702. -s "Extra-header:" \
  8703. -c "HTTP/1.0 200 OK"
  8704. run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
  8705. -p "$P_PXY duplicate=1" \
  8706. "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
  8707. "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
  8708. 0 \
  8709. -c "replayed record" \
  8710. -S "replayed record" \
  8711. -c "record from another epoch" \
  8712. -s "record from another epoch" \
  8713. -c "resend" \
  8714. -s "resend" \
  8715. -s "Extra-header:" \
  8716. -c "HTTP/1.0 200 OK"
  8717. run_test "DTLS proxy: multiple records in same datagram" \
  8718. -p "$P_PXY pack=50" \
  8719. "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
  8720. "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
  8721. 0 \
  8722. -c "next record in same datagram" \
  8723. -s "next record in same datagram"
  8724. run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
  8725. -p "$P_PXY pack=50 duplicate=1" \
  8726. "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
  8727. "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
  8728. 0 \
  8729. -c "next record in same datagram" \
  8730. -s "next record in same datagram"
  8731. run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
  8732. -p "$P_PXY bad_ad=1" \
  8733. "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
  8734. "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
  8735. 0 \
  8736. -c "discarding invalid record (mac)" \
  8737. -s "discarding invalid record (mac)" \
  8738. -s "Extra-header:" \
  8739. -c "HTTP/1.0 200 OK" \
  8740. -S "too many records with bad MAC" \
  8741. -S "Verification of the message MAC failed"
  8742. run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
  8743. -p "$P_PXY bad_ad=1" \
  8744. "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
  8745. "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
  8746. 1 \
  8747. -C "discarding invalid record (mac)" \
  8748. -S "discarding invalid record (mac)" \
  8749. -S "Extra-header:" \
  8750. -C "HTTP/1.0 200 OK" \
  8751. -s "too many records with bad MAC" \
  8752. -s "Verification of the message MAC failed"
  8753. run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
  8754. -p "$P_PXY bad_ad=1" \
  8755. "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
  8756. "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
  8757. 0 \
  8758. -c "discarding invalid record (mac)" \
  8759. -s "discarding invalid record (mac)" \
  8760. -s "Extra-header:" \
  8761. -c "HTTP/1.0 200 OK" \
  8762. -S "too many records with bad MAC" \
  8763. -S "Verification of the message MAC failed"
  8764. run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
  8765. -p "$P_PXY bad_ad=1" \
  8766. "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
  8767. "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
  8768. 1 \
  8769. -c "discarding invalid record (mac)" \
  8770. -s "discarding invalid record (mac)" \
  8771. -s "Extra-header:" \
  8772. -c "HTTP/1.0 200 OK" \
  8773. -s "too many records with bad MAC" \
  8774. -s "Verification of the message MAC failed"
  8775. run_test "DTLS proxy: delay ChangeCipherSpec" \
  8776. -p "$P_PXY delay_ccs=1" \
  8777. "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
  8778. "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
  8779. 0 \
  8780. -c "record from another epoch" \
  8781. -s "record from another epoch" \
  8782. -s "Extra-header:" \
  8783. -c "HTTP/1.0 200 OK"
  8784. # Tests for reordering support with DTLS
  8785. run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
  8786. -p "$P_PXY delay_srv=ServerHello" \
  8787. "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
  8788. hs_timeout=2500-60000" \
  8789. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  8790. hs_timeout=2500-60000" \
  8791. 0 \
  8792. -c "Buffering HS message" \
  8793. -c "Next handshake message has been buffered - load"\
  8794. -S "Buffering HS message" \
  8795. -S "Next handshake message has been buffered - load"\
  8796. -C "Injecting buffered CCS message" \
  8797. -C "Remember CCS message" \
  8798. -S "Injecting buffered CCS message" \
  8799. -S "Remember CCS message"
  8800. run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
  8801. -p "$P_PXY delay_srv=ServerHello" \
  8802. "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
  8803. hs_timeout=2500-60000" \
  8804. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  8805. hs_timeout=2500-60000" \
  8806. 0 \
  8807. -c "Buffering HS message" \
  8808. -c "found fragmented DTLS handshake message"\
  8809. -c "Next handshake message 1 not or only partially bufffered" \
  8810. -c "Next handshake message has been buffered - load"\
  8811. -S "Buffering HS message" \
  8812. -S "Next handshake message has been buffered - load"\
  8813. -C "Injecting buffered CCS message" \
  8814. -C "Remember CCS message" \
  8815. -S "Injecting buffered CCS message" \
  8816. -S "Remember CCS message"
  8817. # The client buffers the ServerKeyExchange before receiving the fragmented
  8818. # Certificate message; at the time of writing, together these are aroudn 1200b
  8819. # in size, so that the bound below ensures that the certificate can be reassembled
  8820. # while keeping the ServerKeyExchange.
  8821. requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
  8822. run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
  8823. -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
  8824. "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
  8825. hs_timeout=2500-60000" \
  8826. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  8827. hs_timeout=2500-60000" \
  8828. 0 \
  8829. -c "Buffering HS message" \
  8830. -c "Next handshake message has been buffered - load"\
  8831. -C "attempt to make space by freeing buffered messages" \
  8832. -S "Buffering HS message" \
  8833. -S "Next handshake message has been buffered - load"\
  8834. -C "Injecting buffered CCS message" \
  8835. -C "Remember CCS message" \
  8836. -S "Injecting buffered CCS message" \
  8837. -S "Remember CCS message"
  8838. # The size constraints ensure that the delayed certificate message can't
  8839. # be reassembled while keeping the ServerKeyExchange message, but it can
  8840. # when dropping it first.
  8841. requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
  8842. requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
  8843. run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
  8844. -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
  8845. "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
  8846. hs_timeout=2500-60000" \
  8847. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  8848. hs_timeout=2500-60000" \
  8849. 0 \
  8850. -c "Buffering HS message" \
  8851. -c "attempt to make space by freeing buffered future messages" \
  8852. -c "Enough space available after freeing buffered HS messages" \
  8853. -S "Buffering HS message" \
  8854. -S "Next handshake message has been buffered - load"\
  8855. -C "Injecting buffered CCS message" \
  8856. -C "Remember CCS message" \
  8857. -S "Injecting buffered CCS message" \
  8858. -S "Remember CCS message"
  8859. run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
  8860. -p "$P_PXY delay_cli=Certificate" \
  8861. "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
  8862. hs_timeout=2500-60000" \
  8863. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  8864. hs_timeout=2500-60000" \
  8865. 0 \
  8866. -C "Buffering HS message" \
  8867. -C "Next handshake message has been buffered - load"\
  8868. -s "Buffering HS message" \
  8869. -s "Next handshake message has been buffered - load" \
  8870. -C "Injecting buffered CCS message" \
  8871. -C "Remember CCS message" \
  8872. -S "Injecting buffered CCS message" \
  8873. -S "Remember CCS message"
  8874. run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
  8875. -p "$P_PXY delay_srv=NewSessionTicket" \
  8876. "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
  8877. hs_timeout=2500-60000" \
  8878. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  8879. hs_timeout=2500-60000" \
  8880. 0 \
  8881. -C "Buffering HS message" \
  8882. -C "Next handshake message has been buffered - load"\
  8883. -S "Buffering HS message" \
  8884. -S "Next handshake message has been buffered - load" \
  8885. -c "Injecting buffered CCS message" \
  8886. -c "Remember CCS message" \
  8887. -S "Injecting buffered CCS message" \
  8888. -S "Remember CCS message"
  8889. run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
  8890. -p "$P_PXY delay_cli=ClientKeyExchange" \
  8891. "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
  8892. hs_timeout=2500-60000" \
  8893. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  8894. hs_timeout=2500-60000" \
  8895. 0 \
  8896. -C "Buffering HS message" \
  8897. -C "Next handshake message has been buffered - load"\
  8898. -S "Buffering HS message" \
  8899. -S "Next handshake message has been buffered - load" \
  8900. -C "Injecting buffered CCS message" \
  8901. -C "Remember CCS message" \
  8902. -s "Injecting buffered CCS message" \
  8903. -s "Remember CCS message"
  8904. run_test "DTLS reordering: Buffer encrypted Finished message" \
  8905. -p "$P_PXY delay_ccs=1" \
  8906. "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
  8907. hs_timeout=2500-60000" \
  8908. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  8909. hs_timeout=2500-60000" \
  8910. 0 \
  8911. -s "Buffer record from epoch 1" \
  8912. -s "Found buffered record from current epoch - load" \
  8913. -c "Buffer record from epoch 1" \
  8914. -c "Found buffered record from current epoch - load"
  8915. # In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
  8916. # from the server are delayed, so that the encrypted Finished message
  8917. # is received and buffered. When the fragmented NewSessionTicket comes
  8918. # in afterwards, the encrypted Finished message must be freed in order
  8919. # to make space for the NewSessionTicket to be reassembled.
  8920. # This works only in very particular circumstances:
  8921. # - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
  8922. # of the NewSessionTicket, but small enough to also allow buffering of
  8923. # the encrypted Finished message.
  8924. # - The MTU setting on the server must be so small that the NewSessionTicket
  8925. # needs to be fragmented.
  8926. # - All messages sent by the server must be small enough to be either sent
  8927. # without fragmentation or be reassembled within the bounds of
  8928. # MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
  8929. # handshake, omitting CRTs.
  8930. requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 190
  8931. requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 230
  8932. run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
  8933. -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
  8934. "$P_SRV mtu=140 response_size=90 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
  8935. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
  8936. 0 \
  8937. -s "Buffer record from epoch 1" \
  8938. -s "Found buffered record from current epoch - load" \
  8939. -c "Buffer record from epoch 1" \
  8940. -C "Found buffered record from current epoch - load" \
  8941. -c "Enough space available after freeing future epoch record"
  8942. # Tests for "randomly unreliable connection": try a variety of flows and peers
  8943. client_needs_more_time 2
  8944. run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
  8945. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  8946. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
  8947. psk=abc123" \
  8948. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
  8949. force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
  8950. 0 \
  8951. -s "Extra-header:" \
  8952. -c "HTTP/1.0 200 OK"
  8953. client_needs_more_time 2
  8954. run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
  8955. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  8956. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
  8957. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
  8958. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  8959. 0 \
  8960. -s "Extra-header:" \
  8961. -c "HTTP/1.0 200 OK"
  8962. client_needs_more_time 2
  8963. run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
  8964. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  8965. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
  8966. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
  8967. 0 \
  8968. -s "Extra-header:" \
  8969. -c "HTTP/1.0 200 OK"
  8970. client_needs_more_time 2
  8971. run_test "DTLS proxy: 3d, FS, client auth" \
  8972. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  8973. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
  8974. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
  8975. 0 \
  8976. -s "Extra-header:" \
  8977. -c "HTTP/1.0 200 OK"
  8978. client_needs_more_time 2
  8979. run_test "DTLS proxy: 3d, FS, ticket" \
  8980. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  8981. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
  8982. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
  8983. 0 \
  8984. -s "Extra-header:" \
  8985. -c "HTTP/1.0 200 OK"
  8986. client_needs_more_time 2
  8987. run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
  8988. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  8989. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
  8990. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
  8991. 0 \
  8992. -s "Extra-header:" \
  8993. -c "HTTP/1.0 200 OK"
  8994. client_needs_more_time 2
  8995. run_test "DTLS proxy: 3d, max handshake, nbio" \
  8996. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  8997. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
  8998. auth_mode=required" \
  8999. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
  9000. 0 \
  9001. -s "Extra-header:" \
  9002. -c "HTTP/1.0 200 OK"
  9003. client_needs_more_time 4
  9004. run_test "DTLS proxy: 3d, min handshake, resumption" \
  9005. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  9006. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
  9007. psk=abc123 debug_level=3" \
  9008. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
  9009. debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
  9010. force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
  9011. 0 \
  9012. -s "a session has been resumed" \
  9013. -c "a session has been resumed" \
  9014. -s "Extra-header:" \
  9015. -c "HTTP/1.0 200 OK"
  9016. client_needs_more_time 4
  9017. run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
  9018. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  9019. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
  9020. psk=abc123 debug_level=3 nbio=2" \
  9021. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
  9022. debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
  9023. force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
  9024. 0 \
  9025. -s "a session has been resumed" \
  9026. -c "a session has been resumed" \
  9027. -s "Extra-header:" \
  9028. -c "HTTP/1.0 200 OK"
  9029. client_needs_more_time 4
  9030. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  9031. run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
  9032. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  9033. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
  9034. psk=abc123 renegotiation=1 debug_level=2" \
  9035. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
  9036. renegotiate=1 debug_level=2 \
  9037. force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
  9038. 0 \
  9039. -c "=> renegotiate" \
  9040. -s "=> renegotiate" \
  9041. -s "Extra-header:" \
  9042. -c "HTTP/1.0 200 OK"
  9043. client_needs_more_time 4
  9044. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  9045. run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
  9046. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  9047. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
  9048. psk=abc123 renegotiation=1 debug_level=2" \
  9049. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
  9050. renegotiate=1 debug_level=2 \
  9051. force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
  9052. 0 \
  9053. -c "=> renegotiate" \
  9054. -s "=> renegotiate" \
  9055. -s "Extra-header:" \
  9056. -c "HTTP/1.0 200 OK"
  9057. client_needs_more_time 4
  9058. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  9059. run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
  9060. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  9061. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
  9062. psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
  9063. debug_level=2" \
  9064. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
  9065. renegotiation=1 exchanges=4 debug_level=2 \
  9066. force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
  9067. 0 \
  9068. -c "=> renegotiate" \
  9069. -s "=> renegotiate" \
  9070. -s "Extra-header:" \
  9071. -c "HTTP/1.0 200 OK"
  9072. client_needs_more_time 4
  9073. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  9074. run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
  9075. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  9076. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
  9077. psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
  9078. debug_level=2 nbio=2" \
  9079. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
  9080. renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
  9081. force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
  9082. 0 \
  9083. -c "=> renegotiate" \
  9084. -s "=> renegotiate" \
  9085. -s "Extra-header:" \
  9086. -c "HTTP/1.0 200 OK"
  9087. ## Interop tests with OpenSSL might trigger a bug in recent versions (including
  9088. ## all versions installed on the CI machines), reported here:
  9089. ## Bug report: https://github.com/openssl/openssl/issues/6902
  9090. ## They should be re-enabled once a fixed version of OpenSSL is available
  9091. ## (this should happen in some 1.1.1_ release according to the ticket).
  9092. skip_next_test
  9093. client_needs_more_time 6
  9094. not_with_valgrind # risk of non-mbedtls peer timing out
  9095. run_test "DTLS proxy: 3d, openssl server" \
  9096. -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
  9097. "$O_SRV -dtls1 -mtu 2048" \
  9098. "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
  9099. 0 \
  9100. -c "HTTP/1.0 200 OK"
  9101. skip_next_test # see above
  9102. client_needs_more_time 8
  9103. not_with_valgrind # risk of non-mbedtls peer timing out
  9104. run_test "DTLS proxy: 3d, openssl server, fragmentation" \
  9105. -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
  9106. "$O_SRV -dtls1 -mtu 768" \
  9107. "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
  9108. 0 \
  9109. -c "HTTP/1.0 200 OK"
  9110. skip_next_test # see above
  9111. client_needs_more_time 8
  9112. not_with_valgrind # risk of non-mbedtls peer timing out
  9113. run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
  9114. -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
  9115. "$O_SRV -dtls1 -mtu 768" \
  9116. "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
  9117. 0 \
  9118. -c "HTTP/1.0 200 OK"
  9119. requires_gnutls
  9120. client_needs_more_time 6
  9121. not_with_valgrind # risk of non-mbedtls peer timing out
  9122. run_test "DTLS proxy: 3d, gnutls server" \
  9123. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  9124. "$G_SRV -u --mtu 2048 -a" \
  9125. "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
  9126. 0 \
  9127. -s "Extra-header:" \
  9128. -c "Extra-header:"
  9129. requires_gnutls_next
  9130. client_needs_more_time 8
  9131. not_with_valgrind # risk of non-mbedtls peer timing out
  9132. run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
  9133. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  9134. "$G_NEXT_SRV -u --mtu 512" \
  9135. "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
  9136. 0 \
  9137. -s "Extra-header:" \
  9138. -c "Extra-header:"
  9139. requires_gnutls_next
  9140. client_needs_more_time 8
  9141. not_with_valgrind # risk of non-mbedtls peer timing out
  9142. run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
  9143. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  9144. "$G_NEXT_SRV -u --mtu 512" \
  9145. "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
  9146. 0 \
  9147. -s "Extra-header:" \
  9148. -c "Extra-header:"
  9149. requires_config_enabled MBEDTLS_SSL_EXPORT_KEYS
  9150. run_test "export keys functionality" \
  9151. "$P_SRV eap_tls=1 debug_level=3" \
  9152. "$P_CLI eap_tls=1 debug_level=3" \
  9153. 0 \
  9154. -s "exported maclen is " \
  9155. -s "exported keylen is " \
  9156. -s "exported ivlen is " \
  9157. -c "exported maclen is " \
  9158. -c "exported keylen is " \
  9159. -c "exported ivlen is " \
  9160. -c "EAP-TLS key material is:"\
  9161. -s "EAP-TLS key material is:"\
  9162. -c "EAP-TLS IV is:" \
  9163. -s "EAP-TLS IV is:"
  9164. # Test heap memory usage after handshake
  9165. requires_config_enabled MBEDTLS_MEMORY_DEBUG
  9166. requires_config_enabled MBEDTLS_MEMORY_BUFFER_ALLOC_C
  9167. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  9168. requires_max_content_len 16384
  9169. run_tests_memory_after_hanshake
  9170. # Final report
  9171. echo "------------------------------------------------------------------------"
  9172. if [ $FAILS = 0 ]; then
  9173. printf "PASSED"
  9174. else
  9175. printf "FAILED"
  9176. fi
  9177. PASSES=$(( $TESTS - $FAILS ))
  9178. echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
  9179. exit $FAILS