ssl-opt.sh 433 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824
  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 "${GNUTLS_NEXT_SERV:-}" ]; then
  71. G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
  72. else
  73. G_NEXT_SRV=false
  74. fi
  75. if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
  76. G_NEXT_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_NEXT_CLI --x509cafile data_files/test-ca_cat12.crt"
  77. else
  78. G_NEXT_CLI=false
  79. fi
  80. TESTS=0
  81. FAILS=0
  82. SKIPS=0
  83. CONFIG_H='../include/mbedtls/config.h'
  84. MEMCHECK=0
  85. FILTER='.*'
  86. EXCLUDE='^$'
  87. SHOW_TEST_NUMBER=0
  88. RUN_TEST_NUMBER=''
  89. PRESERVE_LOGS=0
  90. # Pick a "unique" server port in the range 10000-19999, and a proxy
  91. # port which is this plus 10000. Each port number may be independently
  92. # overridden by a command line option.
  93. SRV_PORT=$(($$ % 10000 + 10000))
  94. PXY_PORT=$((SRV_PORT + 10000))
  95. print_usage() {
  96. echo "Usage: $0 [options]"
  97. printf " -h|--help\tPrint this help.\n"
  98. printf " -m|--memcheck\tCheck memory leaks and errors.\n"
  99. printf " -f|--filter\tOnly matching tests are executed (BRE)\n"
  100. printf " -e|--exclude\tMatching tests are excluded (BRE)\n"
  101. printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
  102. printf " -s|--show-numbers\tShow test numbers in front of test names\n"
  103. printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
  104. printf " --outcome-file\tFile where test outcomes are written\n"
  105. printf " \t(default: \$MBEDTLS_TEST_OUTCOME_FILE, none if empty)\n"
  106. printf " --port \tTCP/UDP port (default: randomish 1xxxx)\n"
  107. printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
  108. printf " --seed \tInteger seed value to use for this test run\n"
  109. }
  110. get_options() {
  111. while [ $# -gt 0 ]; do
  112. case "$1" in
  113. -f|--filter)
  114. shift; FILTER=$1
  115. ;;
  116. -e|--exclude)
  117. shift; EXCLUDE=$1
  118. ;;
  119. -m|--memcheck)
  120. MEMCHECK=1
  121. ;;
  122. -n|--number)
  123. shift; RUN_TEST_NUMBER=$1
  124. ;;
  125. -s|--show-numbers)
  126. SHOW_TEST_NUMBER=1
  127. ;;
  128. -p|--preserve-logs)
  129. PRESERVE_LOGS=1
  130. ;;
  131. --port)
  132. shift; SRV_PORT=$1
  133. ;;
  134. --proxy-port)
  135. shift; PXY_PORT=$1
  136. ;;
  137. --seed)
  138. shift; SEED="$1"
  139. ;;
  140. -h|--help)
  141. print_usage
  142. exit 0
  143. ;;
  144. *)
  145. echo "Unknown argument: '$1'"
  146. print_usage
  147. exit 1
  148. ;;
  149. esac
  150. shift
  151. done
  152. }
  153. # Make the outcome file path relative to the original directory, not
  154. # to .../tests
  155. case "$MBEDTLS_TEST_OUTCOME_FILE" in
  156. [!/]*)
  157. MBEDTLS_TEST_OUTCOME_FILE="$ORIGINAL_PWD/$MBEDTLS_TEST_OUTCOME_FILE"
  158. ;;
  159. esac
  160. # Skip next test; use this macro to skip tests which are legitimate
  161. # in theory and expected to be re-introduced at some point, but
  162. # aren't expected to succeed at the moment due to problems outside
  163. # our control (such as bugs in other TLS implementations).
  164. skip_next_test() {
  165. SKIP_NEXT="YES"
  166. }
  167. # skip next test if the flag is not enabled in config.h
  168. requires_config_enabled() {
  169. if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
  170. SKIP_NEXT="YES"
  171. fi
  172. }
  173. # skip next test if the flag is enabled in config.h
  174. requires_config_disabled() {
  175. if grep "^#define $1" $CONFIG_H > /dev/null; then
  176. SKIP_NEXT="YES"
  177. fi
  178. }
  179. get_config_value_or_default() {
  180. # This function uses the query_config command line option to query the
  181. # required Mbed TLS compile time configuration from the ssl_server2
  182. # program. The command will always return a success value if the
  183. # configuration is defined and the value will be printed to stdout.
  184. #
  185. # Note that if the configuration is not defined or is defined to nothing,
  186. # the output of this function will be an empty string.
  187. ${P_SRV} "query_config=${1}"
  188. }
  189. requires_config_value_at_least() {
  190. VAL="$( get_config_value_or_default "$1" )"
  191. if [ -z "$VAL" ]; then
  192. # Should never happen
  193. echo "Mbed TLS configuration $1 is not defined"
  194. exit 1
  195. elif [ "$VAL" -lt "$2" ]; then
  196. SKIP_NEXT="YES"
  197. fi
  198. }
  199. requires_config_value_at_most() {
  200. VAL=$( get_config_value_or_default "$1" )
  201. if [ -z "$VAL" ]; then
  202. # Should never happen
  203. echo "Mbed TLS configuration $1 is not defined"
  204. exit 1
  205. elif [ "$VAL" -gt "$2" ]; then
  206. SKIP_NEXT="YES"
  207. fi
  208. }
  209. requires_ciphersuite_enabled() {
  210. if [ -z "$($P_CLI --help 2>/dev/null | grep $1)" ]; then
  211. SKIP_NEXT="YES"
  212. fi
  213. }
  214. # maybe_requires_ciphersuite_enabled CMD [RUN_TEST_OPTION...]
  215. # If CMD (call to a TLS client or server program) requires a specific
  216. # ciphersuite, arrange to only run the test case if this ciphersuite is
  217. # enabled. As an exception, do run the test case if it expects a ciphersuite
  218. # mismatch.
  219. maybe_requires_ciphersuite_enabled() {
  220. case "$1" in
  221. *\ force_ciphersuite=*) :;;
  222. *) return;; # No specific required ciphersuite
  223. esac
  224. ciphersuite="${1##*\ force_ciphersuite=}"
  225. ciphersuite="${ciphersuite%%[!-0-9A-Z_a-z]*}"
  226. shift
  227. case "$*" in
  228. *"-s SSL - The server has no ciphersuites in common"*)
  229. # This test case expects a ciphersuite mismatch, so it doesn't
  230. # require the ciphersuite to be enabled.
  231. ;;
  232. *)
  233. requires_ciphersuite_enabled "$ciphersuite"
  234. ;;
  235. esac
  236. unset ciphersuite
  237. }
  238. # skip next test if OpenSSL doesn't support FALLBACK_SCSV
  239. requires_openssl_with_fallback_scsv() {
  240. if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
  241. if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
  242. then
  243. OPENSSL_HAS_FBSCSV="YES"
  244. else
  245. OPENSSL_HAS_FBSCSV="NO"
  246. fi
  247. fi
  248. if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
  249. SKIP_NEXT="YES"
  250. fi
  251. }
  252. # skip next test if GnuTLS isn't available
  253. requires_gnutls() {
  254. if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
  255. if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
  256. GNUTLS_AVAILABLE="YES"
  257. else
  258. GNUTLS_AVAILABLE="NO"
  259. fi
  260. fi
  261. if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
  262. SKIP_NEXT="YES"
  263. fi
  264. }
  265. # skip next test if GnuTLS-next isn't available
  266. requires_gnutls_next() {
  267. if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
  268. if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
  269. GNUTLS_NEXT_AVAILABLE="YES"
  270. else
  271. GNUTLS_NEXT_AVAILABLE="NO"
  272. fi
  273. fi
  274. if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
  275. SKIP_NEXT="YES"
  276. fi
  277. }
  278. # skip next test if OpenSSL-legacy isn't available
  279. requires_openssl_legacy() {
  280. if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
  281. if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
  282. OPENSSL_LEGACY_AVAILABLE="YES"
  283. else
  284. OPENSSL_LEGACY_AVAILABLE="NO"
  285. fi
  286. fi
  287. if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
  288. SKIP_NEXT="YES"
  289. fi
  290. }
  291. # skip next test if IPv6 isn't available on this host
  292. requires_ipv6() {
  293. if [ -z "${HAS_IPV6:-}" ]; then
  294. $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
  295. SRV_PID=$!
  296. sleep 1
  297. kill $SRV_PID >/dev/null 2>&1
  298. if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
  299. HAS_IPV6="NO"
  300. else
  301. HAS_IPV6="YES"
  302. fi
  303. rm -r $SRV_OUT
  304. fi
  305. if [ "$HAS_IPV6" = "NO" ]; then
  306. SKIP_NEXT="YES"
  307. fi
  308. }
  309. # skip next test if it's i686 or uname is not available
  310. requires_not_i686() {
  311. if [ -z "${IS_I686:-}" ]; then
  312. IS_I686="YES"
  313. if which "uname" >/dev/null 2>&1; then
  314. if [ -z "$(uname -a | grep i686)" ]; then
  315. IS_I686="NO"
  316. fi
  317. fi
  318. fi
  319. if [ "$IS_I686" = "YES" ]; then
  320. SKIP_NEXT="YES"
  321. fi
  322. }
  323. # Calculate the input & output maximum content lengths set in the config
  324. MAX_CONTENT_LEN=$( ../scripts/config.py get MBEDTLS_SSL_MAX_CONTENT_LEN || echo "16384")
  325. MAX_IN_LEN=$( ../scripts/config.py get MBEDTLS_SSL_IN_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
  326. MAX_OUT_LEN=$( ../scripts/config.py get MBEDTLS_SSL_OUT_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
  327. if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
  328. MAX_CONTENT_LEN="$MAX_IN_LEN"
  329. fi
  330. if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
  331. MAX_CONTENT_LEN="$MAX_OUT_LEN"
  332. fi
  333. # skip the next test if the SSL output buffer is less than 16KB
  334. requires_full_size_output_buffer() {
  335. if [ "$MAX_OUT_LEN" -ne 16384 ]; then
  336. SKIP_NEXT="YES"
  337. fi
  338. }
  339. # skip the next test if valgrind is in use
  340. not_with_valgrind() {
  341. if [ "$MEMCHECK" -gt 0 ]; then
  342. SKIP_NEXT="YES"
  343. fi
  344. }
  345. # skip the next test if valgrind is NOT in use
  346. only_with_valgrind() {
  347. if [ "$MEMCHECK" -eq 0 ]; then
  348. SKIP_NEXT="YES"
  349. fi
  350. }
  351. # multiply the client timeout delay by the given factor for the next test
  352. client_needs_more_time() {
  353. CLI_DELAY_FACTOR=$1
  354. }
  355. # wait for the given seconds after the client finished in the next test
  356. server_needs_more_time() {
  357. SRV_DELAY_SECONDS=$1
  358. }
  359. # print_name <name>
  360. print_name() {
  361. TESTS=$(( $TESTS + 1 ))
  362. LINE=""
  363. if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
  364. LINE="$TESTS "
  365. fi
  366. LINE="$LINE$1"
  367. printf "%s " "$LINE"
  368. LEN=$(( 72 - `echo "$LINE" | wc -c` ))
  369. for i in `seq 1 $LEN`; do printf '.'; done
  370. printf ' '
  371. }
  372. # record_outcome <outcome> [<failure-reason>]
  373. # The test name must be in $NAME.
  374. record_outcome() {
  375. echo "$1"
  376. if [ -n "$MBEDTLS_TEST_OUTCOME_FILE" ]; then
  377. printf '%s;%s;%s;%s;%s;%s\n' \
  378. "$MBEDTLS_TEST_PLATFORM" "$MBEDTLS_TEST_CONFIGURATION" \
  379. "ssl-opt" "$NAME" \
  380. "$1" "${2-}" \
  381. >>"$MBEDTLS_TEST_OUTCOME_FILE"
  382. fi
  383. }
  384. # fail <message>
  385. fail() {
  386. record_outcome "FAIL" "$1"
  387. echo " ! $1"
  388. mv $SRV_OUT o-srv-${TESTS}.log
  389. mv $CLI_OUT o-cli-${TESTS}.log
  390. if [ -n "$PXY_CMD" ]; then
  391. mv $PXY_OUT o-pxy-${TESTS}.log
  392. fi
  393. echo " ! outputs saved to o-XXX-${TESTS}.log"
  394. if [ "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
  395. echo " ! server output:"
  396. cat o-srv-${TESTS}.log
  397. echo " ! ========================================================"
  398. echo " ! client output:"
  399. cat o-cli-${TESTS}.log
  400. if [ -n "$PXY_CMD" ]; then
  401. echo " ! ========================================================"
  402. echo " ! proxy output:"
  403. cat o-pxy-${TESTS}.log
  404. fi
  405. echo ""
  406. fi
  407. FAILS=$(( $FAILS + 1 ))
  408. }
  409. # is_polar <cmd_line>
  410. is_polar() {
  411. echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
  412. }
  413. # openssl s_server doesn't have -www with DTLS
  414. check_osrv_dtls() {
  415. if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
  416. NEEDS_INPUT=1
  417. SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
  418. else
  419. NEEDS_INPUT=0
  420. fi
  421. }
  422. # provide input to commands that need it
  423. provide_input() {
  424. if [ $NEEDS_INPUT -eq 0 ]; then
  425. return
  426. fi
  427. while true; do
  428. echo "HTTP/1.0 200 OK"
  429. sleep 1
  430. done
  431. }
  432. # has_mem_err <log_file_name>
  433. has_mem_err() {
  434. if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
  435. grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
  436. then
  437. return 1 # false: does not have errors
  438. else
  439. return 0 # true: has errors
  440. fi
  441. }
  442. # Wait for process $2 named $3 to be listening on port $1. Print error to $4.
  443. if type lsof >/dev/null 2>/dev/null; then
  444. wait_app_start() {
  445. START_TIME=$(date +%s)
  446. if [ "$DTLS" -eq 1 ]; then
  447. proto=UDP
  448. else
  449. proto=TCP
  450. fi
  451. # Make a tight loop, server normally takes less than 1s to start.
  452. while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
  453. if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
  454. echo "$3 START TIMEOUT"
  455. echo "$3 START TIMEOUT" >> $4
  456. break
  457. fi
  458. # Linux and *BSD support decimal arguments to sleep. On other
  459. # OSes this may be a tight loop.
  460. sleep 0.1 2>/dev/null || true
  461. done
  462. }
  463. else
  464. echo "Warning: lsof not available, wait_app_start = sleep"
  465. wait_app_start() {
  466. sleep "$START_DELAY"
  467. }
  468. fi
  469. # Wait for server process $2 to be listening on port $1.
  470. wait_server_start() {
  471. wait_app_start $1 $2 "SERVER" $SRV_OUT
  472. }
  473. # Wait for proxy process $2 to be listening on port $1.
  474. wait_proxy_start() {
  475. wait_app_start $1 $2 "PROXY" $PXY_OUT
  476. }
  477. # Given the client or server debug output, parse the unix timestamp that is
  478. # included in the first 4 bytes of the random bytes and check that it's within
  479. # acceptable bounds
  480. check_server_hello_time() {
  481. # Extract the time from the debug (lvl 3) output of the client
  482. SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
  483. # Get the Unix timestamp for now
  484. CUR_TIME=$(date +'%s')
  485. THRESHOLD_IN_SECS=300
  486. # Check if the ServerHello time was printed
  487. if [ -z "$SERVER_HELLO_TIME" ]; then
  488. return 1
  489. fi
  490. # Check the time in ServerHello is within acceptable bounds
  491. if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
  492. # The time in ServerHello is at least 5 minutes before now
  493. return 1
  494. elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
  495. # The time in ServerHello is at least 5 minutes later than now
  496. return 1
  497. else
  498. return 0
  499. fi
  500. }
  501. # Get handshake memory usage from server or client output and put it into the variable specified by the first argument
  502. handshake_memory_get() {
  503. OUTPUT_VARIABLE="$1"
  504. OUTPUT_FILE="$2"
  505. # Get memory usage from a pattern like "Heap memory usage after handshake: 23112 bytes. Peak memory usage was 33112"
  506. MEM_USAGE=$(sed -n 's/.*Heap memory usage after handshake: //p' < "$OUTPUT_FILE" | grep -o "[0-9]*" | head -1)
  507. # Check if memory usage was read
  508. if [ -z "$MEM_USAGE" ]; then
  509. echo "Error: Can not read the value of handshake memory usage"
  510. return 1
  511. else
  512. eval "$OUTPUT_VARIABLE=$MEM_USAGE"
  513. return 0
  514. fi
  515. }
  516. # Get handshake memory usage from server or client output and check if this value
  517. # is not higher than the maximum given by the first argument
  518. handshake_memory_check() {
  519. MAX_MEMORY="$1"
  520. OUTPUT_FILE="$2"
  521. # Get memory usage
  522. if ! handshake_memory_get "MEMORY_USAGE" "$OUTPUT_FILE"; then
  523. return 1
  524. fi
  525. # Check if memory usage is below max value
  526. if [ "$MEMORY_USAGE" -gt "$MAX_MEMORY" ]; then
  527. echo "\nFailed: Handshake memory usage was $MEMORY_USAGE bytes," \
  528. "but should be below $MAX_MEMORY bytes"
  529. return 1
  530. else
  531. return 0
  532. fi
  533. }
  534. # wait for client to terminate and set CLI_EXIT
  535. # must be called right after starting the client
  536. wait_client_done() {
  537. CLI_PID=$!
  538. CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
  539. CLI_DELAY_FACTOR=1
  540. ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
  541. DOG_PID=$!
  542. wait $CLI_PID
  543. CLI_EXIT=$?
  544. kill $DOG_PID >/dev/null 2>&1
  545. wait $DOG_PID
  546. echo "EXIT: $CLI_EXIT" >> $CLI_OUT
  547. sleep $SRV_DELAY_SECONDS
  548. SRV_DELAY_SECONDS=0
  549. }
  550. # check if the given command uses dtls and sets global variable DTLS
  551. detect_dtls() {
  552. if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
  553. DTLS=1
  554. else
  555. DTLS=0
  556. fi
  557. }
  558. # Compare file content
  559. # Usage: find_in_both pattern file1 file2
  560. # extract from file1 the first line matching the pattern
  561. # check in file2 that the same line can be found
  562. find_in_both() {
  563. srv_pattern=$(grep -m 1 "$1" "$2");
  564. if [ -z "$srv_pattern" ]; then
  565. return 1;
  566. fi
  567. if grep "$srv_pattern" $3 >/dev/null; then :
  568. return 0;
  569. else
  570. return 1;
  571. fi
  572. }
  573. # Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
  574. # Options: -s pattern pattern that must be present in server output
  575. # -c pattern pattern that must be present in client output
  576. # -u pattern lines after pattern must be unique in client output
  577. # -f call shell function on client output
  578. # -S pattern pattern that must be absent in server output
  579. # -C pattern pattern that must be absent in client output
  580. # -U pattern lines after pattern must be unique in server output
  581. # -F call shell function on server output
  582. # -g call shell function on server and client output
  583. run_test() {
  584. NAME="$1"
  585. shift 1
  586. if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
  587. else
  588. SKIP_NEXT="NO"
  589. # There was no request to run the test, so don't record its outcome.
  590. return
  591. fi
  592. print_name "$NAME"
  593. # Do we only run numbered tests?
  594. if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
  595. elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
  596. else
  597. SKIP_NEXT="YES"
  598. fi
  599. # does this test use a proxy?
  600. if [ "X$1" = "X-p" ]; then
  601. PXY_CMD="$2"
  602. shift 2
  603. else
  604. PXY_CMD=""
  605. fi
  606. # get commands and client output
  607. SRV_CMD="$1"
  608. CLI_CMD="$2"
  609. CLI_EXPECT="$3"
  610. shift 3
  611. # Check if test uses files
  612. TEST_USES_FILES=$(echo "$SRV_CMD $CLI_CMD" | grep "\.\(key\|crt\|pem\)" )
  613. if [ ! -z "$TEST_USES_FILES" ]; then
  614. requires_config_enabled MBEDTLS_FS_IO
  615. fi
  616. # If the client or serve requires a ciphersuite, check that it's enabled.
  617. maybe_requires_ciphersuite_enabled "$SRV_CMD" "$@"
  618. maybe_requires_ciphersuite_enabled "$CLI_CMD" "$@"
  619. # should we skip?
  620. if [ "X$SKIP_NEXT" = "XYES" ]; then
  621. SKIP_NEXT="NO"
  622. record_outcome "SKIP"
  623. SKIPS=$(( $SKIPS + 1 ))
  624. return
  625. fi
  626. # update DTLS variable
  627. detect_dtls "$SRV_CMD"
  628. # if the test uses DTLS but no custom proxy, add a simple proxy
  629. # as it provides timing info that's useful to debug failures
  630. if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then
  631. PXY_CMD="$P_PXY"
  632. case " $SRV_CMD " in
  633. *' server_addr=::1 '*)
  634. PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";;
  635. esac
  636. fi
  637. # fix client port
  638. if [ -n "$PXY_CMD" ]; then
  639. CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
  640. else
  641. CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
  642. fi
  643. # prepend valgrind to our commands if active
  644. if [ "$MEMCHECK" -gt 0 ]; then
  645. if is_polar "$SRV_CMD"; then
  646. SRV_CMD="valgrind --leak-check=full $SRV_CMD"
  647. fi
  648. if is_polar "$CLI_CMD"; then
  649. CLI_CMD="valgrind --leak-check=full $CLI_CMD"
  650. fi
  651. fi
  652. TIMES_LEFT=2
  653. while [ $TIMES_LEFT -gt 0 ]; do
  654. TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
  655. # run the commands
  656. if [ -n "$PXY_CMD" ]; then
  657. printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT
  658. $PXY_CMD >> $PXY_OUT 2>&1 &
  659. PXY_PID=$!
  660. wait_proxy_start "$PXY_PORT" "$PXY_PID"
  661. fi
  662. check_osrv_dtls
  663. printf '# %s\n%s\n' "$NAME" "$SRV_CMD" > $SRV_OUT
  664. provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
  665. SRV_PID=$!
  666. wait_server_start "$SRV_PORT" "$SRV_PID"
  667. printf '# %s\n%s\n' "$NAME" "$CLI_CMD" > $CLI_OUT
  668. eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
  669. wait_client_done
  670. sleep 0.05
  671. # terminate the server (and the proxy)
  672. kill $SRV_PID
  673. wait $SRV_PID
  674. if [ -n "$PXY_CMD" ]; then
  675. kill $PXY_PID >/dev/null 2>&1
  676. wait $PXY_PID
  677. fi
  678. # retry only on timeouts
  679. if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
  680. printf "RETRY "
  681. else
  682. TIMES_LEFT=0
  683. fi
  684. done
  685. # check if the client and server went at least to the handshake stage
  686. # (useful to avoid tests with only negative assertions and non-zero
  687. # expected client exit to incorrectly succeed in case of catastrophic
  688. # failure)
  689. if is_polar "$SRV_CMD"; then
  690. if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
  691. else
  692. fail "server or client failed to reach handshake stage"
  693. return
  694. fi
  695. fi
  696. if is_polar "$CLI_CMD"; then
  697. if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
  698. else
  699. fail "server or client failed to reach handshake stage"
  700. return
  701. fi
  702. fi
  703. # check server exit code
  704. if [ $? != 0 ]; then
  705. fail "server fail"
  706. return
  707. fi
  708. # check client exit code
  709. if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
  710. \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
  711. then
  712. fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
  713. return
  714. fi
  715. # check other assertions
  716. # lines beginning with == are added by valgrind, ignore them
  717. # lines with 'Serious error when reading debug info', are valgrind issues as well
  718. while [ $# -gt 0 ]
  719. do
  720. case $1 in
  721. "-s")
  722. if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
  723. fail "pattern '$2' MUST be present in the Server output"
  724. return
  725. fi
  726. ;;
  727. "-c")
  728. if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
  729. fail "pattern '$2' MUST be present in the Client output"
  730. return
  731. fi
  732. ;;
  733. "-S")
  734. if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
  735. fail "pattern '$2' MUST NOT be present in the Server output"
  736. return
  737. fi
  738. ;;
  739. "-C")
  740. if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
  741. fail "pattern '$2' MUST NOT be present in the Client output"
  742. return
  743. fi
  744. ;;
  745. # The filtering in the following two options (-u and -U) do the following
  746. # - ignore valgrind output
  747. # - filter out everything but lines right after the pattern occurrences
  748. # - keep one of each non-unique line
  749. # - count how many lines remain
  750. # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
  751. # if there were no duplicates.
  752. "-U")
  753. 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
  754. fail "lines following pattern '$2' must be unique in Server output"
  755. return
  756. fi
  757. ;;
  758. "-u")
  759. 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
  760. fail "lines following pattern '$2' must be unique in Client output"
  761. return
  762. fi
  763. ;;
  764. "-F")
  765. if ! $2 "$SRV_OUT"; then
  766. fail "function call to '$2' failed on Server output"
  767. return
  768. fi
  769. ;;
  770. "-f")
  771. if ! $2 "$CLI_OUT"; then
  772. fail "function call to '$2' failed on Client output"
  773. return
  774. fi
  775. ;;
  776. "-g")
  777. if ! eval "$2 '$SRV_OUT' '$CLI_OUT'"; then
  778. fail "function call to '$2' failed on Server and Client output"
  779. return
  780. fi
  781. ;;
  782. *)
  783. echo "Unknown test: $1" >&2
  784. exit 1
  785. esac
  786. shift 2
  787. done
  788. # check valgrind's results
  789. if [ "$MEMCHECK" -gt 0 ]; then
  790. if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
  791. fail "Server has memory errors"
  792. return
  793. fi
  794. if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
  795. fail "Client has memory errors"
  796. return
  797. fi
  798. fi
  799. # if we're here, everything is ok
  800. record_outcome "PASS"
  801. if [ "$PRESERVE_LOGS" -gt 0 ]; then
  802. mv $SRV_OUT o-srv-${TESTS}.log
  803. mv $CLI_OUT o-cli-${TESTS}.log
  804. if [ -n "$PXY_CMD" ]; then
  805. mv $PXY_OUT o-pxy-${TESTS}.log
  806. fi
  807. fi
  808. rm -f $SRV_OUT $CLI_OUT $PXY_OUT
  809. }
  810. run_test_psa() {
  811. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  812. run_test "PSA-supported ciphersuite: $1" \
  813. "$P_SRV debug_level=3 force_version=tls1_2" \
  814. "$P_CLI debug_level=3 force_version=tls1_2 force_ciphersuite=$1" \
  815. 0 \
  816. -c "Successfully setup PSA-based decryption cipher context" \
  817. -c "Successfully setup PSA-based encryption cipher context" \
  818. -c "PSA calc verify" \
  819. -c "calc PSA finished" \
  820. -s "Successfully setup PSA-based decryption cipher context" \
  821. -s "Successfully setup PSA-based encryption cipher context" \
  822. -s "PSA calc verify" \
  823. -s "calc PSA finished" \
  824. -C "Failed to setup PSA-based cipher context"\
  825. -S "Failed to setup PSA-based cipher context"\
  826. -s "Protocol is TLSv1.2" \
  827. -c "Perform PSA-based ECDH computation."\
  828. -c "Perform PSA-based computation of digest of ServerKeyExchange" \
  829. -S "error" \
  830. -C "error"
  831. }
  832. run_test_psa_force_curve() {
  833. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  834. run_test "PSA - ECDH with $1" \
  835. "$P_SRV debug_level=4 force_version=tls1_2" \
  836. "$P_CLI debug_level=4 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256 curves=$1" \
  837. 0 \
  838. -c "Successfully setup PSA-based decryption cipher context" \
  839. -c "Successfully setup PSA-based encryption cipher context" \
  840. -c "PSA calc verify" \
  841. -c "calc PSA finished" \
  842. -s "Successfully setup PSA-based decryption cipher context" \
  843. -s "Successfully setup PSA-based encryption cipher context" \
  844. -s "PSA calc verify" \
  845. -s "calc PSA finished" \
  846. -C "Failed to setup PSA-based cipher context"\
  847. -S "Failed to setup PSA-based cipher context"\
  848. -s "Protocol is TLSv1.2" \
  849. -c "Perform PSA-based ECDH computation."\
  850. -c "Perform PSA-based computation of digest of ServerKeyExchange" \
  851. -S "error" \
  852. -C "error"
  853. }
  854. # Test that the server's memory usage after a handshake is reduced when a client specifies
  855. # a maximum fragment length.
  856. # first argument ($1) is MFL for SSL client
  857. # second argument ($2) is memory usage for SSL client with default MFL (16k)
  858. run_test_memory_after_hanshake_with_mfl()
  859. {
  860. # The test passes if the difference is around 2*(16k-MFL)
  861. local MEMORY_USAGE_LIMIT="$(( $2 - ( 2 * ( 16384 - $1 )) ))"
  862. # Leave some margin for robustness
  863. MEMORY_USAGE_LIMIT="$(( ( MEMORY_USAGE_LIMIT * 110 ) / 100 ))"
  864. run_test "Handshake memory usage (MFL $1)" \
  865. "$P_SRV debug_level=3 auth_mode=required force_version=tls1_2" \
  866. "$P_CLI debug_level=3 force_version=tls1_2 \
  867. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  868. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM max_frag_len=$1" \
  869. 0 \
  870. -F "handshake_memory_check $MEMORY_USAGE_LIMIT"
  871. }
  872. # Test that the server's memory usage after a handshake is reduced when a client specifies
  873. # different values of Maximum Fragment Length: default (16k), 4k, 2k, 1k and 512 bytes
  874. run_tests_memory_after_hanshake()
  875. {
  876. # all tests in this sequence requires the same configuration (see requires_config_enabled())
  877. SKIP_THIS_TESTS="$SKIP_NEXT"
  878. # first test with default MFU is to get reference memory usage
  879. MEMORY_USAGE_MFL_16K=0
  880. run_test "Handshake memory usage initial (MFL 16384 - default)" \
  881. "$P_SRV debug_level=3 auth_mode=required force_version=tls1_2" \
  882. "$P_CLI debug_level=3 force_version=tls1_2 \
  883. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  884. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM" \
  885. 0 \
  886. -F "handshake_memory_get MEMORY_USAGE_MFL_16K"
  887. SKIP_NEXT="$SKIP_THIS_TESTS"
  888. run_test_memory_after_hanshake_with_mfl 4096 "$MEMORY_USAGE_MFL_16K"
  889. SKIP_NEXT="$SKIP_THIS_TESTS"
  890. run_test_memory_after_hanshake_with_mfl 2048 "$MEMORY_USAGE_MFL_16K"
  891. SKIP_NEXT="$SKIP_THIS_TESTS"
  892. run_test_memory_after_hanshake_with_mfl 1024 "$MEMORY_USAGE_MFL_16K"
  893. SKIP_NEXT="$SKIP_THIS_TESTS"
  894. run_test_memory_after_hanshake_with_mfl 512 "$MEMORY_USAGE_MFL_16K"
  895. }
  896. cleanup() {
  897. rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
  898. rm -f context_srv.txt
  899. rm -f context_cli.txt
  900. test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
  901. test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
  902. test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
  903. test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
  904. exit 1
  905. }
  906. #
  907. # MAIN
  908. #
  909. get_options "$@"
  910. # sanity checks, avoid an avalanche of errors
  911. P_SRV_BIN="${P_SRV%%[ ]*}"
  912. P_CLI_BIN="${P_CLI%%[ ]*}"
  913. P_PXY_BIN="${P_PXY%%[ ]*}"
  914. if [ ! -x "$P_SRV_BIN" ]; then
  915. echo "Command '$P_SRV_BIN' is not an executable file"
  916. exit 1
  917. fi
  918. if [ ! -x "$P_CLI_BIN" ]; then
  919. echo "Command '$P_CLI_BIN' is not an executable file"
  920. exit 1
  921. fi
  922. if [ ! -x "$P_PXY_BIN" ]; then
  923. echo "Command '$P_PXY_BIN' is not an executable file"
  924. exit 1
  925. fi
  926. if [ "$MEMCHECK" -gt 0 ]; then
  927. if which valgrind >/dev/null 2>&1; then :; else
  928. echo "Memcheck not possible. Valgrind not found"
  929. exit 1
  930. fi
  931. fi
  932. if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
  933. echo "Command '$OPENSSL_CMD' not found"
  934. exit 1
  935. fi
  936. # used by watchdog
  937. MAIN_PID="$$"
  938. # We use somewhat arbitrary delays for tests:
  939. # - how long do we wait for the server to start (when lsof not available)?
  940. # - how long do we allow for the client to finish?
  941. # (not to check performance, just to avoid waiting indefinitely)
  942. # Things are slower with valgrind, so give extra time here.
  943. #
  944. # Note: without lsof, there is a trade-off between the running time of this
  945. # script and the risk of spurious errors because we didn't wait long enough.
  946. # The watchdog delay on the other hand doesn't affect normal running time of
  947. # the script, only the case where a client or server gets stuck.
  948. if [ "$MEMCHECK" -gt 0 ]; then
  949. START_DELAY=6
  950. DOG_DELAY=60
  951. else
  952. START_DELAY=2
  953. DOG_DELAY=20
  954. fi
  955. # some particular tests need more time:
  956. # - for the client, we multiply the usual watchdog limit by a factor
  957. # - for the server, we sleep for a number of seconds after the client exits
  958. # see client_need_more_time() and server_needs_more_time()
  959. CLI_DELAY_FACTOR=1
  960. SRV_DELAY_SECONDS=0
  961. # fix commands to use this port, force IPv4 while at it
  962. # +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
  963. P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
  964. P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
  965. 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"}"
  966. O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
  967. O_CLI="$O_CLI -connect localhost:+SRV_PORT"
  968. G_SRV="$G_SRV -p $SRV_PORT"
  969. G_CLI="$G_CLI -p +SRV_PORT"
  970. if [ -n "${OPENSSL_LEGACY:-}" ]; then
  971. O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
  972. O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
  973. fi
  974. if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
  975. G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
  976. fi
  977. if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
  978. G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
  979. fi
  980. # Allow SHA-1, because many of our test certificates use it
  981. P_SRV="$P_SRV allow_sha1=1"
  982. P_CLI="$P_CLI allow_sha1=1"
  983. # Also pick a unique name for intermediate files
  984. SRV_OUT="srv_out.$$"
  985. CLI_OUT="cli_out.$$"
  986. PXY_OUT="pxy_out.$$"
  987. SESSION="session.$$"
  988. SKIP_NEXT="NO"
  989. trap cleanup INT TERM HUP
  990. # Basic test
  991. # Checks that:
  992. # - things work with all ciphersuites active (used with config-full in all.sh)
  993. # - the expected (highest security) parameters are selected
  994. # ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
  995. run_test "Default" \
  996. "$P_SRV debug_level=3" \
  997. "$P_CLI" \
  998. 0 \
  999. -s "Protocol is TLSv1.2" \
  1000. -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
  1001. -s "client hello v3, signature_algorithm ext: 6" \
  1002. -s "ECDHE curve: secp521r1" \
  1003. -S "error" \
  1004. -C "error"
  1005. run_test "Default, DTLS" \
  1006. "$P_SRV dtls=1" \
  1007. "$P_CLI dtls=1" \
  1008. 0 \
  1009. -s "Protocol is DTLSv1.2" \
  1010. -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
  1011. run_test "TLS client auth: required" \
  1012. "$P_SRV auth_mode=required" \
  1013. "$P_CLI" \
  1014. 0 \
  1015. -s "Verifying peer X.509 certificate... ok"
  1016. requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
  1017. requires_config_enabled MBEDTLS_ECDSA_C
  1018. requires_config_enabled MBEDTLS_SHA256_C
  1019. run_test "TLS: password protected client key" \
  1020. "$P_SRV auth_mode=required" \
  1021. "$P_CLI crt_file=data_files/server5.crt key_file=data_files/server5.key.enc key_pwd=PolarSSLTest" \
  1022. 0
  1023. requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
  1024. requires_config_enabled MBEDTLS_ECDSA_C
  1025. requires_config_enabled MBEDTLS_SHA256_C
  1026. run_test "TLS: password protected server key" \
  1027. "$P_SRV crt_file=data_files/server5.crt key_file=data_files/server5.key.enc key_pwd=PolarSSLTest" \
  1028. "$P_CLI" \
  1029. 0
  1030. requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
  1031. requires_config_enabled MBEDTLS_ECDSA_C
  1032. requires_config_enabled MBEDTLS_RSA_C
  1033. requires_config_enabled MBEDTLS_SHA256_C
  1034. run_test "TLS: password protected server key, two certificates" \
  1035. "$P_SRV \
  1036. key_file=data_files/server5.key.enc key_pwd=PolarSSLTest crt_file=data_files/server5.crt \
  1037. key_file2=data_files/server2.key.enc key_pwd2=PolarSSLTest crt_file2=data_files/server2.crt" \
  1038. "$P_CLI" \
  1039. 0
  1040. requires_config_enabled MBEDTLS_ZLIB_SUPPORT
  1041. run_test "Default (compression enabled)" \
  1042. "$P_SRV debug_level=3" \
  1043. "$P_CLI debug_level=3" \
  1044. 0 \
  1045. -s "Allocating compression buffer" \
  1046. -c "Allocating compression buffer" \
  1047. -s "Record expansion is unknown (compression)" \
  1048. -c "Record expansion is unknown (compression)" \
  1049. -S "error" \
  1050. -C "error"
  1051. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  1052. run_test "CA callback on client" \
  1053. "$P_SRV debug_level=3" \
  1054. "$P_CLI ca_callback=1 debug_level=3 " \
  1055. 0 \
  1056. -c "use CA callback for X.509 CRT verification" \
  1057. -S "error" \
  1058. -C "error"
  1059. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  1060. requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
  1061. requires_config_enabled MBEDTLS_ECDSA_C
  1062. requires_config_enabled MBEDTLS_SHA256_C
  1063. run_test "CA callback on server" \
  1064. "$P_SRV auth_mode=required" \
  1065. "$P_CLI ca_callback=1 debug_level=3 crt_file=data_files/server5.crt \
  1066. key_file=data_files/server5.key" \
  1067. 0 \
  1068. -c "use CA callback for X.509 CRT verification" \
  1069. -s "Verifying peer X.509 certificate... ok" \
  1070. -S "error" \
  1071. -C "error"
  1072. # Test using an opaque private key for client authentication
  1073. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  1074. requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
  1075. requires_config_enabled MBEDTLS_ECDSA_C
  1076. requires_config_enabled MBEDTLS_SHA256_C
  1077. run_test "Opaque key for client authentication" \
  1078. "$P_SRV auth_mode=required" \
  1079. "$P_CLI key_opaque=1 crt_file=data_files/server5.crt \
  1080. key_file=data_files/server5.key" \
  1081. 0 \
  1082. -c "key type: Opaque" \
  1083. -s "Verifying peer X.509 certificate... ok" \
  1084. -S "error" \
  1085. -C "error"
  1086. # Test ciphersuites which we expect to be fully supported by PSA Crypto
  1087. # and check that we don't fall back to Mbed TLS' internal crypto primitives.
  1088. run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM
  1089. run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8
  1090. run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CCM
  1091. run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8
  1092. run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
  1093. run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384
  1094. run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA
  1095. run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
  1096. run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384
  1097. requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
  1098. run_test_psa_force_curve "secp521r1"
  1099. requires_config_enabled MBEDTLS_ECP_DP_BP512R1_ENABLED
  1100. run_test_psa_force_curve "brainpoolP512r1"
  1101. requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
  1102. run_test_psa_force_curve "secp384r1"
  1103. requires_config_enabled MBEDTLS_ECP_DP_BP384R1_ENABLED
  1104. run_test_psa_force_curve "brainpoolP384r1"
  1105. requires_config_enabled MBEDTLS_ECP_DP_SECP256R1_ENABLED
  1106. run_test_psa_force_curve "secp256r1"
  1107. requires_config_enabled MBEDTLS_ECP_DP_SECP256K1_ENABLED
  1108. run_test_psa_force_curve "secp256k1"
  1109. requires_config_enabled MBEDTLS_ECP_DP_BP256R1_ENABLED
  1110. run_test_psa_force_curve "brainpoolP256r1"
  1111. requires_config_enabled MBEDTLS_ECP_DP_SECP224R1_ENABLED
  1112. run_test_psa_force_curve "secp224r1"
  1113. requires_config_enabled MBEDTLS_ECP_DP_SECP224K1_ENABLED
  1114. run_test_psa_force_curve "secp224k1"
  1115. requires_config_enabled MBEDTLS_ECP_DP_SECP192R1_ENABLED
  1116. run_test_psa_force_curve "secp192r1"
  1117. requires_config_enabled MBEDTLS_ECP_DP_SECP192K1_ENABLED
  1118. run_test_psa_force_curve "secp192k1"
  1119. # Test current time in ServerHello
  1120. requires_config_enabled MBEDTLS_HAVE_TIME
  1121. run_test "ServerHello contains gmt_unix_time" \
  1122. "$P_SRV debug_level=3" \
  1123. "$P_CLI debug_level=3" \
  1124. 0 \
  1125. -f "check_server_hello_time" \
  1126. -F "check_server_hello_time"
  1127. # Test for uniqueness of IVs in AEAD ciphersuites
  1128. run_test "Unique IV in GCM" \
  1129. "$P_SRV exchanges=20 debug_level=4" \
  1130. "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
  1131. 0 \
  1132. -u "IV used" \
  1133. -U "IV used"
  1134. # Tests for certificate verification callback
  1135. run_test "Configuration-specific CRT verification callback" \
  1136. "$P_SRV debug_level=3" \
  1137. "$P_CLI context_crt_cb=0 debug_level=3" \
  1138. 0 \
  1139. -S "error" \
  1140. -c "Verify requested for " \
  1141. -c "Use configuration-specific verification callback" \
  1142. -C "Use context-specific verification callback" \
  1143. -C "error"
  1144. run_test "Context-specific CRT verification callback" \
  1145. "$P_SRV debug_level=3" \
  1146. "$P_CLI context_crt_cb=1 debug_level=3" \
  1147. 0 \
  1148. -S "error" \
  1149. -c "Verify requested for " \
  1150. -c "Use context-specific verification callback" \
  1151. -C "Use configuration-specific verification callback" \
  1152. -C "error"
  1153. # Tests for rc4 option
  1154. requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
  1155. run_test "RC4: server disabled, client enabled" \
  1156. "$P_SRV" \
  1157. "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  1158. 1 \
  1159. -s "SSL - The server has no ciphersuites in common"
  1160. requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
  1161. run_test "RC4: server half, client enabled" \
  1162. "$P_SRV arc4=1" \
  1163. "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  1164. 1 \
  1165. -s "SSL - The server has no ciphersuites in common"
  1166. run_test "RC4: server enabled, client disabled" \
  1167. "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  1168. "$P_CLI" \
  1169. 1 \
  1170. -s "SSL - The server has no ciphersuites in common"
  1171. run_test "RC4: both enabled" \
  1172. "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  1173. "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  1174. 0 \
  1175. -S "SSL - None of the common ciphersuites is usable" \
  1176. -S "SSL - The server has no ciphersuites in common"
  1177. # Test empty CA list in CertificateRequest in TLS 1.1 and earlier
  1178. requires_gnutls
  1179. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
  1180. run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
  1181. "$G_SRV"\
  1182. "$P_CLI force_version=tls1_1" \
  1183. 0
  1184. requires_gnutls
  1185. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
  1186. run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
  1187. "$G_SRV"\
  1188. "$P_CLI force_version=tls1" \
  1189. 0
  1190. # Tests for SHA-1 support
  1191. requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
  1192. run_test "SHA-1 forbidden by default in server certificate" \
  1193. "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
  1194. "$P_CLI debug_level=2 allow_sha1=0" \
  1195. 1 \
  1196. -c "The certificate is signed with an unacceptable hash"
  1197. requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
  1198. run_test "SHA-1 allowed by default in server certificate" \
  1199. "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
  1200. "$P_CLI debug_level=2 allow_sha1=0" \
  1201. 0
  1202. run_test "SHA-1 explicitly allowed in server certificate" \
  1203. "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
  1204. "$P_CLI allow_sha1=1" \
  1205. 0
  1206. run_test "SHA-256 allowed by default in server certificate" \
  1207. "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
  1208. "$P_CLI allow_sha1=0" \
  1209. 0
  1210. requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
  1211. run_test "SHA-1 forbidden by default in client certificate" \
  1212. "$P_SRV auth_mode=required allow_sha1=0" \
  1213. "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
  1214. 1 \
  1215. -s "The certificate is signed with an unacceptable hash"
  1216. requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
  1217. run_test "SHA-1 allowed by default in client certificate" \
  1218. "$P_SRV auth_mode=required allow_sha1=0" \
  1219. "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
  1220. 0
  1221. run_test "SHA-1 explicitly allowed in client certificate" \
  1222. "$P_SRV auth_mode=required allow_sha1=1" \
  1223. "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
  1224. 0
  1225. run_test "SHA-256 allowed by default in client certificate" \
  1226. "$P_SRV auth_mode=required allow_sha1=0" \
  1227. "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
  1228. 0
  1229. # Tests for datagram packing
  1230. run_test "DTLS: multiple records in same datagram, client and server" \
  1231. "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
  1232. "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
  1233. 0 \
  1234. -c "next record in same datagram" \
  1235. -s "next record in same datagram"
  1236. run_test "DTLS: multiple records in same datagram, client only" \
  1237. "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
  1238. "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
  1239. 0 \
  1240. -s "next record in same datagram" \
  1241. -C "next record in same datagram"
  1242. run_test "DTLS: multiple records in same datagram, server only" \
  1243. "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
  1244. "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
  1245. 0 \
  1246. -S "next record in same datagram" \
  1247. -c "next record in same datagram"
  1248. run_test "DTLS: multiple records in same datagram, neither client nor server" \
  1249. "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
  1250. "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
  1251. 0 \
  1252. -S "next record in same datagram" \
  1253. -C "next record in same datagram"
  1254. # Tests for Truncated HMAC extension
  1255. run_test "Truncated HMAC: client default, server default" \
  1256. "$P_SRV debug_level=4" \
  1257. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  1258. 0 \
  1259. -s "dumping 'expected mac' (20 bytes)" \
  1260. -S "dumping 'expected mac' (10 bytes)"
  1261. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  1262. run_test "Truncated HMAC: client disabled, server default" \
  1263. "$P_SRV debug_level=4" \
  1264. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
  1265. 0 \
  1266. -s "dumping 'expected mac' (20 bytes)" \
  1267. -S "dumping 'expected mac' (10 bytes)"
  1268. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  1269. run_test "Truncated HMAC: client enabled, server default" \
  1270. "$P_SRV debug_level=4" \
  1271. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
  1272. 0 \
  1273. -s "dumping 'expected mac' (20 bytes)" \
  1274. -S "dumping 'expected mac' (10 bytes)"
  1275. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  1276. run_test "Truncated HMAC: client enabled, server disabled" \
  1277. "$P_SRV debug_level=4 trunc_hmac=0" \
  1278. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
  1279. 0 \
  1280. -s "dumping 'expected mac' (20 bytes)" \
  1281. -S "dumping 'expected mac' (10 bytes)"
  1282. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  1283. run_test "Truncated HMAC: client disabled, server enabled" \
  1284. "$P_SRV debug_level=4 trunc_hmac=1" \
  1285. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
  1286. 0 \
  1287. -s "dumping 'expected mac' (20 bytes)" \
  1288. -S "dumping 'expected mac' (10 bytes)"
  1289. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  1290. run_test "Truncated HMAC: client enabled, server enabled" \
  1291. "$P_SRV debug_level=4 trunc_hmac=1" \
  1292. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
  1293. 0 \
  1294. -S "dumping 'expected mac' (20 bytes)" \
  1295. -s "dumping 'expected mac' (10 bytes)"
  1296. run_test "Truncated HMAC, DTLS: client default, server default" \
  1297. "$P_SRV dtls=1 debug_level=4" \
  1298. "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  1299. 0 \
  1300. -s "dumping 'expected mac' (20 bytes)" \
  1301. -S "dumping 'expected mac' (10 bytes)"
  1302. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  1303. run_test "Truncated HMAC, DTLS: client disabled, server default" \
  1304. "$P_SRV dtls=1 debug_level=4" \
  1305. "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
  1306. 0 \
  1307. -s "dumping 'expected mac' (20 bytes)" \
  1308. -S "dumping 'expected mac' (10 bytes)"
  1309. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  1310. run_test "Truncated HMAC, DTLS: client enabled, server default" \
  1311. "$P_SRV dtls=1 debug_level=4" \
  1312. "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
  1313. 0 \
  1314. -s "dumping 'expected mac' (20 bytes)" \
  1315. -S "dumping 'expected mac' (10 bytes)"
  1316. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  1317. run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
  1318. "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
  1319. "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
  1320. 0 \
  1321. -s "dumping 'expected mac' (20 bytes)" \
  1322. -S "dumping 'expected mac' (10 bytes)"
  1323. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  1324. run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
  1325. "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
  1326. "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
  1327. 0 \
  1328. -s "dumping 'expected mac' (20 bytes)" \
  1329. -S "dumping 'expected mac' (10 bytes)"
  1330. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  1331. run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
  1332. "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
  1333. "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
  1334. 0 \
  1335. -S "dumping 'expected mac' (20 bytes)" \
  1336. -s "dumping 'expected mac' (10 bytes)"
  1337. # Tests for Context serialization
  1338. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1339. run_test "Context serialization, client serializes, CCM" \
  1340. "$P_SRV dtls=1 serialize=0 exchanges=2" \
  1341. "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
  1342. 0 \
  1343. -c "Deserializing connection..." \
  1344. -S "Deserializing connection..."
  1345. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1346. run_test "Context serialization, client serializes, ChaChaPoly" \
  1347. "$P_SRV dtls=1 serialize=0 exchanges=2" \
  1348. "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
  1349. 0 \
  1350. -c "Deserializing connection..." \
  1351. -S "Deserializing connection..."
  1352. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1353. run_test "Context serialization, client serializes, GCM" \
  1354. "$P_SRV dtls=1 serialize=0 exchanges=2" \
  1355. "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
  1356. 0 \
  1357. -c "Deserializing connection..." \
  1358. -S "Deserializing connection..."
  1359. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1360. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1361. run_test "Context serialization, client serializes, with CID" \
  1362. "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
  1363. "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
  1364. 0 \
  1365. -c "Deserializing connection..." \
  1366. -S "Deserializing connection..."
  1367. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1368. run_test "Context serialization, server serializes, CCM" \
  1369. "$P_SRV dtls=1 serialize=1 exchanges=2" \
  1370. "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
  1371. 0 \
  1372. -C "Deserializing connection..." \
  1373. -s "Deserializing connection..."
  1374. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1375. run_test "Context serialization, server serializes, ChaChaPoly" \
  1376. "$P_SRV dtls=1 serialize=1 exchanges=2" \
  1377. "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
  1378. 0 \
  1379. -C "Deserializing connection..." \
  1380. -s "Deserializing connection..."
  1381. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1382. run_test "Context serialization, server serializes, GCM" \
  1383. "$P_SRV dtls=1 serialize=1 exchanges=2" \
  1384. "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
  1385. 0 \
  1386. -C "Deserializing connection..." \
  1387. -s "Deserializing connection..."
  1388. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1389. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1390. run_test "Context serialization, server serializes, with CID" \
  1391. "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
  1392. "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
  1393. 0 \
  1394. -C "Deserializing connection..." \
  1395. -s "Deserializing connection..."
  1396. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1397. run_test "Context serialization, both serialize, CCM" \
  1398. "$P_SRV dtls=1 serialize=1 exchanges=2" \
  1399. "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
  1400. 0 \
  1401. -c "Deserializing connection..." \
  1402. -s "Deserializing connection..."
  1403. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1404. run_test "Context serialization, both serialize, ChaChaPoly" \
  1405. "$P_SRV dtls=1 serialize=1 exchanges=2" \
  1406. "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
  1407. 0 \
  1408. -c "Deserializing connection..." \
  1409. -s "Deserializing connection..."
  1410. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1411. run_test "Context serialization, both serialize, GCM" \
  1412. "$P_SRV dtls=1 serialize=1 exchanges=2" \
  1413. "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
  1414. 0 \
  1415. -c "Deserializing connection..." \
  1416. -s "Deserializing connection..."
  1417. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1418. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1419. run_test "Context serialization, both serialize, with CID" \
  1420. "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
  1421. "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
  1422. 0 \
  1423. -c "Deserializing connection..." \
  1424. -s "Deserializing connection..."
  1425. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1426. run_test "Context serialization, re-init, client serializes, CCM" \
  1427. "$P_SRV dtls=1 serialize=0 exchanges=2" \
  1428. "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
  1429. 0 \
  1430. -c "Deserializing connection..." \
  1431. -S "Deserializing connection..."
  1432. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1433. run_test "Context serialization, re-init, client serializes, ChaChaPoly" \
  1434. "$P_SRV dtls=1 serialize=0 exchanges=2" \
  1435. "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
  1436. 0 \
  1437. -c "Deserializing connection..." \
  1438. -S "Deserializing connection..."
  1439. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1440. run_test "Context serialization, re-init, client serializes, GCM" \
  1441. "$P_SRV dtls=1 serialize=0 exchanges=2" \
  1442. "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
  1443. 0 \
  1444. -c "Deserializing connection..." \
  1445. -S "Deserializing connection..."
  1446. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1447. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1448. run_test "Context serialization, re-init, client serializes, with CID" \
  1449. "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
  1450. "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
  1451. 0 \
  1452. -c "Deserializing connection..." \
  1453. -S "Deserializing connection..."
  1454. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1455. run_test "Context serialization, re-init, server serializes, CCM" \
  1456. "$P_SRV dtls=1 serialize=2 exchanges=2" \
  1457. "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
  1458. 0 \
  1459. -C "Deserializing connection..." \
  1460. -s "Deserializing connection..."
  1461. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1462. run_test "Context serialization, re-init, server serializes, ChaChaPoly" \
  1463. "$P_SRV dtls=1 serialize=2 exchanges=2" \
  1464. "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
  1465. 0 \
  1466. -C "Deserializing connection..." \
  1467. -s "Deserializing connection..."
  1468. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1469. run_test "Context serialization, re-init, server serializes, GCM" \
  1470. "$P_SRV dtls=1 serialize=2 exchanges=2" \
  1471. "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
  1472. 0 \
  1473. -C "Deserializing connection..." \
  1474. -s "Deserializing connection..."
  1475. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1476. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1477. run_test "Context serialization, re-init, server serializes, with CID" \
  1478. "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
  1479. "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
  1480. 0 \
  1481. -C "Deserializing connection..." \
  1482. -s "Deserializing connection..."
  1483. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1484. run_test "Context serialization, re-init, both serialize, CCM" \
  1485. "$P_SRV dtls=1 serialize=2 exchanges=2" \
  1486. "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
  1487. 0 \
  1488. -c "Deserializing connection..." \
  1489. -s "Deserializing connection..."
  1490. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1491. run_test "Context serialization, re-init, both serialize, ChaChaPoly" \
  1492. "$P_SRV dtls=1 serialize=2 exchanges=2" \
  1493. "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
  1494. 0 \
  1495. -c "Deserializing connection..." \
  1496. -s "Deserializing connection..."
  1497. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1498. run_test "Context serialization, re-init, both serialize, GCM" \
  1499. "$P_SRV dtls=1 serialize=2 exchanges=2" \
  1500. "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
  1501. 0 \
  1502. -c "Deserializing connection..." \
  1503. -s "Deserializing connection..."
  1504. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1505. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1506. run_test "Context serialization, re-init, both serialize, with CID" \
  1507. "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
  1508. "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
  1509. 0 \
  1510. -c "Deserializing connection..." \
  1511. -s "Deserializing connection..."
  1512. requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
  1513. run_test "Saving the serialized context to a file" \
  1514. "$P_SRV dtls=1 serialize=1 context_file=context_srv.txt" \
  1515. "$P_CLI dtls=1 serialize=1 context_file=context_cli.txt" \
  1516. 0 \
  1517. -s "Save serialized context to a file... ok" \
  1518. -c "Save serialized context to a file... ok"
  1519. rm -f context_srv.txt
  1520. rm -f context_cli.txt
  1521. # Tests for DTLS Connection ID extension
  1522. # So far, the CID API isn't implemented, so we can't
  1523. # grep for output witnessing its use. This needs to be
  1524. # changed once the CID extension is implemented.
  1525. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1526. run_test "Connection ID: Cli enabled, Srv disabled" \
  1527. "$P_SRV debug_level=3 dtls=1 cid=0" \
  1528. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
  1529. 0 \
  1530. -s "Disable use of CID extension." \
  1531. -s "found CID extension" \
  1532. -s "Client sent CID extension, but CID disabled" \
  1533. -c "Enable use of CID extension." \
  1534. -c "client hello, adding CID extension" \
  1535. -S "server hello, adding CID extension" \
  1536. -C "found CID extension" \
  1537. -S "Copy CIDs into SSL transform" \
  1538. -C "Copy CIDs into SSL transform" \
  1539. -c "Use of Connection ID was rejected by the server"
  1540. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1541. run_test "Connection ID: Cli disabled, Srv enabled" \
  1542. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
  1543. "$P_CLI debug_level=3 dtls=1 cid=0" \
  1544. 0 \
  1545. -c "Disable use of CID extension." \
  1546. -C "client hello, adding CID extension" \
  1547. -S "found CID extension" \
  1548. -s "Enable use of CID extension." \
  1549. -S "server hello, adding CID extension" \
  1550. -C "found CID extension" \
  1551. -S "Copy CIDs into SSL transform" \
  1552. -C "Copy CIDs into SSL transform" \
  1553. -s "Use of Connection ID was not offered by client"
  1554. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1555. run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty" \
  1556. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
  1557. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef" \
  1558. 0 \
  1559. -c "Enable use of CID extension." \
  1560. -s "Enable use of CID extension." \
  1561. -c "client hello, adding CID extension" \
  1562. -s "found CID extension" \
  1563. -s "Use of CID extension negotiated" \
  1564. -s "server hello, adding CID extension" \
  1565. -c "found CID extension" \
  1566. -c "Use of CID extension negotiated" \
  1567. -s "Copy CIDs into SSL transform" \
  1568. -c "Copy CIDs into SSL transform" \
  1569. -c "Peer CID (length 2 Bytes): de ad" \
  1570. -s "Peer CID (length 2 Bytes): be ef" \
  1571. -s "Use of Connection ID has been negotiated" \
  1572. -c "Use of Connection ID has been negotiated"
  1573. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1574. run_test "Connection ID, 3D: Cli+Srv enabled, Cli+Srv CID nonempty" \
  1575. -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
  1576. "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead" \
  1577. "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef" \
  1578. 0 \
  1579. -c "Enable use of CID extension." \
  1580. -s "Enable use of CID extension." \
  1581. -c "client hello, adding CID extension" \
  1582. -s "found CID extension" \
  1583. -s "Use of CID extension negotiated" \
  1584. -s "server hello, adding CID extension" \
  1585. -c "found CID extension" \
  1586. -c "Use of CID extension negotiated" \
  1587. -s "Copy CIDs into SSL transform" \
  1588. -c "Copy CIDs into SSL transform" \
  1589. -c "Peer CID (length 2 Bytes): de ad" \
  1590. -s "Peer CID (length 2 Bytes): be ef" \
  1591. -s "Use of Connection ID has been negotiated" \
  1592. -c "Use of Connection ID has been negotiated" \
  1593. -c "ignoring unexpected CID" \
  1594. -s "ignoring unexpected CID"
  1595. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1596. run_test "Connection ID, MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
  1597. -p "$P_PXY mtu=800" \
  1598. "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
  1599. "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
  1600. 0 \
  1601. -c "Enable use of CID extension." \
  1602. -s "Enable use of CID extension." \
  1603. -c "client hello, adding CID extension" \
  1604. -s "found CID extension" \
  1605. -s "Use of CID extension negotiated" \
  1606. -s "server hello, adding CID extension" \
  1607. -c "found CID extension" \
  1608. -c "Use of CID extension negotiated" \
  1609. -s "Copy CIDs into SSL transform" \
  1610. -c "Copy CIDs into SSL transform" \
  1611. -c "Peer CID (length 2 Bytes): de ad" \
  1612. -s "Peer CID (length 2 Bytes): be ef" \
  1613. -s "Use of Connection ID has been negotiated" \
  1614. -c "Use of Connection ID has been negotiated"
  1615. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1616. run_test "Connection ID, 3D+MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
  1617. -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
  1618. "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
  1619. "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
  1620. 0 \
  1621. -c "Enable use of CID extension." \
  1622. -s "Enable use of CID extension." \
  1623. -c "client hello, adding CID extension" \
  1624. -s "found CID extension" \
  1625. -s "Use of CID extension negotiated" \
  1626. -s "server hello, adding CID extension" \
  1627. -c "found CID extension" \
  1628. -c "Use of CID extension negotiated" \
  1629. -s "Copy CIDs into SSL transform" \
  1630. -c "Copy CIDs into SSL transform" \
  1631. -c "Peer CID (length 2 Bytes): de ad" \
  1632. -s "Peer CID (length 2 Bytes): be ef" \
  1633. -s "Use of Connection ID has been negotiated" \
  1634. -c "Use of Connection ID has been negotiated" \
  1635. -c "ignoring unexpected CID" \
  1636. -s "ignoring unexpected CID"
  1637. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1638. run_test "Connection ID: Cli+Srv enabled, Cli CID empty" \
  1639. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
  1640. "$P_CLI debug_level=3 dtls=1 cid=1" \
  1641. 0 \
  1642. -c "Enable use of CID extension." \
  1643. -s "Enable use of CID extension." \
  1644. -c "client hello, adding CID extension" \
  1645. -s "found CID extension" \
  1646. -s "Use of CID extension negotiated" \
  1647. -s "server hello, adding CID extension" \
  1648. -c "found CID extension" \
  1649. -c "Use of CID extension negotiated" \
  1650. -s "Copy CIDs into SSL transform" \
  1651. -c "Copy CIDs into SSL transform" \
  1652. -c "Peer CID (length 4 Bytes): de ad be ef" \
  1653. -s "Peer CID (length 0 Bytes):" \
  1654. -s "Use of Connection ID has been negotiated" \
  1655. -c "Use of Connection ID has been negotiated"
  1656. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1657. run_test "Connection ID: Cli+Srv enabled, Srv CID empty" \
  1658. "$P_SRV debug_level=3 dtls=1 cid=1" \
  1659. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
  1660. 0 \
  1661. -c "Enable use of CID extension." \
  1662. -s "Enable use of CID extension." \
  1663. -c "client hello, adding CID extension" \
  1664. -s "found CID extension" \
  1665. -s "Use of CID extension negotiated" \
  1666. -s "server hello, adding CID extension" \
  1667. -c "found CID extension" \
  1668. -c "Use of CID extension negotiated" \
  1669. -s "Copy CIDs into SSL transform" \
  1670. -c "Copy CIDs into SSL transform" \
  1671. -s "Peer CID (length 4 Bytes): de ad be ef" \
  1672. -c "Peer CID (length 0 Bytes):" \
  1673. -s "Use of Connection ID has been negotiated" \
  1674. -c "Use of Connection ID has been negotiated"
  1675. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1676. run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty" \
  1677. "$P_SRV debug_level=3 dtls=1 cid=1" \
  1678. "$P_CLI debug_level=3 dtls=1 cid=1" \
  1679. 0 \
  1680. -c "Enable use of CID extension." \
  1681. -s "Enable use of CID extension." \
  1682. -c "client hello, adding CID extension" \
  1683. -s "found CID extension" \
  1684. -s "Use of CID extension negotiated" \
  1685. -s "server hello, adding CID extension" \
  1686. -c "found CID extension" \
  1687. -c "Use of CID extension negotiated" \
  1688. -s "Copy CIDs into SSL transform" \
  1689. -c "Copy CIDs into SSL transform" \
  1690. -S "Use of Connection ID has been negotiated" \
  1691. -C "Use of Connection ID has been negotiated"
  1692. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1693. run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CCM-8" \
  1694. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
  1695. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
  1696. 0 \
  1697. -c "Enable use of CID extension." \
  1698. -s "Enable use of CID extension." \
  1699. -c "client hello, adding CID extension" \
  1700. -s "found CID extension" \
  1701. -s "Use of CID extension negotiated" \
  1702. -s "server hello, adding CID extension" \
  1703. -c "found CID extension" \
  1704. -c "Use of CID extension negotiated" \
  1705. -s "Copy CIDs into SSL transform" \
  1706. -c "Copy CIDs into SSL transform" \
  1707. -c "Peer CID (length 2 Bytes): de ad" \
  1708. -s "Peer CID (length 2 Bytes): be ef" \
  1709. -s "Use of Connection ID has been negotiated" \
  1710. -c "Use of Connection ID has been negotiated"
  1711. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1712. run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CCM-8" \
  1713. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
  1714. "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
  1715. 0 \
  1716. -c "Enable use of CID extension." \
  1717. -s "Enable use of CID extension." \
  1718. -c "client hello, adding CID extension" \
  1719. -s "found CID extension" \
  1720. -s "Use of CID extension negotiated" \
  1721. -s "server hello, adding CID extension" \
  1722. -c "found CID extension" \
  1723. -c "Use of CID extension negotiated" \
  1724. -s "Copy CIDs into SSL transform" \
  1725. -c "Copy CIDs into SSL transform" \
  1726. -c "Peer CID (length 4 Bytes): de ad be ef" \
  1727. -s "Peer CID (length 0 Bytes):" \
  1728. -s "Use of Connection ID has been negotiated" \
  1729. -c "Use of Connection ID has been negotiated"
  1730. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1731. run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CCM-8" \
  1732. "$P_SRV debug_level=3 dtls=1 cid=1" \
  1733. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
  1734. 0 \
  1735. -c "Enable use of CID extension." \
  1736. -s "Enable use of CID extension." \
  1737. -c "client hello, adding CID extension" \
  1738. -s "found CID extension" \
  1739. -s "Use of CID extension negotiated" \
  1740. -s "server hello, adding CID extension" \
  1741. -c "found CID extension" \
  1742. -c "Use of CID extension negotiated" \
  1743. -s "Copy CIDs into SSL transform" \
  1744. -c "Copy CIDs into SSL transform" \
  1745. -s "Peer CID (length 4 Bytes): de ad be ef" \
  1746. -c "Peer CID (length 0 Bytes):" \
  1747. -s "Use of Connection ID has been negotiated" \
  1748. -c "Use of Connection ID has been negotiated"
  1749. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1750. run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CCM-8" \
  1751. "$P_SRV debug_level=3 dtls=1 cid=1" \
  1752. "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
  1753. 0 \
  1754. -c "Enable use of CID extension." \
  1755. -s "Enable use of CID extension." \
  1756. -c "client hello, adding CID extension" \
  1757. -s "found CID extension" \
  1758. -s "Use of CID extension negotiated" \
  1759. -s "server hello, adding CID extension" \
  1760. -c "found CID extension" \
  1761. -c "Use of CID extension negotiated" \
  1762. -s "Copy CIDs into SSL transform" \
  1763. -c "Copy CIDs into SSL transform" \
  1764. -S "Use of Connection ID has been negotiated" \
  1765. -C "Use of Connection ID has been negotiated"
  1766. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1767. run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CBC" \
  1768. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
  1769. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
  1770. 0 \
  1771. -c "Enable use of CID extension." \
  1772. -s "Enable use of CID extension." \
  1773. -c "client hello, adding CID extension" \
  1774. -s "found CID extension" \
  1775. -s "Use of CID extension negotiated" \
  1776. -s "server hello, adding CID extension" \
  1777. -c "found CID extension" \
  1778. -c "Use of CID extension negotiated" \
  1779. -s "Copy CIDs into SSL transform" \
  1780. -c "Copy CIDs into SSL transform" \
  1781. -c "Peer CID (length 2 Bytes): de ad" \
  1782. -s "Peer CID (length 2 Bytes): be ef" \
  1783. -s "Use of Connection ID has been negotiated" \
  1784. -c "Use of Connection ID has been negotiated"
  1785. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1786. run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CBC" \
  1787. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
  1788. "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
  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 4 Bytes): de ad be ef" \
  1801. -s "Peer CID (length 0 Bytes):" \
  1802. -s "Use of Connection ID has been negotiated" \
  1803. -c "Use of Connection ID has been negotiated"
  1804. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1805. run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CBC" \
  1806. "$P_SRV debug_level=3 dtls=1 cid=1" \
  1807. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
  1808. 0 \
  1809. -c "Enable use of CID extension." \
  1810. -s "Enable use of CID extension." \
  1811. -c "client hello, adding CID extension" \
  1812. -s "found CID extension" \
  1813. -s "Use of CID extension negotiated" \
  1814. -s "server hello, adding CID extension" \
  1815. -c "found CID extension" \
  1816. -c "Use of CID extension negotiated" \
  1817. -s "Copy CIDs into SSL transform" \
  1818. -c "Copy CIDs into SSL transform" \
  1819. -s "Peer CID (length 4 Bytes): de ad be ef" \
  1820. -c "Peer CID (length 0 Bytes):" \
  1821. -s "Use of Connection ID has been negotiated" \
  1822. -c "Use of Connection ID has been negotiated"
  1823. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1824. run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CBC" \
  1825. "$P_SRV debug_level=3 dtls=1 cid=1" \
  1826. "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
  1827. 0 \
  1828. -c "Enable use of CID extension." \
  1829. -s "Enable use of CID extension." \
  1830. -c "client hello, adding CID extension" \
  1831. -s "found CID extension" \
  1832. -s "Use of CID extension negotiated" \
  1833. -s "server hello, adding CID extension" \
  1834. -c "found CID extension" \
  1835. -c "Use of CID extension negotiated" \
  1836. -s "Copy CIDs into SSL transform" \
  1837. -c "Copy CIDs into SSL transform" \
  1838. -S "Use of Connection ID has been negotiated" \
  1839. -C "Use of Connection ID has been negotiated"
  1840. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1841. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  1842. run_test "Connection ID: Cli+Srv enabled, renegotiate without change of CID" \
  1843. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
  1844. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
  1845. 0 \
  1846. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  1847. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  1848. -s "(initial handshake) Use of Connection ID has been negotiated" \
  1849. -c "(initial handshake) Use of Connection ID has been negotiated" \
  1850. -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  1851. -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  1852. -s "(after renegotiation) Use of Connection ID has been negotiated" \
  1853. -c "(after renegotiation) Use of Connection ID has been negotiated"
  1854. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1855. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  1856. run_test "Connection ID: Cli+Srv enabled, renegotiate with different CID" \
  1857. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
  1858. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
  1859. 0 \
  1860. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  1861. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  1862. -s "(initial handshake) Use of Connection ID has been negotiated" \
  1863. -c "(initial handshake) Use of Connection ID has been negotiated" \
  1864. -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  1865. -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  1866. -s "(after renegotiation) Use of Connection ID has been negotiated" \
  1867. -c "(after renegotiation) Use of Connection ID has been negotiated"
  1868. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1869. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  1870. run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate with different CID" \
  1871. "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead cid_val_renego=beef renegotiation=1" \
  1872. "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
  1873. 0 \
  1874. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  1875. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  1876. -s "(initial handshake) Use of Connection ID has been negotiated" \
  1877. -c "(initial handshake) Use of Connection ID has been negotiated" \
  1878. -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  1879. -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  1880. -s "(after renegotiation) Use of Connection ID has been negotiated" \
  1881. -c "(after renegotiation) Use of Connection ID has been negotiated"
  1882. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1883. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  1884. run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate with different CID" \
  1885. -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
  1886. "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
  1887. "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
  1888. 0 \
  1889. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  1890. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  1891. -s "(initial handshake) Use of Connection ID has been negotiated" \
  1892. -c "(initial handshake) Use of Connection ID has been negotiated" \
  1893. -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  1894. -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  1895. -s "(after renegotiation) Use of Connection ID has been negotiated" \
  1896. -c "(after renegotiation) Use of Connection ID has been negotiated" \
  1897. -c "ignoring unexpected CID" \
  1898. -s "ignoring unexpected CID"
  1899. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1900. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  1901. run_test "Connection ID: Cli+Srv enabled, renegotiate without CID" \
  1902. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
  1903. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
  1904. 0 \
  1905. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  1906. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  1907. -s "(initial handshake) Use of Connection ID has been negotiated" \
  1908. -c "(initial handshake) Use of Connection ID has been negotiated" \
  1909. -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  1910. -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  1911. -C "(after renegotiation) Use of Connection ID has been negotiated" \
  1912. -S "(after renegotiation) Use of Connection ID has been negotiated"
  1913. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1914. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  1915. run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate without CID" \
  1916. "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
  1917. "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
  1918. 0 \
  1919. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  1920. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  1921. -s "(initial handshake) Use of Connection ID has been negotiated" \
  1922. -c "(initial handshake) Use of Connection ID has been negotiated" \
  1923. -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  1924. -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  1925. -C "(after renegotiation) Use of Connection ID has been negotiated" \
  1926. -S "(after renegotiation) Use of Connection ID has been negotiated"
  1927. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1928. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  1929. run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate without CID" \
  1930. -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
  1931. "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
  1932. "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
  1933. 0 \
  1934. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  1935. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  1936. -s "(initial handshake) Use of Connection ID has been negotiated" \
  1937. -c "(initial handshake) Use of Connection ID has been negotiated" \
  1938. -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  1939. -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  1940. -C "(after renegotiation) Use of Connection ID has been negotiated" \
  1941. -S "(after renegotiation) Use of Connection ID has been negotiated" \
  1942. -c "ignoring unexpected CID" \
  1943. -s "ignoring unexpected CID"
  1944. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1945. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  1946. run_test "Connection ID: Cli+Srv enabled, CID on renegotiation" \
  1947. "$P_SRV debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
  1948. "$P_CLI debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
  1949. 0 \
  1950. -S "(initial handshake) Use of Connection ID has been negotiated" \
  1951. -C "(initial handshake) Use of Connection ID has been negotiated" \
  1952. -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  1953. -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  1954. -c "(after renegotiation) Use of Connection ID has been negotiated" \
  1955. -s "(after renegotiation) Use of Connection ID has been negotiated"
  1956. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1957. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  1958. run_test "Connection ID, no packing: Cli+Srv enabled, CID on renegotiation" \
  1959. "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
  1960. "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
  1961. 0 \
  1962. -S "(initial handshake) Use of Connection ID has been negotiated" \
  1963. -C "(initial handshake) Use of Connection ID has been negotiated" \
  1964. -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  1965. -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  1966. -c "(after renegotiation) Use of Connection ID has been negotiated" \
  1967. -s "(after renegotiation) Use of Connection ID has been negotiated"
  1968. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1969. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  1970. run_test "Connection ID, 3D+MTU: Cli+Srv enabled, CID on renegotiation" \
  1971. -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
  1972. "$P_SRV debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
  1973. "$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" \
  1974. 0 \
  1975. -S "(initial handshake) Use of Connection ID has been negotiated" \
  1976. -C "(initial handshake) Use of Connection ID has been negotiated" \
  1977. -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  1978. -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  1979. -c "(after renegotiation) Use of Connection ID has been negotiated" \
  1980. -s "(after renegotiation) Use of Connection ID has been negotiated" \
  1981. -c "ignoring unexpected CID" \
  1982. -s "ignoring unexpected CID"
  1983. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1984. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  1985. run_test "Connection ID: Cli+Srv enabled, Cli disables on renegotiation" \
  1986. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
  1987. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
  1988. 0 \
  1989. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  1990. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  1991. -s "(initial handshake) Use of Connection ID has been negotiated" \
  1992. -c "(initial handshake) Use of Connection ID has been negotiated" \
  1993. -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  1994. -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  1995. -C "(after renegotiation) Use of Connection ID has been negotiated" \
  1996. -S "(after renegotiation) Use of Connection ID has been negotiated" \
  1997. -s "(after renegotiation) Use of Connection ID was not offered by client"
  1998. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  1999. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  2000. run_test "Connection ID, 3D: Cli+Srv enabled, Cli disables on renegotiation" \
  2001. -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
  2002. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
  2003. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
  2004. 0 \
  2005. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  2006. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  2007. -s "(initial handshake) Use of Connection ID has been negotiated" \
  2008. -c "(initial handshake) Use of Connection ID has been negotiated" \
  2009. -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  2010. -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  2011. -C "(after renegotiation) Use of Connection ID has been negotiated" \
  2012. -S "(after renegotiation) Use of Connection ID has been negotiated" \
  2013. -s "(after renegotiation) Use of Connection ID was not offered by client" \
  2014. -c "ignoring unexpected CID" \
  2015. -s "ignoring unexpected CID"
  2016. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  2017. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  2018. run_test "Connection ID: Cli+Srv enabled, Srv disables on renegotiation" \
  2019. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
  2020. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
  2021. 0 \
  2022. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  2023. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  2024. -s "(initial handshake) Use of Connection ID has been negotiated" \
  2025. -c "(initial handshake) Use of Connection ID has been negotiated" \
  2026. -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  2027. -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  2028. -C "(after renegotiation) Use of Connection ID has been negotiated" \
  2029. -S "(after renegotiation) Use of Connection ID has been negotiated" \
  2030. -c "(after renegotiation) Use of Connection ID was rejected by the server"
  2031. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  2032. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  2033. run_test "Connection ID, 3D: Cli+Srv enabled, Srv disables on renegotiation" \
  2034. -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
  2035. "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
  2036. "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
  2037. 0 \
  2038. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  2039. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  2040. -s "(initial handshake) Use of Connection ID has been negotiated" \
  2041. -c "(initial handshake) Use of Connection ID has been negotiated" \
  2042. -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
  2043. -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
  2044. -C "(after renegotiation) Use of Connection ID has been negotiated" \
  2045. -S "(after renegotiation) Use of Connection ID has been negotiated" \
  2046. -c "(after renegotiation) Use of Connection ID was rejected by the server" \
  2047. -c "ignoring unexpected CID" \
  2048. -s "ignoring unexpected CID"
  2049. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  2050. requires_config_enabled MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
  2051. run_test "Connection ID: Cli+Srv enabled, variable buffer lengths, MFL=512" \
  2052. "$P_SRV dtls=1 cid=1 cid_val=dead debug_level=2" \
  2053. "$P_CLI force_ciphersuite="TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" max_frag_len=512 dtls=1 cid=1 cid_val=beef" \
  2054. 0 \
  2055. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  2056. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  2057. -s "(initial handshake) Use of Connection ID has been negotiated" \
  2058. -c "(initial handshake) Use of Connection ID has been negotiated" \
  2059. -s "Reallocating in_buf" \
  2060. -s "Reallocating out_buf"
  2061. requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
  2062. requires_config_enabled MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
  2063. run_test "Connection ID: Cli+Srv enabled, variable buffer lengths, MFL=1024" \
  2064. "$P_SRV dtls=1 cid=1 cid_val=dead debug_level=2" \
  2065. "$P_CLI force_ciphersuite="TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" max_frag_len=1024 dtls=1 cid=1 cid_val=beef" \
  2066. 0 \
  2067. -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
  2068. -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
  2069. -s "(initial handshake) Use of Connection ID has been negotiated" \
  2070. -c "(initial handshake) Use of Connection ID has been negotiated" \
  2071. -s "Reallocating in_buf" \
  2072. -s "Reallocating out_buf"
  2073. # Tests for Encrypt-then-MAC extension
  2074. run_test "Encrypt then MAC: default" \
  2075. "$P_SRV debug_level=3 \
  2076. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  2077. "$P_CLI debug_level=3" \
  2078. 0 \
  2079. -c "client hello, adding encrypt_then_mac extension" \
  2080. -s "found encrypt then mac extension" \
  2081. -s "server hello, adding encrypt then mac extension" \
  2082. -c "found encrypt_then_mac extension" \
  2083. -c "using encrypt then mac" \
  2084. -s "using encrypt then mac"
  2085. run_test "Encrypt then MAC: client enabled, server disabled" \
  2086. "$P_SRV debug_level=3 etm=0 \
  2087. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  2088. "$P_CLI debug_level=3 etm=1" \
  2089. 0 \
  2090. -c "client hello, adding encrypt_then_mac extension" \
  2091. -s "found encrypt then mac extension" \
  2092. -S "server hello, adding encrypt then mac extension" \
  2093. -C "found encrypt_then_mac extension" \
  2094. -C "using encrypt then mac" \
  2095. -S "using encrypt then mac"
  2096. run_test "Encrypt then MAC: client enabled, aead cipher" \
  2097. "$P_SRV debug_level=3 etm=1 \
  2098. force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
  2099. "$P_CLI debug_level=3 etm=1" \
  2100. 0 \
  2101. -c "client hello, adding encrypt_then_mac extension" \
  2102. -s "found encrypt then mac extension" \
  2103. -S "server hello, adding encrypt then mac extension" \
  2104. -C "found encrypt_then_mac extension" \
  2105. -C "using encrypt then mac" \
  2106. -S "using encrypt then mac"
  2107. run_test "Encrypt then MAC: client enabled, stream cipher" \
  2108. "$P_SRV debug_level=3 etm=1 \
  2109. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  2110. "$P_CLI debug_level=3 etm=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  2111. 0 \
  2112. -c "client hello, adding encrypt_then_mac extension" \
  2113. -s "found encrypt then mac extension" \
  2114. -S "server hello, adding encrypt then mac extension" \
  2115. -C "found encrypt_then_mac extension" \
  2116. -C "using encrypt then mac" \
  2117. -S "using encrypt then mac"
  2118. run_test "Encrypt then MAC: client disabled, server enabled" \
  2119. "$P_SRV debug_level=3 etm=1 \
  2120. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  2121. "$P_CLI debug_level=3 etm=0" \
  2122. 0 \
  2123. -C "client hello, adding encrypt_then_mac extension" \
  2124. -S "found encrypt then mac extension" \
  2125. -S "server hello, adding encrypt then mac extension" \
  2126. -C "found encrypt_then_mac extension" \
  2127. -C "using encrypt then mac" \
  2128. -S "using encrypt then mac"
  2129. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  2130. run_test "Encrypt then MAC: client SSLv3, server enabled" \
  2131. "$P_SRV debug_level=3 min_version=ssl3 \
  2132. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  2133. "$P_CLI debug_level=3 force_version=ssl3" \
  2134. 0 \
  2135. -C "client hello, adding encrypt_then_mac extension" \
  2136. -S "found encrypt then mac extension" \
  2137. -S "server hello, adding encrypt then mac extension" \
  2138. -C "found encrypt_then_mac extension" \
  2139. -C "using encrypt then mac" \
  2140. -S "using encrypt then mac"
  2141. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  2142. run_test "Encrypt then MAC: client enabled, server SSLv3" \
  2143. "$P_SRV debug_level=3 force_version=ssl3 \
  2144. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  2145. "$P_CLI debug_level=3 min_version=ssl3" \
  2146. 0 \
  2147. -c "client hello, adding encrypt_then_mac extension" \
  2148. -S "found encrypt then mac extension" \
  2149. -S "server hello, adding encrypt then mac extension" \
  2150. -C "found encrypt_then_mac extension" \
  2151. -C "using encrypt then mac" \
  2152. -S "using encrypt then mac"
  2153. # Tests for Extended Master Secret extension
  2154. run_test "Extended Master Secret: default" \
  2155. "$P_SRV debug_level=3" \
  2156. "$P_CLI debug_level=3" \
  2157. 0 \
  2158. -c "client hello, adding extended_master_secret extension" \
  2159. -s "found extended master secret extension" \
  2160. -s "server hello, adding extended master secret extension" \
  2161. -c "found extended_master_secret extension" \
  2162. -c "session hash for extended master secret" \
  2163. -s "session hash for extended master secret"
  2164. run_test "Extended Master Secret: client enabled, server disabled" \
  2165. "$P_SRV debug_level=3 extended_ms=0" \
  2166. "$P_CLI debug_level=3 extended_ms=1" \
  2167. 0 \
  2168. -c "client hello, adding extended_master_secret extension" \
  2169. -s "found extended master secret extension" \
  2170. -S "server hello, adding extended master secret extension" \
  2171. -C "found extended_master_secret extension" \
  2172. -C "session hash for extended master secret" \
  2173. -S "session hash for extended master secret"
  2174. run_test "Extended Master Secret: client disabled, server enabled" \
  2175. "$P_SRV debug_level=3 extended_ms=1" \
  2176. "$P_CLI debug_level=3 extended_ms=0" \
  2177. 0 \
  2178. -C "client hello, adding extended_master_secret extension" \
  2179. -S "found extended master secret extension" \
  2180. -S "server hello, adding extended master secret extension" \
  2181. -C "found extended_master_secret extension" \
  2182. -C "session hash for extended master secret" \
  2183. -S "session hash for extended master secret"
  2184. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  2185. run_test "Extended Master Secret: client SSLv3, server enabled" \
  2186. "$P_SRV debug_level=3 min_version=ssl3" \
  2187. "$P_CLI debug_level=3 force_version=ssl3" \
  2188. 0 \
  2189. -C "client hello, adding extended_master_secret extension" \
  2190. -S "found extended master secret extension" \
  2191. -S "server hello, adding extended master secret extension" \
  2192. -C "found extended_master_secret extension" \
  2193. -C "session hash for extended master secret" \
  2194. -S "session hash for extended master secret"
  2195. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  2196. run_test "Extended Master Secret: client enabled, server SSLv3" \
  2197. "$P_SRV debug_level=3 force_version=ssl3" \
  2198. "$P_CLI debug_level=3 min_version=ssl3" \
  2199. 0 \
  2200. -c "client hello, adding extended_master_secret extension" \
  2201. -S "found extended master secret extension" \
  2202. -S "server hello, adding extended master secret extension" \
  2203. -C "found extended_master_secret extension" \
  2204. -C "session hash for extended master secret" \
  2205. -S "session hash for extended master secret"
  2206. # Tests for FALLBACK_SCSV
  2207. run_test "Fallback SCSV: default" \
  2208. "$P_SRV debug_level=2" \
  2209. "$P_CLI debug_level=3 force_version=tls1_1" \
  2210. 0 \
  2211. -C "adding FALLBACK_SCSV" \
  2212. -S "received FALLBACK_SCSV" \
  2213. -S "inapropriate fallback" \
  2214. -C "is a fatal alert message (msg 86)"
  2215. run_test "Fallback SCSV: explicitly disabled" \
  2216. "$P_SRV debug_level=2" \
  2217. "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
  2218. 0 \
  2219. -C "adding FALLBACK_SCSV" \
  2220. -S "received FALLBACK_SCSV" \
  2221. -S "inapropriate fallback" \
  2222. -C "is a fatal alert message (msg 86)"
  2223. run_test "Fallback SCSV: enabled" \
  2224. "$P_SRV debug_level=2" \
  2225. "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
  2226. 1 \
  2227. -c "adding FALLBACK_SCSV" \
  2228. -s "received FALLBACK_SCSV" \
  2229. -s "inapropriate fallback" \
  2230. -c "is a fatal alert message (msg 86)"
  2231. run_test "Fallback SCSV: enabled, max version" \
  2232. "$P_SRV debug_level=2" \
  2233. "$P_CLI debug_level=3 fallback=1" \
  2234. 0 \
  2235. -c "adding FALLBACK_SCSV" \
  2236. -s "received FALLBACK_SCSV" \
  2237. -S "inapropriate fallback" \
  2238. -C "is a fatal alert message (msg 86)"
  2239. requires_openssl_with_fallback_scsv
  2240. run_test "Fallback SCSV: default, openssl server" \
  2241. "$O_SRV" \
  2242. "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
  2243. 0 \
  2244. -C "adding FALLBACK_SCSV" \
  2245. -C "is a fatal alert message (msg 86)"
  2246. requires_openssl_with_fallback_scsv
  2247. run_test "Fallback SCSV: enabled, openssl server" \
  2248. "$O_SRV" \
  2249. "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
  2250. 1 \
  2251. -c "adding FALLBACK_SCSV" \
  2252. -c "is a fatal alert message (msg 86)"
  2253. requires_openssl_with_fallback_scsv
  2254. run_test "Fallback SCSV: disabled, openssl client" \
  2255. "$P_SRV debug_level=2" \
  2256. "$O_CLI -tls1_1" \
  2257. 0 \
  2258. -S "received FALLBACK_SCSV" \
  2259. -S "inapropriate fallback"
  2260. requires_openssl_with_fallback_scsv
  2261. run_test "Fallback SCSV: enabled, openssl client" \
  2262. "$P_SRV debug_level=2" \
  2263. "$O_CLI -tls1_1 -fallback_scsv" \
  2264. 1 \
  2265. -s "received FALLBACK_SCSV" \
  2266. -s "inapropriate fallback"
  2267. requires_openssl_with_fallback_scsv
  2268. run_test "Fallback SCSV: enabled, max version, openssl client" \
  2269. "$P_SRV debug_level=2" \
  2270. "$O_CLI -fallback_scsv" \
  2271. 0 \
  2272. -s "received FALLBACK_SCSV" \
  2273. -S "inapropriate fallback"
  2274. # Test sending and receiving empty application data records
  2275. run_test "Encrypt then MAC: empty application data record" \
  2276. "$P_SRV auth_mode=none debug_level=4 etm=1" \
  2277. "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
  2278. 0 \
  2279. -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
  2280. -s "dumping 'input payload after decrypt' (0 bytes)" \
  2281. -c "0 bytes written in 1 fragments"
  2282. run_test "Encrypt then MAC: disabled, empty application data record" \
  2283. "$P_SRV auth_mode=none debug_level=4 etm=0" \
  2284. "$P_CLI auth_mode=none etm=0 request_size=0" \
  2285. 0 \
  2286. -s "dumping 'input payload after decrypt' (0 bytes)" \
  2287. -c "0 bytes written in 1 fragments"
  2288. run_test "Encrypt then MAC, DTLS: empty application data record" \
  2289. "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
  2290. "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
  2291. 0 \
  2292. -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
  2293. -s "dumping 'input payload after decrypt' (0 bytes)" \
  2294. -c "0 bytes written in 1 fragments"
  2295. run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
  2296. "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
  2297. "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
  2298. 0 \
  2299. -s "dumping 'input payload after decrypt' (0 bytes)" \
  2300. -c "0 bytes written in 1 fragments"
  2301. ## ClientHello generated with
  2302. ## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
  2303. ## then manually twiddling the ciphersuite list.
  2304. ## The ClientHello content is spelled out below as a hex string as
  2305. ## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
  2306. ## The expected response is an inappropriate_fallback alert.
  2307. requires_openssl_with_fallback_scsv
  2308. run_test "Fallback SCSV: beginning of list" \
  2309. "$P_SRV debug_level=2" \
  2310. "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
  2311. 0 \
  2312. -s "received FALLBACK_SCSV" \
  2313. -s "inapropriate fallback"
  2314. requires_openssl_with_fallback_scsv
  2315. run_test "Fallback SCSV: end of list" \
  2316. "$P_SRV debug_level=2" \
  2317. "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
  2318. 0 \
  2319. -s "received FALLBACK_SCSV" \
  2320. -s "inapropriate fallback"
  2321. ## Here the expected response is a valid ServerHello prefix, up to the random.
  2322. requires_openssl_with_fallback_scsv
  2323. run_test "Fallback SCSV: not in list" \
  2324. "$P_SRV debug_level=2" \
  2325. "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
  2326. 0 \
  2327. -S "received FALLBACK_SCSV" \
  2328. -S "inapropriate fallback"
  2329. # Tests for CBC 1/n-1 record splitting
  2330. run_test "CBC Record splitting: TLS 1.2, no splitting" \
  2331. "$P_SRV" \
  2332. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
  2333. request_size=123 force_version=tls1_2" \
  2334. 0 \
  2335. -s "Read from client: 123 bytes read" \
  2336. -S "Read from client: 1 bytes read" \
  2337. -S "122 bytes read"
  2338. run_test "CBC Record splitting: TLS 1.1, no splitting" \
  2339. "$P_SRV" \
  2340. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
  2341. request_size=123 force_version=tls1_1" \
  2342. 0 \
  2343. -s "Read from client: 123 bytes read" \
  2344. -S "Read from client: 1 bytes read" \
  2345. -S "122 bytes read"
  2346. run_test "CBC Record splitting: TLS 1.0, splitting" \
  2347. "$P_SRV" \
  2348. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
  2349. request_size=123 force_version=tls1" \
  2350. 0 \
  2351. -S "Read from client: 123 bytes read" \
  2352. -s "Read from client: 1 bytes read" \
  2353. -s "122 bytes read"
  2354. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  2355. run_test "CBC Record splitting: SSLv3, splitting" \
  2356. "$P_SRV min_version=ssl3" \
  2357. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
  2358. request_size=123 force_version=ssl3" \
  2359. 0 \
  2360. -S "Read from client: 123 bytes read" \
  2361. -s "Read from client: 1 bytes read" \
  2362. -s "122 bytes read"
  2363. run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
  2364. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  2365. "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
  2366. request_size=123 force_version=tls1" \
  2367. 0 \
  2368. -s "Read from client: 123 bytes read" \
  2369. -S "Read from client: 1 bytes read" \
  2370. -S "122 bytes read"
  2371. run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
  2372. "$P_SRV" \
  2373. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
  2374. request_size=123 force_version=tls1 recsplit=0" \
  2375. 0 \
  2376. -s "Read from client: 123 bytes read" \
  2377. -S "Read from client: 1 bytes read" \
  2378. -S "122 bytes read"
  2379. run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
  2380. "$P_SRV nbio=2" \
  2381. "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
  2382. request_size=123 force_version=tls1" \
  2383. 0 \
  2384. -S "Read from client: 123 bytes read" \
  2385. -s "Read from client: 1 bytes read" \
  2386. -s "122 bytes read"
  2387. # Tests for Session Tickets
  2388. run_test "Session resume using tickets: basic" \
  2389. "$P_SRV debug_level=3 tickets=1" \
  2390. "$P_CLI debug_level=3 tickets=1 reconnect=1" \
  2391. 0 \
  2392. -c "client hello, adding session ticket extension" \
  2393. -s "found session ticket extension" \
  2394. -s "server hello, adding session ticket extension" \
  2395. -c "found session_ticket extension" \
  2396. -c "parse new session ticket" \
  2397. -S "session successfully restored from cache" \
  2398. -s "session successfully restored from ticket" \
  2399. -s "a session has been resumed" \
  2400. -c "a session has been resumed"
  2401. run_test "Session resume using tickets: cache disabled" \
  2402. "$P_SRV debug_level=3 tickets=1 cache_max=0" \
  2403. "$P_CLI debug_level=3 tickets=1 reconnect=1" \
  2404. 0 \
  2405. -c "client hello, adding session ticket extension" \
  2406. -s "found session ticket extension" \
  2407. -s "server hello, adding session ticket extension" \
  2408. -c "found session_ticket extension" \
  2409. -c "parse new session ticket" \
  2410. -S "session successfully restored from cache" \
  2411. -s "session successfully restored from ticket" \
  2412. -s "a session has been resumed" \
  2413. -c "a session has been resumed"
  2414. run_test "Session resume using tickets: timeout" \
  2415. "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
  2416. "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
  2417. 0 \
  2418. -c "client hello, adding session ticket extension" \
  2419. -s "found session ticket extension" \
  2420. -s "server hello, adding session ticket extension" \
  2421. -c "found session_ticket extension" \
  2422. -c "parse new session ticket" \
  2423. -S "session successfully restored from cache" \
  2424. -S "session successfully restored from ticket" \
  2425. -S "a session has been resumed" \
  2426. -C "a session has been resumed"
  2427. run_test "Session resume using tickets: session copy" \
  2428. "$P_SRV debug_level=3 tickets=1 cache_max=0" \
  2429. "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_mode=0" \
  2430. 0 \
  2431. -c "client hello, adding session ticket extension" \
  2432. -s "found session ticket extension" \
  2433. -s "server hello, adding session ticket extension" \
  2434. -c "found session_ticket extension" \
  2435. -c "parse new session ticket" \
  2436. -S "session successfully restored from cache" \
  2437. -s "session successfully restored from ticket" \
  2438. -s "a session has been resumed" \
  2439. -c "a session has been resumed"
  2440. run_test "Session resume using tickets: openssl server" \
  2441. "$O_SRV" \
  2442. "$P_CLI debug_level=3 tickets=1 reconnect=1" \
  2443. 0 \
  2444. -c "client hello, adding session ticket extension" \
  2445. -c "found session_ticket extension" \
  2446. -c "parse new session ticket" \
  2447. -c "a session has been resumed"
  2448. run_test "Session resume using tickets: openssl client" \
  2449. "$P_SRV debug_level=3 tickets=1" \
  2450. "( $O_CLI -sess_out $SESSION; \
  2451. $O_CLI -sess_in $SESSION; \
  2452. rm -f $SESSION )" \
  2453. 0 \
  2454. -s "found session ticket extension" \
  2455. -s "server hello, adding session ticket extension" \
  2456. -S "session successfully restored from cache" \
  2457. -s "session successfully restored from ticket" \
  2458. -s "a session has been resumed"
  2459. # Tests for Session Tickets with DTLS
  2460. run_test "Session resume using tickets, DTLS: basic" \
  2461. "$P_SRV debug_level=3 dtls=1 tickets=1" \
  2462. "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
  2463. 0 \
  2464. -c "client hello, adding session ticket extension" \
  2465. -s "found session ticket extension" \
  2466. -s "server hello, adding session ticket extension" \
  2467. -c "found session_ticket extension" \
  2468. -c "parse new session ticket" \
  2469. -S "session successfully restored from cache" \
  2470. -s "session successfully restored from ticket" \
  2471. -s "a session has been resumed" \
  2472. -c "a session has been resumed"
  2473. run_test "Session resume using tickets, DTLS: cache disabled" \
  2474. "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
  2475. "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
  2476. 0 \
  2477. -c "client hello, adding session ticket extension" \
  2478. -s "found session ticket extension" \
  2479. -s "server hello, adding session ticket extension" \
  2480. -c "found session_ticket extension" \
  2481. -c "parse new session ticket" \
  2482. -S "session successfully restored from cache" \
  2483. -s "session successfully restored from ticket" \
  2484. -s "a session has been resumed" \
  2485. -c "a session has been resumed"
  2486. run_test "Session resume using tickets, DTLS: timeout" \
  2487. "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
  2488. "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1 reco_delay=2" \
  2489. 0 \
  2490. -c "client hello, adding session ticket extension" \
  2491. -s "found session ticket extension" \
  2492. -s "server hello, adding session ticket extension" \
  2493. -c "found session_ticket extension" \
  2494. -c "parse new session ticket" \
  2495. -S "session successfully restored from cache" \
  2496. -S "session successfully restored from ticket" \
  2497. -S "a session has been resumed" \
  2498. -C "a session has been resumed"
  2499. run_test "Session resume using tickets, DTLS: session copy" \
  2500. "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
  2501. "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1 reco_mode=0" \
  2502. 0 \
  2503. -c "client hello, adding session ticket extension" \
  2504. -s "found session ticket extension" \
  2505. -s "server hello, adding session ticket extension" \
  2506. -c "found session_ticket extension" \
  2507. -c "parse new session ticket" \
  2508. -S "session successfully restored from cache" \
  2509. -s "session successfully restored from ticket" \
  2510. -s "a session has been resumed" \
  2511. -c "a session has been resumed"
  2512. run_test "Session resume using tickets, DTLS: openssl server" \
  2513. "$O_SRV -dtls1" \
  2514. "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
  2515. 0 \
  2516. -c "client hello, adding session ticket extension" \
  2517. -c "found session_ticket extension" \
  2518. -c "parse new session ticket" \
  2519. -c "a session has been resumed"
  2520. run_test "Session resume using tickets, DTLS: openssl client" \
  2521. "$P_SRV dtls=1 debug_level=3 tickets=1" \
  2522. "( $O_CLI -dtls1 -sess_out $SESSION; \
  2523. $O_CLI -dtls1 -sess_in $SESSION; \
  2524. rm -f $SESSION )" \
  2525. 0 \
  2526. -s "found session ticket extension" \
  2527. -s "server hello, adding session ticket extension" \
  2528. -S "session successfully restored from cache" \
  2529. -s "session successfully restored from ticket" \
  2530. -s "a session has been resumed"
  2531. # Tests for Session Resume based on session-ID and cache
  2532. run_test "Session resume using cache: tickets enabled on client" \
  2533. "$P_SRV debug_level=3 tickets=0" \
  2534. "$P_CLI debug_level=3 tickets=1 reconnect=1" \
  2535. 0 \
  2536. -c "client hello, adding session ticket extension" \
  2537. -s "found session ticket extension" \
  2538. -S "server hello, adding session ticket extension" \
  2539. -C "found session_ticket extension" \
  2540. -C "parse new session ticket" \
  2541. -s "session successfully restored from cache" \
  2542. -S "session successfully restored from ticket" \
  2543. -s "a session has been resumed" \
  2544. -c "a session has been resumed"
  2545. run_test "Session resume using cache: tickets enabled on server" \
  2546. "$P_SRV debug_level=3 tickets=1" \
  2547. "$P_CLI debug_level=3 tickets=0 reconnect=1" \
  2548. 0 \
  2549. -C "client hello, adding session ticket extension" \
  2550. -S "found session ticket extension" \
  2551. -S "server hello, adding session ticket extension" \
  2552. -C "found session_ticket extension" \
  2553. -C "parse new session ticket" \
  2554. -s "session successfully restored from cache" \
  2555. -S "session successfully restored from ticket" \
  2556. -s "a session has been resumed" \
  2557. -c "a session has been resumed"
  2558. run_test "Session resume using cache: cache_max=0" \
  2559. "$P_SRV debug_level=3 tickets=0 cache_max=0" \
  2560. "$P_CLI debug_level=3 tickets=0 reconnect=1" \
  2561. 0 \
  2562. -S "session successfully restored from cache" \
  2563. -S "session successfully restored from ticket" \
  2564. -S "a session has been resumed" \
  2565. -C "a session has been resumed"
  2566. run_test "Session resume using cache: cache_max=1" \
  2567. "$P_SRV debug_level=3 tickets=0 cache_max=1" \
  2568. "$P_CLI debug_level=3 tickets=0 reconnect=1" \
  2569. 0 \
  2570. -s "session successfully restored from cache" \
  2571. -S "session successfully restored from ticket" \
  2572. -s "a session has been resumed" \
  2573. -c "a session has been resumed"
  2574. run_test "Session resume using cache: timeout > delay" \
  2575. "$P_SRV debug_level=3 tickets=0" \
  2576. "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
  2577. 0 \
  2578. -s "session successfully restored from cache" \
  2579. -S "session successfully restored from ticket" \
  2580. -s "a session has been resumed" \
  2581. -c "a session has been resumed"
  2582. run_test "Session resume using cache: timeout < delay" \
  2583. "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
  2584. "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
  2585. 0 \
  2586. -S "session successfully restored from cache" \
  2587. -S "session successfully restored from ticket" \
  2588. -S "a session has been resumed" \
  2589. -C "a session has been resumed"
  2590. run_test "Session resume using cache: no timeout" \
  2591. "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
  2592. "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
  2593. 0 \
  2594. -s "session successfully restored from cache" \
  2595. -S "session successfully restored from ticket" \
  2596. -s "a session has been resumed" \
  2597. -c "a session has been resumed"
  2598. run_test "Session resume using cache: session copy" \
  2599. "$P_SRV debug_level=3 tickets=0" \
  2600. "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
  2601. 0 \
  2602. -s "session successfully restored from cache" \
  2603. -S "session successfully restored from ticket" \
  2604. -s "a session has been resumed" \
  2605. -c "a session has been resumed"
  2606. run_test "Session resume using cache: openssl client" \
  2607. "$P_SRV debug_level=3 tickets=0" \
  2608. "( $O_CLI -sess_out $SESSION; \
  2609. $O_CLI -sess_in $SESSION; \
  2610. rm -f $SESSION )" \
  2611. 0 \
  2612. -s "found session ticket extension" \
  2613. -S "server hello, adding session ticket extension" \
  2614. -s "session successfully restored from cache" \
  2615. -S "session successfully restored from ticket" \
  2616. -s "a session has been resumed"
  2617. run_test "Session resume using cache: openssl server" \
  2618. "$O_SRV" \
  2619. "$P_CLI debug_level=3 tickets=0 reconnect=1" \
  2620. 0 \
  2621. -C "found session_ticket extension" \
  2622. -C "parse new session ticket" \
  2623. -c "a session has been resumed"
  2624. # Tests for Session Resume based on session-ID and cache, DTLS
  2625. run_test "Session resume using cache, DTLS: tickets enabled on client" \
  2626. "$P_SRV dtls=1 debug_level=3 tickets=0" \
  2627. "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
  2628. 0 \
  2629. -c "client hello, adding session ticket extension" \
  2630. -s "found session ticket extension" \
  2631. -S "server hello, adding session ticket extension" \
  2632. -C "found session_ticket extension" \
  2633. -C "parse new session ticket" \
  2634. -s "session successfully restored from cache" \
  2635. -S "session successfully restored from ticket" \
  2636. -s "a session has been resumed" \
  2637. -c "a session has been resumed"
  2638. run_test "Session resume using cache, DTLS: tickets enabled on server" \
  2639. "$P_SRV dtls=1 debug_level=3 tickets=1" \
  2640. "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
  2641. 0 \
  2642. -C "client hello, adding session ticket extension" \
  2643. -S "found session ticket extension" \
  2644. -S "server hello, adding session ticket extension" \
  2645. -C "found session_ticket extension" \
  2646. -C "parse new session ticket" \
  2647. -s "session successfully restored from cache" \
  2648. -S "session successfully restored from ticket" \
  2649. -s "a session has been resumed" \
  2650. -c "a session has been resumed"
  2651. run_test "Session resume using cache, DTLS: cache_max=0" \
  2652. "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
  2653. "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
  2654. 0 \
  2655. -S "session successfully restored from cache" \
  2656. -S "session successfully restored from ticket" \
  2657. -S "a session has been resumed" \
  2658. -C "a session has been resumed"
  2659. run_test "Session resume using cache, DTLS: cache_max=1" \
  2660. "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
  2661. "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
  2662. 0 \
  2663. -s "session successfully restored from cache" \
  2664. -S "session successfully restored from ticket" \
  2665. -s "a session has been resumed" \
  2666. -c "a session has been resumed"
  2667. run_test "Session resume using cache, DTLS: timeout > delay" \
  2668. "$P_SRV dtls=1 debug_level=3 tickets=0" \
  2669. "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=0" \
  2670. 0 \
  2671. -s "session successfully restored from cache" \
  2672. -S "session successfully restored from ticket" \
  2673. -s "a session has been resumed" \
  2674. -c "a session has been resumed"
  2675. run_test "Session resume using cache, DTLS: timeout < delay" \
  2676. "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
  2677. "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=2" \
  2678. 0 \
  2679. -S "session successfully restored from cache" \
  2680. -S "session successfully restored from ticket" \
  2681. -S "a session has been resumed" \
  2682. -C "a session has been resumed"
  2683. run_test "Session resume using cache, DTLS: no timeout" \
  2684. "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
  2685. "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=2" \
  2686. 0 \
  2687. -s "session successfully restored from cache" \
  2688. -S "session successfully restored from ticket" \
  2689. -s "a session has been resumed" \
  2690. -c "a session has been resumed"
  2691. run_test "Session resume using cache, DTLS: session copy" \
  2692. "$P_SRV dtls=1 debug_level=3 tickets=0" \
  2693. "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_mode=0" \
  2694. 0 \
  2695. -s "session successfully restored from cache" \
  2696. -S "session successfully restored from ticket" \
  2697. -s "a session has been resumed" \
  2698. -c "a session has been resumed"
  2699. run_test "Session resume using cache, DTLS: openssl client" \
  2700. "$P_SRV dtls=1 debug_level=3 tickets=0" \
  2701. "( $O_CLI -dtls1 -sess_out $SESSION; \
  2702. $O_CLI -dtls1 -sess_in $SESSION; \
  2703. rm -f $SESSION )" \
  2704. 0 \
  2705. -s "found session ticket extension" \
  2706. -S "server hello, adding session ticket extension" \
  2707. -s "session successfully restored from cache" \
  2708. -S "session successfully restored from ticket" \
  2709. -s "a session has been resumed"
  2710. run_test "Session resume using cache, DTLS: openssl server" \
  2711. "$O_SRV -dtls1" \
  2712. "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
  2713. 0 \
  2714. -C "found session_ticket extension" \
  2715. -C "parse new session ticket" \
  2716. -c "a session has been resumed"
  2717. # Tests for Max Fragment Length extension
  2718. if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
  2719. printf '%s defines MBEDTLS_SSL_MAX_CONTENT_LEN to be less than 4096. Fragment length tests will fail.\n' "${CONFIG_H}"
  2720. exit 1
  2721. fi
  2722. if [ $MAX_CONTENT_LEN -ne 16384 ]; then
  2723. echo "Using non-default maximum content length $MAX_CONTENT_LEN"
  2724. fi
  2725. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2726. run_test "Max fragment length: enabled, default" \
  2727. "$P_SRV debug_level=3" \
  2728. "$P_CLI debug_level=3" \
  2729. 0 \
  2730. -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
  2731. -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
  2732. -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
  2733. -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
  2734. -C "client hello, adding max_fragment_length extension" \
  2735. -S "found max fragment length extension" \
  2736. -S "server hello, max_fragment_length extension" \
  2737. -C "found max_fragment_length extension"
  2738. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2739. run_test "Max fragment length: enabled, default, larger message" \
  2740. "$P_SRV debug_level=3" \
  2741. "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
  2742. 0 \
  2743. -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
  2744. -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
  2745. -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
  2746. -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
  2747. -C "client hello, adding max_fragment_length extension" \
  2748. -S "found max fragment length extension" \
  2749. -S "server hello, max_fragment_length extension" \
  2750. -C "found max_fragment_length extension" \
  2751. -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
  2752. -s "$MAX_CONTENT_LEN bytes read" \
  2753. -s "1 bytes read"
  2754. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2755. run_test "Max fragment length, DTLS: enabled, default, larger message" \
  2756. "$P_SRV debug_level=3 dtls=1" \
  2757. "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
  2758. 1 \
  2759. -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
  2760. -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
  2761. -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
  2762. -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
  2763. -C "client hello, adding max_fragment_length extension" \
  2764. -S "found max fragment length extension" \
  2765. -S "server hello, max_fragment_length extension" \
  2766. -C "found max_fragment_length extension" \
  2767. -c "fragment larger than.*maximum "
  2768. # Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
  2769. # (session fragment length will be 16384 regardless of mbedtls
  2770. # content length configuration.)
  2771. requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2772. run_test "Max fragment length: disabled, larger message" \
  2773. "$P_SRV debug_level=3" \
  2774. "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
  2775. 0 \
  2776. -C "Maximum input fragment length is 16384" \
  2777. -C "Maximum output fragment length is 16384" \
  2778. -S "Maximum input fragment length is 16384" \
  2779. -S "Maximum output fragment length is 16384" \
  2780. -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
  2781. -s "$MAX_CONTENT_LEN bytes read" \
  2782. -s "1 bytes read"
  2783. requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2784. run_test "Max fragment length DTLS: disabled, larger message" \
  2785. "$P_SRV debug_level=3 dtls=1" \
  2786. "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
  2787. 1 \
  2788. -C "Maximum input fragment length is 16384" \
  2789. -C "Maximum output fragment length is 16384" \
  2790. -S "Maximum input fragment length is 16384" \
  2791. -S "Maximum output fragment length is 16384" \
  2792. -c "fragment larger than.*maximum "
  2793. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2794. run_test "Max fragment length: used by client" \
  2795. "$P_SRV debug_level=3" \
  2796. "$P_CLI debug_level=3 max_frag_len=4096" \
  2797. 0 \
  2798. -c "Maximum input fragment length is 4096" \
  2799. -c "Maximum output fragment length is 4096" \
  2800. -s "Maximum input fragment length is 4096" \
  2801. -s "Maximum output fragment length is 4096" \
  2802. -c "client hello, adding max_fragment_length extension" \
  2803. -s "found max fragment length extension" \
  2804. -s "server hello, max_fragment_length extension" \
  2805. -c "found max_fragment_length extension"
  2806. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2807. run_test "Max fragment length: client 512, server 1024" \
  2808. "$P_SRV debug_level=3 max_frag_len=1024" \
  2809. "$P_CLI debug_level=3 max_frag_len=512" \
  2810. 0 \
  2811. -c "Maximum input fragment length is 512" \
  2812. -c "Maximum output fragment length is 512" \
  2813. -s "Maximum input fragment length is 512" \
  2814. -s "Maximum output fragment length is 512" \
  2815. -c "client hello, adding max_fragment_length extension" \
  2816. -s "found max fragment length extension" \
  2817. -s "server hello, max_fragment_length extension" \
  2818. -c "found max_fragment_length extension"
  2819. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2820. run_test "Max fragment length: client 512, server 2048" \
  2821. "$P_SRV debug_level=3 max_frag_len=2048" \
  2822. "$P_CLI debug_level=3 max_frag_len=512" \
  2823. 0 \
  2824. -c "Maximum input fragment length is 512" \
  2825. -c "Maximum output fragment length is 512" \
  2826. -s "Maximum input fragment length is 512" \
  2827. -s "Maximum output fragment length is 512" \
  2828. -c "client hello, adding max_fragment_length extension" \
  2829. -s "found max fragment length extension" \
  2830. -s "server hello, max_fragment_length extension" \
  2831. -c "found max_fragment_length extension"
  2832. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2833. run_test "Max fragment length: client 512, server 4096" \
  2834. "$P_SRV debug_level=3 max_frag_len=4096" \
  2835. "$P_CLI debug_level=3 max_frag_len=512" \
  2836. 0 \
  2837. -c "Maximum input fragment length is 512" \
  2838. -c "Maximum output fragment length is 512" \
  2839. -s "Maximum input fragment length is 512" \
  2840. -s "Maximum output fragment length is 512" \
  2841. -c "client hello, adding max_fragment_length extension" \
  2842. -s "found max fragment length extension" \
  2843. -s "server hello, max_fragment_length extension" \
  2844. -c "found max_fragment_length extension"
  2845. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2846. run_test "Max fragment length: client 1024, server 512" \
  2847. "$P_SRV debug_level=3 max_frag_len=512" \
  2848. "$P_CLI debug_level=3 max_frag_len=1024" \
  2849. 0 \
  2850. -c "Maximum input fragment length is 1024" \
  2851. -c "Maximum output fragment length is 1024" \
  2852. -s "Maximum input fragment length is 1024" \
  2853. -s "Maximum output fragment length is 512" \
  2854. -c "client hello, adding max_fragment_length extension" \
  2855. -s "found max fragment length extension" \
  2856. -s "server hello, max_fragment_length extension" \
  2857. -c "found max_fragment_length extension"
  2858. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2859. run_test "Max fragment length: client 1024, server 2048" \
  2860. "$P_SRV debug_level=3 max_frag_len=2048" \
  2861. "$P_CLI debug_level=3 max_frag_len=1024" \
  2862. 0 \
  2863. -c "Maximum input fragment length is 1024" \
  2864. -c "Maximum output fragment length is 1024" \
  2865. -s "Maximum input fragment length is 1024" \
  2866. -s "Maximum output fragment length is 1024" \
  2867. -c "client hello, adding max_fragment_length extension" \
  2868. -s "found max fragment length extension" \
  2869. -s "server hello, max_fragment_length extension" \
  2870. -c "found max_fragment_length extension"
  2871. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2872. run_test "Max fragment length: client 1024, server 4096" \
  2873. "$P_SRV debug_level=3 max_frag_len=4096" \
  2874. "$P_CLI debug_level=3 max_frag_len=1024" \
  2875. 0 \
  2876. -c "Maximum input fragment length is 1024" \
  2877. -c "Maximum output fragment length is 1024" \
  2878. -s "Maximum input fragment length is 1024" \
  2879. -s "Maximum output fragment length is 1024" \
  2880. -c "client hello, adding max_fragment_length extension" \
  2881. -s "found max fragment length extension" \
  2882. -s "server hello, max_fragment_length extension" \
  2883. -c "found max_fragment_length extension"
  2884. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2885. run_test "Max fragment length: client 2048, server 512" \
  2886. "$P_SRV debug_level=3 max_frag_len=512" \
  2887. "$P_CLI debug_level=3 max_frag_len=2048" \
  2888. 0 \
  2889. -c "Maximum input fragment length is 2048" \
  2890. -c "Maximum output fragment length is 2048" \
  2891. -s "Maximum input fragment length is 2048" \
  2892. -s "Maximum output fragment length is 512" \
  2893. -c "client hello, adding max_fragment_length extension" \
  2894. -s "found max fragment length extension" \
  2895. -s "server hello, max_fragment_length extension" \
  2896. -c "found max_fragment_length extension"
  2897. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2898. run_test "Max fragment length: client 2048, server 1024" \
  2899. "$P_SRV debug_level=3 max_frag_len=1024" \
  2900. "$P_CLI debug_level=3 max_frag_len=2048" \
  2901. 0 \
  2902. -c "Maximum input fragment length is 2048" \
  2903. -c "Maximum output fragment length is 2048" \
  2904. -s "Maximum input fragment length is 2048" \
  2905. -s "Maximum output fragment length is 1024" \
  2906. -c "client hello, adding max_fragment_length extension" \
  2907. -s "found max fragment length extension" \
  2908. -s "server hello, max_fragment_length extension" \
  2909. -c "found max_fragment_length extension"
  2910. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2911. run_test "Max fragment length: client 2048, server 4096" \
  2912. "$P_SRV debug_level=3 max_frag_len=4096" \
  2913. "$P_CLI debug_level=3 max_frag_len=2048" \
  2914. 0 \
  2915. -c "Maximum input fragment length is 2048" \
  2916. -c "Maximum output fragment length is 2048" \
  2917. -s "Maximum input fragment length is 2048" \
  2918. -s "Maximum output fragment length is 2048" \
  2919. -c "client hello, adding max_fragment_length extension" \
  2920. -s "found max fragment length extension" \
  2921. -s "server hello, max_fragment_length extension" \
  2922. -c "found max_fragment_length extension"
  2923. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2924. run_test "Max fragment length: client 4096, server 512" \
  2925. "$P_SRV debug_level=3 max_frag_len=512" \
  2926. "$P_CLI debug_level=3 max_frag_len=4096" \
  2927. 0 \
  2928. -c "Maximum input fragment length is 4096" \
  2929. -c "Maximum output fragment length is 4096" \
  2930. -s "Maximum input fragment length is 4096" \
  2931. -s "Maximum output fragment length is 512" \
  2932. -c "client hello, adding max_fragment_length extension" \
  2933. -s "found max fragment length extension" \
  2934. -s "server hello, max_fragment_length extension" \
  2935. -c "found max_fragment_length extension"
  2936. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2937. run_test "Max fragment length: client 4096, server 1024" \
  2938. "$P_SRV debug_level=3 max_frag_len=1024" \
  2939. "$P_CLI debug_level=3 max_frag_len=4096" \
  2940. 0 \
  2941. -c "Maximum input fragment length is 4096" \
  2942. -c "Maximum output fragment length is 4096" \
  2943. -s "Maximum input fragment length is 4096" \
  2944. -s "Maximum output fragment length is 1024" \
  2945. -c "client hello, adding max_fragment_length extension" \
  2946. -s "found max fragment length extension" \
  2947. -s "server hello, max_fragment_length extension" \
  2948. -c "found max_fragment_length extension"
  2949. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2950. run_test "Max fragment length: client 4096, server 2048" \
  2951. "$P_SRV debug_level=3 max_frag_len=2048" \
  2952. "$P_CLI debug_level=3 max_frag_len=4096" \
  2953. 0 \
  2954. -c "Maximum input fragment length is 4096" \
  2955. -c "Maximum output fragment length is 4096" \
  2956. -s "Maximum input fragment length is 4096" \
  2957. -s "Maximum output fragment length is 2048" \
  2958. -c "client hello, adding max_fragment_length extension" \
  2959. -s "found max fragment length extension" \
  2960. -s "server hello, max_fragment_length extension" \
  2961. -c "found max_fragment_length extension"
  2962. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2963. run_test "Max fragment length: used by server" \
  2964. "$P_SRV debug_level=3 max_frag_len=4096" \
  2965. "$P_CLI debug_level=3" \
  2966. 0 \
  2967. -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
  2968. -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
  2969. -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
  2970. -s "Maximum output fragment length is 4096" \
  2971. -C "client hello, adding max_fragment_length extension" \
  2972. -S "found max fragment length extension" \
  2973. -S "server hello, max_fragment_length extension" \
  2974. -C "found max_fragment_length extension"
  2975. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2976. requires_gnutls
  2977. run_test "Max fragment length: gnutls server" \
  2978. "$G_SRV" \
  2979. "$P_CLI debug_level=3 max_frag_len=4096" \
  2980. 0 \
  2981. -c "Maximum input fragment length is 4096" \
  2982. -c "Maximum output fragment length is 4096" \
  2983. -c "client hello, adding max_fragment_length extension" \
  2984. -c "found max_fragment_length extension"
  2985. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  2986. run_test "Max fragment length: client, message just fits" \
  2987. "$P_SRV debug_level=3" \
  2988. "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
  2989. 0 \
  2990. -c "Maximum input fragment length is 2048" \
  2991. -c "Maximum output fragment length is 2048" \
  2992. -s "Maximum input fragment length is 2048" \
  2993. -s "Maximum output fragment length is 2048" \
  2994. -c "client hello, adding max_fragment_length extension" \
  2995. -s "found max fragment length extension" \
  2996. -s "server hello, max_fragment_length extension" \
  2997. -c "found max_fragment_length extension" \
  2998. -c "2048 bytes written in 1 fragments" \
  2999. -s "2048 bytes read"
  3000. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  3001. run_test "Max fragment length: client, larger message" \
  3002. "$P_SRV debug_level=3" \
  3003. "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
  3004. 0 \
  3005. -c "Maximum input fragment length is 2048" \
  3006. -c "Maximum output fragment length is 2048" \
  3007. -s "Maximum input fragment length is 2048" \
  3008. -s "Maximum output fragment length is 2048" \
  3009. -c "client hello, adding max_fragment_length extension" \
  3010. -s "found max fragment length extension" \
  3011. -s "server hello, max_fragment_length extension" \
  3012. -c "found max_fragment_length extension" \
  3013. -c "2345 bytes written in 2 fragments" \
  3014. -s "2048 bytes read" \
  3015. -s "297 bytes read"
  3016. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  3017. run_test "Max fragment length: DTLS client, larger message" \
  3018. "$P_SRV debug_level=3 dtls=1" \
  3019. "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
  3020. 1 \
  3021. -c "Maximum input fragment length is 2048" \
  3022. -c "Maximum output fragment length is 2048" \
  3023. -s "Maximum input fragment length is 2048" \
  3024. -s "Maximum output fragment length is 2048" \
  3025. -c "client hello, adding max_fragment_length extension" \
  3026. -s "found max fragment length extension" \
  3027. -s "server hello, max_fragment_length extension" \
  3028. -c "found max_fragment_length extension" \
  3029. -c "fragment larger than.*maximum"
  3030. # Tests for renegotiation
  3031. # Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
  3032. run_test "Renegotiation: none, for reference" \
  3033. "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
  3034. "$P_CLI debug_level=3 exchanges=2" \
  3035. 0 \
  3036. -C "client hello, adding renegotiation extension" \
  3037. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3038. -S "found renegotiation extension" \
  3039. -s "server hello, secure renegotiation extension" \
  3040. -c "found renegotiation extension" \
  3041. -C "=> renegotiate" \
  3042. -S "=> renegotiate" \
  3043. -S "write hello request"
  3044. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3045. run_test "Renegotiation: client-initiated" \
  3046. "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
  3047. "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
  3048. 0 \
  3049. -c "client hello, adding renegotiation extension" \
  3050. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3051. -s "found renegotiation extension" \
  3052. -s "server hello, secure renegotiation extension" \
  3053. -c "found renegotiation extension" \
  3054. -c "=> renegotiate" \
  3055. -s "=> renegotiate" \
  3056. -S "write hello request"
  3057. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3058. run_test "Renegotiation: server-initiated" \
  3059. "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
  3060. "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
  3061. 0 \
  3062. -c "client hello, adding renegotiation extension" \
  3063. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3064. -s "found renegotiation extension" \
  3065. -s "server hello, secure renegotiation extension" \
  3066. -c "found renegotiation extension" \
  3067. -c "=> renegotiate" \
  3068. -s "=> renegotiate" \
  3069. -s "write hello request"
  3070. # Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
  3071. # the server did not parse the Signature Algorithm extension. This test is valid only if an MD
  3072. # algorithm stronger than SHA-1 is enabled in config.h
  3073. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3074. run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
  3075. "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
  3076. "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
  3077. 0 \
  3078. -c "client hello, adding renegotiation extension" \
  3079. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3080. -s "found renegotiation extension" \
  3081. -s "server hello, secure renegotiation extension" \
  3082. -c "found renegotiation extension" \
  3083. -c "=> renegotiate" \
  3084. -s "=> renegotiate" \
  3085. -S "write hello request" \
  3086. -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
  3087. # Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
  3088. # the server did not parse the Signature Algorithm extension. This test is valid only if an MD
  3089. # algorithm stronger than SHA-1 is enabled in config.h
  3090. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3091. run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
  3092. "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
  3093. "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
  3094. 0 \
  3095. -c "client hello, adding renegotiation extension" \
  3096. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3097. -s "found renegotiation extension" \
  3098. -s "server hello, secure renegotiation extension" \
  3099. -c "found renegotiation extension" \
  3100. -c "=> renegotiate" \
  3101. -s "=> renegotiate" \
  3102. -s "write hello request" \
  3103. -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
  3104. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3105. run_test "Renegotiation: double" \
  3106. "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
  3107. "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
  3108. 0 \
  3109. -c "client hello, adding renegotiation extension" \
  3110. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3111. -s "found renegotiation extension" \
  3112. -s "server hello, secure renegotiation extension" \
  3113. -c "found renegotiation extension" \
  3114. -c "=> renegotiate" \
  3115. -s "=> renegotiate" \
  3116. -s "write hello request"
  3117. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3118. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  3119. run_test "Renegotiation with max fragment length: client 2048, server 512" \
  3120. "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1 max_frag_len=512" \
  3121. "$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" \
  3122. 0 \
  3123. -c "Maximum input fragment length is 2048" \
  3124. -c "Maximum output fragment length is 2048" \
  3125. -s "Maximum input fragment length is 2048" \
  3126. -s "Maximum output fragment length is 512" \
  3127. -c "client hello, adding max_fragment_length extension" \
  3128. -s "found max fragment length extension" \
  3129. -s "server hello, max_fragment_length extension" \
  3130. -c "found max_fragment_length extension" \
  3131. -c "client hello, adding renegotiation extension" \
  3132. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3133. -s "found renegotiation extension" \
  3134. -s "server hello, secure renegotiation extension" \
  3135. -c "found renegotiation extension" \
  3136. -c "=> renegotiate" \
  3137. -s "=> renegotiate" \
  3138. -s "write hello request"
  3139. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3140. run_test "Renegotiation: client-initiated, server-rejected" \
  3141. "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
  3142. "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
  3143. 1 \
  3144. -c "client hello, adding renegotiation extension" \
  3145. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3146. -S "found renegotiation extension" \
  3147. -s "server hello, secure renegotiation extension" \
  3148. -c "found renegotiation extension" \
  3149. -c "=> renegotiate" \
  3150. -S "=> renegotiate" \
  3151. -S "write hello request" \
  3152. -c "SSL - Unexpected message at ServerHello in renegotiation" \
  3153. -c "failed"
  3154. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3155. run_test "Renegotiation: server-initiated, client-rejected, default" \
  3156. "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
  3157. "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
  3158. 0 \
  3159. -C "client hello, adding renegotiation extension" \
  3160. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3161. -S "found renegotiation extension" \
  3162. -s "server hello, secure renegotiation extension" \
  3163. -c "found renegotiation extension" \
  3164. -C "=> renegotiate" \
  3165. -S "=> renegotiate" \
  3166. -s "write hello request" \
  3167. -S "SSL - An unexpected message was received from our peer" \
  3168. -S "failed"
  3169. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3170. run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
  3171. "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
  3172. renego_delay=-1 auth_mode=optional" \
  3173. "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
  3174. 0 \
  3175. -C "client hello, adding renegotiation extension" \
  3176. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3177. -S "found renegotiation extension" \
  3178. -s "server hello, secure renegotiation extension" \
  3179. -c "found renegotiation extension" \
  3180. -C "=> renegotiate" \
  3181. -S "=> renegotiate" \
  3182. -s "write hello request" \
  3183. -S "SSL - An unexpected message was received from our peer" \
  3184. -S "failed"
  3185. # delay 2 for 1 alert record + 1 application data record
  3186. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3187. run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
  3188. "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
  3189. renego_delay=2 auth_mode=optional" \
  3190. "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
  3191. 0 \
  3192. -C "client hello, adding renegotiation extension" \
  3193. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3194. -S "found renegotiation extension" \
  3195. -s "server hello, secure renegotiation extension" \
  3196. -c "found renegotiation extension" \
  3197. -C "=> renegotiate" \
  3198. -S "=> renegotiate" \
  3199. -s "write hello request" \
  3200. -S "SSL - An unexpected message was received from our peer" \
  3201. -S "failed"
  3202. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3203. run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
  3204. "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
  3205. renego_delay=0 auth_mode=optional" \
  3206. "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
  3207. 0 \
  3208. -C "client hello, adding renegotiation extension" \
  3209. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3210. -S "found renegotiation extension" \
  3211. -s "server hello, secure renegotiation extension" \
  3212. -c "found renegotiation extension" \
  3213. -C "=> renegotiate" \
  3214. -S "=> renegotiate" \
  3215. -s "write hello request" \
  3216. -s "SSL - An unexpected message was received from our peer"
  3217. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3218. run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
  3219. "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
  3220. renego_delay=0 auth_mode=optional" \
  3221. "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
  3222. 0 \
  3223. -c "client hello, adding renegotiation extension" \
  3224. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3225. -s "found renegotiation extension" \
  3226. -s "server hello, secure renegotiation extension" \
  3227. -c "found renegotiation extension" \
  3228. -c "=> renegotiate" \
  3229. -s "=> renegotiate" \
  3230. -s "write hello request" \
  3231. -S "SSL - An unexpected message was received from our peer" \
  3232. -S "failed"
  3233. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3234. run_test "Renegotiation: periodic, just below period" \
  3235. "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
  3236. "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
  3237. 0 \
  3238. -C "client hello, adding renegotiation extension" \
  3239. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3240. -S "found renegotiation extension" \
  3241. -s "server hello, secure renegotiation extension" \
  3242. -c "found renegotiation extension" \
  3243. -S "record counter limit reached: renegotiate" \
  3244. -C "=> renegotiate" \
  3245. -S "=> renegotiate" \
  3246. -S "write hello request" \
  3247. -S "SSL - An unexpected message was received from our peer" \
  3248. -S "failed"
  3249. # one extra exchange to be able to complete renego
  3250. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3251. run_test "Renegotiation: periodic, just above period" \
  3252. "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
  3253. "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
  3254. 0 \
  3255. -c "client hello, adding renegotiation extension" \
  3256. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3257. -s "found renegotiation extension" \
  3258. -s "server hello, secure renegotiation extension" \
  3259. -c "found renegotiation extension" \
  3260. -s "record counter limit reached: renegotiate" \
  3261. -c "=> renegotiate" \
  3262. -s "=> renegotiate" \
  3263. -s "write hello request" \
  3264. -S "SSL - An unexpected message was received from our peer" \
  3265. -S "failed"
  3266. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3267. run_test "Renegotiation: periodic, two times period" \
  3268. "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
  3269. "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
  3270. 0 \
  3271. -c "client hello, adding renegotiation extension" \
  3272. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3273. -s "found renegotiation extension" \
  3274. -s "server hello, secure renegotiation extension" \
  3275. -c "found renegotiation extension" \
  3276. -s "record counter limit reached: renegotiate" \
  3277. -c "=> renegotiate" \
  3278. -s "=> renegotiate" \
  3279. -s "write hello request" \
  3280. -S "SSL - An unexpected message was received from our peer" \
  3281. -S "failed"
  3282. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3283. run_test "Renegotiation: periodic, above period, disabled" \
  3284. "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
  3285. "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
  3286. 0 \
  3287. -C "client hello, adding renegotiation extension" \
  3288. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3289. -S "found renegotiation extension" \
  3290. -s "server hello, secure renegotiation extension" \
  3291. -c "found renegotiation extension" \
  3292. -S "record counter limit reached: renegotiate" \
  3293. -C "=> renegotiate" \
  3294. -S "=> renegotiate" \
  3295. -S "write hello request" \
  3296. -S "SSL - An unexpected message was received from our peer" \
  3297. -S "failed"
  3298. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3299. run_test "Renegotiation: nbio, client-initiated" \
  3300. "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
  3301. "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
  3302. 0 \
  3303. -c "client hello, adding renegotiation extension" \
  3304. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3305. -s "found renegotiation extension" \
  3306. -s "server hello, secure renegotiation extension" \
  3307. -c "found renegotiation extension" \
  3308. -c "=> renegotiate" \
  3309. -s "=> renegotiate" \
  3310. -S "write hello request"
  3311. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3312. run_test "Renegotiation: nbio, server-initiated" \
  3313. "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
  3314. "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
  3315. 0 \
  3316. -c "client hello, adding renegotiation extension" \
  3317. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3318. -s "found renegotiation extension" \
  3319. -s "server hello, secure renegotiation extension" \
  3320. -c "found renegotiation extension" \
  3321. -c "=> renegotiate" \
  3322. -s "=> renegotiate" \
  3323. -s "write hello request"
  3324. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3325. run_test "Renegotiation: openssl server, client-initiated" \
  3326. "$O_SRV -www" \
  3327. "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
  3328. 0 \
  3329. -c "client hello, adding renegotiation extension" \
  3330. -c "found renegotiation extension" \
  3331. -c "=> renegotiate" \
  3332. -C "ssl_hanshake() returned" \
  3333. -C "error" \
  3334. -c "HTTP/1.0 200 [Oo][Kk]"
  3335. requires_gnutls
  3336. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3337. run_test "Renegotiation: gnutls server strict, client-initiated" \
  3338. "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
  3339. "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
  3340. 0 \
  3341. -c "client hello, adding renegotiation extension" \
  3342. -c "found renegotiation extension" \
  3343. -c "=> renegotiate" \
  3344. -C "ssl_hanshake() returned" \
  3345. -C "error" \
  3346. -c "HTTP/1.0 200 [Oo][Kk]"
  3347. requires_gnutls
  3348. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3349. run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
  3350. "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
  3351. "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
  3352. 1 \
  3353. -c "client hello, adding renegotiation extension" \
  3354. -C "found renegotiation extension" \
  3355. -c "=> renegotiate" \
  3356. -c "mbedtls_ssl_handshake() returned" \
  3357. -c "error" \
  3358. -C "HTTP/1.0 200 [Oo][Kk]"
  3359. requires_gnutls
  3360. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3361. run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
  3362. "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
  3363. "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
  3364. allow_legacy=0" \
  3365. 1 \
  3366. -c "client hello, adding renegotiation extension" \
  3367. -C "found renegotiation extension" \
  3368. -c "=> renegotiate" \
  3369. -c "mbedtls_ssl_handshake() returned" \
  3370. -c "error" \
  3371. -C "HTTP/1.0 200 [Oo][Kk]"
  3372. requires_gnutls
  3373. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3374. run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
  3375. "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
  3376. "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
  3377. allow_legacy=1" \
  3378. 0 \
  3379. -c "client hello, adding renegotiation extension" \
  3380. -C "found renegotiation extension" \
  3381. -c "=> renegotiate" \
  3382. -C "ssl_hanshake() returned" \
  3383. -C "error" \
  3384. -c "HTTP/1.0 200 [Oo][Kk]"
  3385. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3386. run_test "Renegotiation: DTLS, client-initiated" \
  3387. "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
  3388. "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
  3389. 0 \
  3390. -c "client hello, adding renegotiation extension" \
  3391. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3392. -s "found renegotiation extension" \
  3393. -s "server hello, secure renegotiation extension" \
  3394. -c "found renegotiation extension" \
  3395. -c "=> renegotiate" \
  3396. -s "=> renegotiate" \
  3397. -S "write hello request"
  3398. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3399. run_test "Renegotiation: DTLS, server-initiated" \
  3400. "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
  3401. "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
  3402. read_timeout=1000 max_resend=2" \
  3403. 0 \
  3404. -c "client hello, adding renegotiation extension" \
  3405. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3406. -s "found renegotiation extension" \
  3407. -s "server hello, secure renegotiation extension" \
  3408. -c "found renegotiation extension" \
  3409. -c "=> renegotiate" \
  3410. -s "=> renegotiate" \
  3411. -s "write hello request"
  3412. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3413. run_test "Renegotiation: DTLS, renego_period overflow" \
  3414. "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
  3415. "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
  3416. 0 \
  3417. -c "client hello, adding renegotiation extension" \
  3418. -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
  3419. -s "found renegotiation extension" \
  3420. -s "server hello, secure renegotiation extension" \
  3421. -s "record counter limit reached: renegotiate" \
  3422. -c "=> renegotiate" \
  3423. -s "=> renegotiate" \
  3424. -s "write hello request"
  3425. requires_gnutls
  3426. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  3427. run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
  3428. "$G_SRV -u --mtu 4096" \
  3429. "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
  3430. 0 \
  3431. -c "client hello, adding renegotiation extension" \
  3432. -c "found renegotiation extension" \
  3433. -c "=> renegotiate" \
  3434. -C "mbedtls_ssl_handshake returned" \
  3435. -C "error" \
  3436. -s "Extra-header:"
  3437. # Test for the "secure renegotation" extension only (no actual renegotiation)
  3438. requires_gnutls
  3439. run_test "Renego ext: gnutls server strict, client default" \
  3440. "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
  3441. "$P_CLI debug_level=3" \
  3442. 0 \
  3443. -c "found renegotiation extension" \
  3444. -C "error" \
  3445. -c "HTTP/1.0 200 [Oo][Kk]"
  3446. requires_gnutls
  3447. run_test "Renego ext: gnutls server unsafe, client default" \
  3448. "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
  3449. "$P_CLI debug_level=3" \
  3450. 0 \
  3451. -C "found renegotiation extension" \
  3452. -C "error" \
  3453. -c "HTTP/1.0 200 [Oo][Kk]"
  3454. requires_gnutls
  3455. run_test "Renego ext: gnutls server unsafe, client break legacy" \
  3456. "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
  3457. "$P_CLI debug_level=3 allow_legacy=-1" \
  3458. 1 \
  3459. -C "found renegotiation extension" \
  3460. -c "error" \
  3461. -C "HTTP/1.0 200 [Oo][Kk]"
  3462. requires_gnutls
  3463. run_test "Renego ext: gnutls client strict, server default" \
  3464. "$P_SRV debug_level=3" \
  3465. "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
  3466. 0 \
  3467. -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
  3468. -s "server hello, secure renegotiation extension"
  3469. requires_gnutls
  3470. run_test "Renego ext: gnutls client unsafe, server default" \
  3471. "$P_SRV debug_level=3" \
  3472. "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
  3473. 0 \
  3474. -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
  3475. -S "server hello, secure renegotiation extension"
  3476. requires_gnutls
  3477. run_test "Renego ext: gnutls client unsafe, server break legacy" \
  3478. "$P_SRV debug_level=3 allow_legacy=-1" \
  3479. "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
  3480. 1 \
  3481. -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
  3482. -S "server hello, secure renegotiation extension"
  3483. # Tests for silently dropping trailing extra bytes in .der certificates
  3484. requires_gnutls
  3485. run_test "DER format: no trailing bytes" \
  3486. "$P_SRV crt_file=data_files/server5-der0.crt \
  3487. key_file=data_files/server5.key" \
  3488. "$G_CLI localhost" \
  3489. 0 \
  3490. -c "Handshake was completed" \
  3491. requires_gnutls
  3492. run_test "DER format: with a trailing zero byte" \
  3493. "$P_SRV crt_file=data_files/server5-der1a.crt \
  3494. key_file=data_files/server5.key" \
  3495. "$G_CLI localhost" \
  3496. 0 \
  3497. -c "Handshake was completed" \
  3498. requires_gnutls
  3499. run_test "DER format: with a trailing random byte" \
  3500. "$P_SRV crt_file=data_files/server5-der1b.crt \
  3501. key_file=data_files/server5.key" \
  3502. "$G_CLI localhost" \
  3503. 0 \
  3504. -c "Handshake was completed" \
  3505. requires_gnutls
  3506. run_test "DER format: with 2 trailing random bytes" \
  3507. "$P_SRV crt_file=data_files/server5-der2.crt \
  3508. key_file=data_files/server5.key" \
  3509. "$G_CLI localhost" \
  3510. 0 \
  3511. -c "Handshake was completed" \
  3512. requires_gnutls
  3513. run_test "DER format: with 4 trailing random bytes" \
  3514. "$P_SRV crt_file=data_files/server5-der4.crt \
  3515. key_file=data_files/server5.key" \
  3516. "$G_CLI localhost" \
  3517. 0 \
  3518. -c "Handshake was completed" \
  3519. requires_gnutls
  3520. run_test "DER format: with 8 trailing random bytes" \
  3521. "$P_SRV crt_file=data_files/server5-der8.crt \
  3522. key_file=data_files/server5.key" \
  3523. "$G_CLI localhost" \
  3524. 0 \
  3525. -c "Handshake was completed" \
  3526. requires_gnutls
  3527. run_test "DER format: with 9 trailing random bytes" \
  3528. "$P_SRV crt_file=data_files/server5-der9.crt \
  3529. key_file=data_files/server5.key" \
  3530. "$G_CLI localhost" \
  3531. 0 \
  3532. -c "Handshake was completed" \
  3533. # Tests for auth_mode, there are duplicated tests using ca callback for authentication
  3534. # When updating these tests, modify the matching authentication tests accordingly
  3535. run_test "Authentication: server badcert, client required" \
  3536. "$P_SRV crt_file=data_files/server5-badsign.crt \
  3537. key_file=data_files/server5.key" \
  3538. "$P_CLI debug_level=1 auth_mode=required" \
  3539. 1 \
  3540. -c "x509_verify_cert() returned" \
  3541. -c "! The certificate is not correctly signed by the trusted CA" \
  3542. -c "! mbedtls_ssl_handshake returned" \
  3543. -c "X509 - Certificate verification failed"
  3544. run_test "Authentication: server badcert, client optional" \
  3545. "$P_SRV crt_file=data_files/server5-badsign.crt \
  3546. key_file=data_files/server5.key" \
  3547. "$P_CLI debug_level=1 auth_mode=optional" \
  3548. 0 \
  3549. -c "x509_verify_cert() returned" \
  3550. -c "! The certificate is not correctly signed by the trusted CA" \
  3551. -C "! mbedtls_ssl_handshake returned" \
  3552. -C "X509 - Certificate verification failed"
  3553. run_test "Authentication: server goodcert, client optional, no trusted CA" \
  3554. "$P_SRV" \
  3555. "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
  3556. 0 \
  3557. -c "x509_verify_cert() returned" \
  3558. -c "! The certificate is not correctly signed by the trusted CA" \
  3559. -c "! Certificate verification flags"\
  3560. -C "! mbedtls_ssl_handshake returned" \
  3561. -C "X509 - Certificate verification failed" \
  3562. -C "SSL - No CA Chain is set, but required to operate"
  3563. run_test "Authentication: server goodcert, client required, no trusted CA" \
  3564. "$P_SRV" \
  3565. "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
  3566. 1 \
  3567. -c "x509_verify_cert() returned" \
  3568. -c "! The certificate is not correctly signed by the trusted CA" \
  3569. -c "! Certificate verification flags"\
  3570. -c "! mbedtls_ssl_handshake returned" \
  3571. -c "SSL - No CA Chain is set, but required to operate"
  3572. # The purpose of the next two tests is to test the client's behaviour when receiving a server
  3573. # certificate with an unsupported elliptic curve. This should usually not happen because
  3574. # the client informs the server about the supported curves - it does, though, in the
  3575. # corner case of a static ECDH suite, because the server doesn't check the curve on that
  3576. # occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
  3577. # different means to have the server ignoring the client's supported curve list.
  3578. requires_config_enabled MBEDTLS_ECP_C
  3579. run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
  3580. "$P_SRV debug_level=1 key_file=data_files/server5.key \
  3581. crt_file=data_files/server5.ku-ka.crt" \
  3582. "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
  3583. 1 \
  3584. -c "bad certificate (EC key curve)"\
  3585. -c "! Certificate verification flags"\
  3586. -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
  3587. requires_config_enabled MBEDTLS_ECP_C
  3588. run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
  3589. "$P_SRV debug_level=1 key_file=data_files/server5.key \
  3590. crt_file=data_files/server5.ku-ka.crt" \
  3591. "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
  3592. 1 \
  3593. -c "bad certificate (EC key curve)"\
  3594. -c "! Certificate verification flags"\
  3595. -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
  3596. run_test "Authentication: server badcert, client none" \
  3597. "$P_SRV crt_file=data_files/server5-badsign.crt \
  3598. key_file=data_files/server5.key" \
  3599. "$P_CLI debug_level=1 auth_mode=none" \
  3600. 0 \
  3601. -C "x509_verify_cert() returned" \
  3602. -C "! The certificate is not correctly signed by the trusted CA" \
  3603. -C "! mbedtls_ssl_handshake returned" \
  3604. -C "X509 - Certificate verification failed"
  3605. run_test "Authentication: client SHA256, server required" \
  3606. "$P_SRV auth_mode=required" \
  3607. "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
  3608. key_file=data_files/server6.key \
  3609. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
  3610. 0 \
  3611. -c "Supported Signature Algorithm found: 4," \
  3612. -c "Supported Signature Algorithm found: 5,"
  3613. run_test "Authentication: client SHA384, server required" \
  3614. "$P_SRV auth_mode=required" \
  3615. "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
  3616. key_file=data_files/server6.key \
  3617. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
  3618. 0 \
  3619. -c "Supported Signature Algorithm found: 4," \
  3620. -c "Supported Signature Algorithm found: 5,"
  3621. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  3622. run_test "Authentication: client has no cert, server required (SSLv3)" \
  3623. "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
  3624. "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
  3625. key_file=data_files/server5.key" \
  3626. 1 \
  3627. -S "skip write certificate request" \
  3628. -C "skip parse certificate request" \
  3629. -c "got a certificate request" \
  3630. -c "got no certificate to send" \
  3631. -S "x509_verify_cert() returned" \
  3632. -s "client has no certificate" \
  3633. -s "! mbedtls_ssl_handshake returned" \
  3634. -c "! mbedtls_ssl_handshake returned" \
  3635. -s "No client certification received from the client, but required by the authentication mode"
  3636. run_test "Authentication: client has no cert, server required (TLS)" \
  3637. "$P_SRV debug_level=3 auth_mode=required" \
  3638. "$P_CLI debug_level=3 crt_file=none \
  3639. key_file=data_files/server5.key" \
  3640. 1 \
  3641. -S "skip write certificate request" \
  3642. -C "skip parse certificate request" \
  3643. -c "got a certificate request" \
  3644. -c "= write certificate$" \
  3645. -C "skip write certificate$" \
  3646. -S "x509_verify_cert() returned" \
  3647. -s "client has no certificate" \
  3648. -s "! mbedtls_ssl_handshake returned" \
  3649. -c "! mbedtls_ssl_handshake returned" \
  3650. -s "No client certification received from the client, but required by the authentication mode"
  3651. run_test "Authentication: client badcert, server required" \
  3652. "$P_SRV debug_level=3 auth_mode=required" \
  3653. "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
  3654. key_file=data_files/server5.key" \
  3655. 1 \
  3656. -S "skip write certificate request" \
  3657. -C "skip parse certificate request" \
  3658. -c "got a certificate request" \
  3659. -C "skip write certificate" \
  3660. -C "skip write certificate verify" \
  3661. -S "skip parse certificate verify" \
  3662. -s "x509_verify_cert() returned" \
  3663. -s "! The certificate is not correctly signed by the trusted CA" \
  3664. -s "! mbedtls_ssl_handshake returned" \
  3665. -s "send alert level=2 message=48" \
  3666. -c "! mbedtls_ssl_handshake returned" \
  3667. -s "X509 - Certificate verification failed"
  3668. # We don't check that the client receives the alert because it might
  3669. # detect that its write end of the connection is closed and abort
  3670. # before reading the alert message.
  3671. run_test "Authentication: client cert not trusted, server required" \
  3672. "$P_SRV debug_level=3 auth_mode=required" \
  3673. "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
  3674. key_file=data_files/server5.key" \
  3675. 1 \
  3676. -S "skip write certificate request" \
  3677. -C "skip parse certificate request" \
  3678. -c "got a certificate request" \
  3679. -C "skip write certificate" \
  3680. -C "skip write certificate verify" \
  3681. -S "skip parse certificate verify" \
  3682. -s "x509_verify_cert() returned" \
  3683. -s "! The certificate is not correctly signed by the trusted CA" \
  3684. -s "! mbedtls_ssl_handshake returned" \
  3685. -c "! mbedtls_ssl_handshake returned" \
  3686. -s "X509 - Certificate verification failed"
  3687. run_test "Authentication: client badcert, server optional" \
  3688. "$P_SRV debug_level=3 auth_mode=optional" \
  3689. "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
  3690. key_file=data_files/server5.key" \
  3691. 0 \
  3692. -S "skip write certificate request" \
  3693. -C "skip parse certificate request" \
  3694. -c "got a certificate request" \
  3695. -C "skip write certificate" \
  3696. -C "skip write certificate verify" \
  3697. -S "skip parse certificate verify" \
  3698. -s "x509_verify_cert() returned" \
  3699. -s "! The certificate is not correctly signed by the trusted CA" \
  3700. -S "! mbedtls_ssl_handshake returned" \
  3701. -C "! mbedtls_ssl_handshake returned" \
  3702. -S "X509 - Certificate verification failed"
  3703. run_test "Authentication: client badcert, server none" \
  3704. "$P_SRV debug_level=3 auth_mode=none" \
  3705. "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
  3706. key_file=data_files/server5.key" \
  3707. 0 \
  3708. -s "skip write certificate request" \
  3709. -C "skip parse certificate request" \
  3710. -c "got no certificate request" \
  3711. -c "skip write certificate" \
  3712. -c "skip write certificate verify" \
  3713. -s "skip parse certificate verify" \
  3714. -S "x509_verify_cert() returned" \
  3715. -S "! The certificate is not correctly signed by the trusted CA" \
  3716. -S "! mbedtls_ssl_handshake returned" \
  3717. -C "! mbedtls_ssl_handshake returned" \
  3718. -S "X509 - Certificate verification failed"
  3719. run_test "Authentication: client no cert, server optional" \
  3720. "$P_SRV debug_level=3 auth_mode=optional" \
  3721. "$P_CLI debug_level=3 crt_file=none key_file=none" \
  3722. 0 \
  3723. -S "skip write certificate request" \
  3724. -C "skip parse certificate request" \
  3725. -c "got a certificate request" \
  3726. -C "skip write certificate$" \
  3727. -C "got no certificate to send" \
  3728. -S "SSLv3 client has no certificate" \
  3729. -c "skip write certificate verify" \
  3730. -s "skip parse certificate verify" \
  3731. -s "! Certificate was missing" \
  3732. -S "! mbedtls_ssl_handshake returned" \
  3733. -C "! mbedtls_ssl_handshake returned" \
  3734. -S "X509 - Certificate verification failed"
  3735. run_test "Authentication: openssl client no cert, server optional" \
  3736. "$P_SRV debug_level=3 auth_mode=optional" \
  3737. "$O_CLI" \
  3738. 0 \
  3739. -S "skip write certificate request" \
  3740. -s "skip parse certificate verify" \
  3741. -s "! Certificate was missing" \
  3742. -S "! mbedtls_ssl_handshake returned" \
  3743. -S "X509 - Certificate verification failed"
  3744. run_test "Authentication: client no cert, openssl server optional" \
  3745. "$O_SRV -verify 10" \
  3746. "$P_CLI debug_level=3 crt_file=none key_file=none" \
  3747. 0 \
  3748. -C "skip parse certificate request" \
  3749. -c "got a certificate request" \
  3750. -C "skip write certificate$" \
  3751. -c "skip write certificate verify" \
  3752. -C "! mbedtls_ssl_handshake returned"
  3753. run_test "Authentication: client no cert, openssl server required" \
  3754. "$O_SRV -Verify 10" \
  3755. "$P_CLI debug_level=3 crt_file=none key_file=none" \
  3756. 1 \
  3757. -C "skip parse certificate request" \
  3758. -c "got a certificate request" \
  3759. -C "skip write certificate$" \
  3760. -c "skip write certificate verify" \
  3761. -c "! mbedtls_ssl_handshake returned"
  3762. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  3763. run_test "Authentication: client no cert, ssl3" \
  3764. "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
  3765. "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
  3766. 0 \
  3767. -S "skip write certificate request" \
  3768. -C "skip parse certificate request" \
  3769. -c "got a certificate request" \
  3770. -C "skip write certificate$" \
  3771. -c "skip write certificate verify" \
  3772. -c "got no certificate to send" \
  3773. -s "SSLv3 client has no certificate" \
  3774. -s "skip parse certificate verify" \
  3775. -s "! Certificate was missing" \
  3776. -S "! mbedtls_ssl_handshake returned" \
  3777. -C "! mbedtls_ssl_handshake returned" \
  3778. -S "X509 - Certificate verification failed"
  3779. # The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
  3780. # default value (8)
  3781. MAX_IM_CA='8'
  3782. MAX_IM_CA_CONFIG=$( ../scripts/config.py get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
  3783. if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
  3784. cat <<EOF
  3785. ${CONFIG_H} contains a value for the configuration of
  3786. MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script's
  3787. test value of ${MAX_IM_CA}.
  3788. The tests assume this value and if it changes, the tests in this
  3789. script should also be adjusted.
  3790. EOF
  3791. exit 1
  3792. fi
  3793. requires_full_size_output_buffer
  3794. run_test "Authentication: server max_int chain, client default" \
  3795. "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
  3796. key_file=data_files/dir-maxpath/09.key" \
  3797. "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
  3798. 0 \
  3799. -C "X509 - A fatal error occurred"
  3800. requires_full_size_output_buffer
  3801. run_test "Authentication: server max_int+1 chain, client default" \
  3802. "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
  3803. key_file=data_files/dir-maxpath/10.key" \
  3804. "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
  3805. 1 \
  3806. -c "X509 - A fatal error occurred"
  3807. requires_full_size_output_buffer
  3808. run_test "Authentication: server max_int+1 chain, client optional" \
  3809. "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
  3810. key_file=data_files/dir-maxpath/10.key" \
  3811. "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
  3812. auth_mode=optional" \
  3813. 1 \
  3814. -c "X509 - A fatal error occurred"
  3815. requires_full_size_output_buffer
  3816. run_test "Authentication: server max_int+1 chain, client none" \
  3817. "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
  3818. key_file=data_files/dir-maxpath/10.key" \
  3819. "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
  3820. auth_mode=none" \
  3821. 0 \
  3822. -C "X509 - A fatal error occurred"
  3823. requires_full_size_output_buffer
  3824. run_test "Authentication: client max_int+1 chain, server default" \
  3825. "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
  3826. "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
  3827. key_file=data_files/dir-maxpath/10.key" \
  3828. 0 \
  3829. -S "X509 - A fatal error occurred"
  3830. requires_full_size_output_buffer
  3831. run_test "Authentication: client max_int+1 chain, server optional" \
  3832. "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
  3833. "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
  3834. key_file=data_files/dir-maxpath/10.key" \
  3835. 1 \
  3836. -s "X509 - A fatal error occurred"
  3837. requires_full_size_output_buffer
  3838. run_test "Authentication: client max_int+1 chain, server required" \
  3839. "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
  3840. "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
  3841. key_file=data_files/dir-maxpath/10.key" \
  3842. 1 \
  3843. -s "X509 - A fatal error occurred"
  3844. requires_full_size_output_buffer
  3845. run_test "Authentication: client max_int chain, server required" \
  3846. "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
  3847. "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
  3848. key_file=data_files/dir-maxpath/09.key" \
  3849. 0 \
  3850. -S "X509 - A fatal error occurred"
  3851. # Tests for CA list in CertificateRequest messages
  3852. run_test "Authentication: send CA list in CertificateRequest (default)" \
  3853. "$P_SRV debug_level=3 auth_mode=required" \
  3854. "$P_CLI crt_file=data_files/server6.crt \
  3855. key_file=data_files/server6.key" \
  3856. 0 \
  3857. -s "requested DN"
  3858. run_test "Authentication: do not send CA list in CertificateRequest" \
  3859. "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
  3860. "$P_CLI crt_file=data_files/server6.crt \
  3861. key_file=data_files/server6.key" \
  3862. 0 \
  3863. -S "requested DN"
  3864. run_test "Authentication: send CA list in CertificateRequest, client self signed" \
  3865. "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
  3866. "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
  3867. key_file=data_files/server5.key" \
  3868. 1 \
  3869. -S "requested DN" \
  3870. -s "x509_verify_cert() returned" \
  3871. -s "! The certificate is not correctly signed by the trusted CA" \
  3872. -s "! mbedtls_ssl_handshake returned" \
  3873. -c "! mbedtls_ssl_handshake returned" \
  3874. -s "X509 - Certificate verification failed"
  3875. # Tests for auth_mode, using CA callback, these are duplicated from the authentication tests
  3876. # When updating these tests, modify the matching authentication tests accordingly
  3877. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  3878. run_test "Authentication, CA callback: server badcert, client required" \
  3879. "$P_SRV crt_file=data_files/server5-badsign.crt \
  3880. key_file=data_files/server5.key" \
  3881. "$P_CLI ca_callback=1 debug_level=3 auth_mode=required" \
  3882. 1 \
  3883. -c "use CA callback for X.509 CRT verification" \
  3884. -c "x509_verify_cert() returned" \
  3885. -c "! The certificate is not correctly signed by the trusted CA" \
  3886. -c "! mbedtls_ssl_handshake returned" \
  3887. -c "X509 - Certificate verification failed"
  3888. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  3889. run_test "Authentication, CA callback: server badcert, client optional" \
  3890. "$P_SRV crt_file=data_files/server5-badsign.crt \
  3891. key_file=data_files/server5.key" \
  3892. "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional" \
  3893. 0 \
  3894. -c "use CA callback for X.509 CRT verification" \
  3895. -c "x509_verify_cert() returned" \
  3896. -c "! The certificate is not correctly signed by the trusted CA" \
  3897. -C "! mbedtls_ssl_handshake returned" \
  3898. -C "X509 - Certificate verification failed"
  3899. # The purpose of the next two tests is to test the client's behaviour when receiving a server
  3900. # certificate with an unsupported elliptic curve. This should usually not happen because
  3901. # the client informs the server about the supported curves - it does, though, in the
  3902. # corner case of a static ECDH suite, because the server doesn't check the curve on that
  3903. # occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
  3904. # different means to have the server ignoring the client's supported curve list.
  3905. requires_config_enabled MBEDTLS_ECP_C
  3906. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  3907. run_test "Authentication, CA callback: server ECDH p256v1, client required, p256v1 unsupported" \
  3908. "$P_SRV debug_level=1 key_file=data_files/server5.key \
  3909. crt_file=data_files/server5.ku-ka.crt" \
  3910. "$P_CLI ca_callback=1 debug_level=3 auth_mode=required curves=secp521r1" \
  3911. 1 \
  3912. -c "use CA callback for X.509 CRT verification" \
  3913. -c "bad certificate (EC key curve)" \
  3914. -c "! Certificate verification flags" \
  3915. -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
  3916. requires_config_enabled MBEDTLS_ECP_C
  3917. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  3918. run_test "Authentication, CA callback: server ECDH p256v1, client optional, p256v1 unsupported" \
  3919. "$P_SRV debug_level=1 key_file=data_files/server5.key \
  3920. crt_file=data_files/server5.ku-ka.crt" \
  3921. "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional curves=secp521r1" \
  3922. 1 \
  3923. -c "use CA callback for X.509 CRT verification" \
  3924. -c "bad certificate (EC key curve)"\
  3925. -c "! Certificate verification flags"\
  3926. -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
  3927. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  3928. run_test "Authentication, CA callback: client SHA256, server required" \
  3929. "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
  3930. "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
  3931. key_file=data_files/server6.key \
  3932. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
  3933. 0 \
  3934. -s "use CA callback for X.509 CRT verification" \
  3935. -c "Supported Signature Algorithm found: 4," \
  3936. -c "Supported Signature Algorithm found: 5,"
  3937. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  3938. run_test "Authentication, CA callback: client SHA384, server required" \
  3939. "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
  3940. "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
  3941. key_file=data_files/server6.key \
  3942. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
  3943. 0 \
  3944. -s "use CA callback for X.509 CRT verification" \
  3945. -c "Supported Signature Algorithm found: 4," \
  3946. -c "Supported Signature Algorithm found: 5,"
  3947. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  3948. run_test "Authentication, CA callback: client badcert, server required" \
  3949. "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
  3950. "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
  3951. key_file=data_files/server5.key" \
  3952. 1 \
  3953. -s "use CA callback for X.509 CRT verification" \
  3954. -S "skip write certificate request" \
  3955. -C "skip parse certificate request" \
  3956. -c "got a certificate request" \
  3957. -C "skip write certificate" \
  3958. -C "skip write certificate verify" \
  3959. -S "skip parse certificate verify" \
  3960. -s "x509_verify_cert() returned" \
  3961. -s "! The certificate is not correctly signed by the trusted CA" \
  3962. -s "! mbedtls_ssl_handshake returned" \
  3963. -s "send alert level=2 message=48" \
  3964. -c "! mbedtls_ssl_handshake returned" \
  3965. -s "X509 - Certificate verification failed"
  3966. # We don't check that the client receives the alert because it might
  3967. # detect that its write end of the connection is closed and abort
  3968. # before reading the alert message.
  3969. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  3970. run_test "Authentication, CA callback: client cert not trusted, server required" \
  3971. "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
  3972. "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
  3973. key_file=data_files/server5.key" \
  3974. 1 \
  3975. -s "use CA callback for X.509 CRT verification" \
  3976. -S "skip write certificate request" \
  3977. -C "skip parse certificate request" \
  3978. -c "got a certificate request" \
  3979. -C "skip write certificate" \
  3980. -C "skip write certificate verify" \
  3981. -S "skip parse certificate verify" \
  3982. -s "x509_verify_cert() returned" \
  3983. -s "! The certificate is not correctly signed by the trusted CA" \
  3984. -s "! mbedtls_ssl_handshake returned" \
  3985. -c "! mbedtls_ssl_handshake returned" \
  3986. -s "X509 - Certificate verification failed"
  3987. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  3988. run_test "Authentication, CA callback: client badcert, server optional" \
  3989. "$P_SRV ca_callback=1 debug_level=3 auth_mode=optional" \
  3990. "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
  3991. key_file=data_files/server5.key" \
  3992. 0 \
  3993. -s "use CA callback for X.509 CRT verification" \
  3994. -S "skip write certificate request" \
  3995. -C "skip parse certificate request" \
  3996. -c "got a certificate request" \
  3997. -C "skip write certificate" \
  3998. -C "skip write certificate verify" \
  3999. -S "skip parse certificate verify" \
  4000. -s "x509_verify_cert() returned" \
  4001. -s "! The certificate is not correctly signed by the trusted CA" \
  4002. -S "! mbedtls_ssl_handshake returned" \
  4003. -C "! mbedtls_ssl_handshake returned" \
  4004. -S "X509 - Certificate verification failed"
  4005. requires_full_size_output_buffer
  4006. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  4007. run_test "Authentication, CA callback: server max_int chain, client default" \
  4008. "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
  4009. key_file=data_files/dir-maxpath/09.key" \
  4010. "$P_CLI ca_callback=1 debug_level=3 server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
  4011. 0 \
  4012. -c "use CA callback for X.509 CRT verification" \
  4013. -C "X509 - A fatal error occurred"
  4014. requires_full_size_output_buffer
  4015. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  4016. run_test "Authentication, CA callback: server max_int+1 chain, client default" \
  4017. "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
  4018. key_file=data_files/dir-maxpath/10.key" \
  4019. "$P_CLI debug_level=3 ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
  4020. 1 \
  4021. -c "use CA callback for X.509 CRT verification" \
  4022. -c "X509 - A fatal error occurred"
  4023. requires_full_size_output_buffer
  4024. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  4025. run_test "Authentication, CA callback: server max_int+1 chain, client optional" \
  4026. "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
  4027. key_file=data_files/dir-maxpath/10.key" \
  4028. "$P_CLI ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
  4029. debug_level=3 auth_mode=optional" \
  4030. 1 \
  4031. -c "use CA callback for X.509 CRT verification" \
  4032. -c "X509 - A fatal error occurred"
  4033. requires_full_size_output_buffer
  4034. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  4035. run_test "Authentication, CA callback: client max_int+1 chain, server optional" \
  4036. "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
  4037. "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
  4038. key_file=data_files/dir-maxpath/10.key" \
  4039. 1 \
  4040. -s "use CA callback for X.509 CRT verification" \
  4041. -s "X509 - A fatal error occurred"
  4042. requires_full_size_output_buffer
  4043. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  4044. run_test "Authentication, CA callback: client max_int+1 chain, server required" \
  4045. "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
  4046. "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
  4047. key_file=data_files/dir-maxpath/10.key" \
  4048. 1 \
  4049. -s "use CA callback for X.509 CRT verification" \
  4050. -s "X509 - A fatal error occurred"
  4051. requires_full_size_output_buffer
  4052. requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
  4053. run_test "Authentication, CA callback: client max_int chain, server required" \
  4054. "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
  4055. "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
  4056. key_file=data_files/dir-maxpath/09.key" \
  4057. 0 \
  4058. -s "use CA callback for X.509 CRT verification" \
  4059. -S "X509 - A fatal error occurred"
  4060. # Tests for certificate selection based on SHA verson
  4061. run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
  4062. "$P_SRV crt_file=data_files/server5.crt \
  4063. key_file=data_files/server5.key \
  4064. crt_file2=data_files/server5-sha1.crt \
  4065. key_file2=data_files/server5.key" \
  4066. "$P_CLI force_version=tls1_2" \
  4067. 0 \
  4068. -c "signed using.*ECDSA with SHA256" \
  4069. -C "signed using.*ECDSA with SHA1"
  4070. run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
  4071. "$P_SRV crt_file=data_files/server5.crt \
  4072. key_file=data_files/server5.key \
  4073. crt_file2=data_files/server5-sha1.crt \
  4074. key_file2=data_files/server5.key" \
  4075. "$P_CLI force_version=tls1_1" \
  4076. 0 \
  4077. -C "signed using.*ECDSA with SHA256" \
  4078. -c "signed using.*ECDSA with SHA1"
  4079. run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
  4080. "$P_SRV crt_file=data_files/server5.crt \
  4081. key_file=data_files/server5.key \
  4082. crt_file2=data_files/server5-sha1.crt \
  4083. key_file2=data_files/server5.key" \
  4084. "$P_CLI force_version=tls1" \
  4085. 0 \
  4086. -C "signed using.*ECDSA with SHA256" \
  4087. -c "signed using.*ECDSA with SHA1"
  4088. run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
  4089. "$P_SRV crt_file=data_files/server5.crt \
  4090. key_file=data_files/server5.key \
  4091. crt_file2=data_files/server6.crt \
  4092. key_file2=data_files/server6.key" \
  4093. "$P_CLI force_version=tls1_1" \
  4094. 0 \
  4095. -c "serial number.*09" \
  4096. -c "signed using.*ECDSA with SHA256" \
  4097. -C "signed using.*ECDSA with SHA1"
  4098. run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
  4099. "$P_SRV crt_file=data_files/server6.crt \
  4100. key_file=data_files/server6.key \
  4101. crt_file2=data_files/server5.crt \
  4102. key_file2=data_files/server5.key" \
  4103. "$P_CLI force_version=tls1_1" \
  4104. 0 \
  4105. -c "serial number.*0A" \
  4106. -c "signed using.*ECDSA with SHA256" \
  4107. -C "signed using.*ECDSA with SHA1"
  4108. # tests for SNI
  4109. run_test "SNI: no SNI callback" \
  4110. "$P_SRV debug_level=3 \
  4111. crt_file=data_files/server5.crt key_file=data_files/server5.key" \
  4112. "$P_CLI server_name=localhost" \
  4113. 0 \
  4114. -S "parse ServerName extension" \
  4115. -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
  4116. -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
  4117. run_test "SNI: matching cert 1" \
  4118. "$P_SRV debug_level=3 \
  4119. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4120. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
  4121. "$P_CLI server_name=localhost" \
  4122. 0 \
  4123. -s "parse ServerName extension" \
  4124. -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
  4125. -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
  4126. run_test "SNI: matching cert 2" \
  4127. "$P_SRV debug_level=3 \
  4128. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4129. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
  4130. "$P_CLI server_name=polarssl.example" \
  4131. 0 \
  4132. -s "parse ServerName extension" \
  4133. -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
  4134. -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
  4135. run_test "SNI: no matching cert" \
  4136. "$P_SRV debug_level=3 \
  4137. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4138. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
  4139. "$P_CLI server_name=nonesuch.example" \
  4140. 1 \
  4141. -s "parse ServerName extension" \
  4142. -s "ssl_sni_wrapper() returned" \
  4143. -s "mbedtls_ssl_handshake returned" \
  4144. -c "mbedtls_ssl_handshake returned" \
  4145. -c "SSL - A fatal alert message was received from our peer"
  4146. run_test "SNI: client auth no override: optional" \
  4147. "$P_SRV debug_level=3 auth_mode=optional \
  4148. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4149. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
  4150. "$P_CLI debug_level=3 server_name=localhost" \
  4151. 0 \
  4152. -S "skip write certificate request" \
  4153. -C "skip parse certificate request" \
  4154. -c "got a certificate request" \
  4155. -C "skip write certificate" \
  4156. -C "skip write certificate verify" \
  4157. -S "skip parse certificate verify"
  4158. run_test "SNI: client auth override: none -> optional" \
  4159. "$P_SRV debug_level=3 auth_mode=none \
  4160. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4161. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
  4162. "$P_CLI debug_level=3 server_name=localhost" \
  4163. 0 \
  4164. -S "skip write certificate request" \
  4165. -C "skip parse certificate request" \
  4166. -c "got a certificate request" \
  4167. -C "skip write certificate" \
  4168. -C "skip write certificate verify" \
  4169. -S "skip parse certificate verify"
  4170. run_test "SNI: client auth override: optional -> none" \
  4171. "$P_SRV debug_level=3 auth_mode=optional \
  4172. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4173. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
  4174. "$P_CLI debug_level=3 server_name=localhost" \
  4175. 0 \
  4176. -s "skip write certificate request" \
  4177. -C "skip parse certificate request" \
  4178. -c "got no certificate request" \
  4179. -c "skip write certificate" \
  4180. -c "skip write certificate verify" \
  4181. -s "skip parse certificate verify"
  4182. run_test "SNI: CA no override" \
  4183. "$P_SRV debug_level=3 auth_mode=optional \
  4184. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4185. ca_file=data_files/test-ca.crt \
  4186. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
  4187. "$P_CLI debug_level=3 server_name=localhost \
  4188. crt_file=data_files/server6.crt key_file=data_files/server6.key" \
  4189. 1 \
  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 "The certificate has been revoked (is on a CRL)"
  4199. run_test "SNI: CA override" \
  4200. "$P_SRV debug_level=3 auth_mode=optional \
  4201. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4202. ca_file=data_files/test-ca.crt \
  4203. sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
  4204. "$P_CLI debug_level=3 server_name=localhost \
  4205. crt_file=data_files/server6.crt key_file=data_files/server6.key" \
  4206. 0 \
  4207. -S "skip write certificate request" \
  4208. -C "skip parse certificate request" \
  4209. -c "got a certificate request" \
  4210. -C "skip write certificate" \
  4211. -C "skip write certificate verify" \
  4212. -S "skip parse certificate verify" \
  4213. -S "x509_verify_cert() returned" \
  4214. -S "! The certificate is not correctly signed by the trusted CA" \
  4215. -S "The certificate has been revoked (is on a CRL)"
  4216. run_test "SNI: CA override with CRL" \
  4217. "$P_SRV debug_level=3 auth_mode=optional \
  4218. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4219. ca_file=data_files/test-ca.crt \
  4220. sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
  4221. "$P_CLI debug_level=3 server_name=localhost \
  4222. crt_file=data_files/server6.crt key_file=data_files/server6.key" \
  4223. 1 \
  4224. -S "skip write certificate request" \
  4225. -C "skip parse certificate request" \
  4226. -c "got a certificate request" \
  4227. -C "skip write certificate" \
  4228. -C "skip write certificate verify" \
  4229. -S "skip parse certificate verify" \
  4230. -s "x509_verify_cert() returned" \
  4231. -S "! The certificate is not correctly signed by the trusted CA" \
  4232. -s "The certificate has been revoked (is on a CRL)"
  4233. # Tests for SNI and DTLS
  4234. run_test "SNI: DTLS, no SNI callback" \
  4235. "$P_SRV debug_level=3 dtls=1 \
  4236. crt_file=data_files/server5.crt key_file=data_files/server5.key" \
  4237. "$P_CLI server_name=localhost dtls=1" \
  4238. 0 \
  4239. -S "parse ServerName extension" \
  4240. -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
  4241. -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
  4242. run_test "SNI: DTLS, matching cert 1" \
  4243. "$P_SRV debug_level=3 dtls=1 \
  4244. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4245. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
  4246. "$P_CLI server_name=localhost dtls=1" \
  4247. 0 \
  4248. -s "parse ServerName extension" \
  4249. -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
  4250. -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
  4251. run_test "SNI: DTLS, matching cert 2" \
  4252. "$P_SRV debug_level=3 dtls=1 \
  4253. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4254. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
  4255. "$P_CLI server_name=polarssl.example dtls=1" \
  4256. 0 \
  4257. -s "parse ServerName extension" \
  4258. -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
  4259. -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
  4260. run_test "SNI: DTLS, no matching cert" \
  4261. "$P_SRV debug_level=3 dtls=1 \
  4262. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4263. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
  4264. "$P_CLI server_name=nonesuch.example dtls=1" \
  4265. 1 \
  4266. -s "parse ServerName extension" \
  4267. -s "ssl_sni_wrapper() returned" \
  4268. -s "mbedtls_ssl_handshake returned" \
  4269. -c "mbedtls_ssl_handshake returned" \
  4270. -c "SSL - A fatal alert message was received from our peer"
  4271. run_test "SNI: DTLS, client auth no override: optional" \
  4272. "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
  4273. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4274. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
  4275. "$P_CLI debug_level=3 server_name=localhost dtls=1" \
  4276. 0 \
  4277. -S "skip write certificate request" \
  4278. -C "skip parse certificate request" \
  4279. -c "got a certificate request" \
  4280. -C "skip write certificate" \
  4281. -C "skip write certificate verify" \
  4282. -S "skip parse certificate verify"
  4283. run_test "SNI: DTLS, client auth override: none -> optional" \
  4284. "$P_SRV debug_level=3 auth_mode=none dtls=1 \
  4285. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4286. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
  4287. "$P_CLI debug_level=3 server_name=localhost dtls=1" \
  4288. 0 \
  4289. -S "skip write certificate request" \
  4290. -C "skip parse certificate request" \
  4291. -c "got a certificate request" \
  4292. -C "skip write certificate" \
  4293. -C "skip write certificate verify" \
  4294. -S "skip parse certificate verify"
  4295. run_test "SNI: DTLS, client auth override: optional -> none" \
  4296. "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
  4297. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4298. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
  4299. "$P_CLI debug_level=3 server_name=localhost dtls=1" \
  4300. 0 \
  4301. -s "skip write certificate request" \
  4302. -C "skip parse certificate request" \
  4303. -c "got no certificate request" \
  4304. -c "skip write certificate" \
  4305. -c "skip write certificate verify" \
  4306. -s "skip parse certificate verify"
  4307. run_test "SNI: DTLS, CA no override" \
  4308. "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
  4309. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4310. ca_file=data_files/test-ca.crt \
  4311. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
  4312. "$P_CLI debug_level=3 server_name=localhost dtls=1 \
  4313. crt_file=data_files/server6.crt key_file=data_files/server6.key" \
  4314. 1 \
  4315. -S "skip write certificate request" \
  4316. -C "skip parse certificate request" \
  4317. -c "got a certificate request" \
  4318. -C "skip write certificate" \
  4319. -C "skip write certificate verify" \
  4320. -S "skip parse certificate verify" \
  4321. -s "x509_verify_cert() returned" \
  4322. -s "! The certificate is not correctly signed by the trusted CA" \
  4323. -S "The certificate has been revoked (is on a CRL)"
  4324. run_test "SNI: DTLS, CA override" \
  4325. "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
  4326. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  4327. ca_file=data_files/test-ca.crt \
  4328. sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
  4329. "$P_CLI debug_level=3 server_name=localhost dtls=1 \
  4330. crt_file=data_files/server6.crt key_file=data_files/server6.key" \
  4331. 0 \
  4332. -S "skip write certificate request" \
  4333. -C "skip parse certificate request" \
  4334. -c "got a certificate request" \
  4335. -C "skip write certificate" \
  4336. -C "skip write certificate verify" \
  4337. -S "skip parse certificate verify" \
  4338. -S "x509_verify_cert() returned" \
  4339. -S "! The certificate is not correctly signed by the trusted CA" \
  4340. -S "The certificate has been revoked (is on a CRL)"
  4341. run_test "SNI: DTLS, CA override with CRL" \
  4342. "$P_SRV debug_level=3 auth_mode=optional \
  4343. crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
  4344. ca_file=data_files/test-ca.crt \
  4345. sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
  4346. "$P_CLI debug_level=3 server_name=localhost dtls=1 \
  4347. crt_file=data_files/server6.crt key_file=data_files/server6.key" \
  4348. 1 \
  4349. -S "skip write certificate request" \
  4350. -C "skip parse certificate request" \
  4351. -c "got a certificate request" \
  4352. -C "skip write certificate" \
  4353. -C "skip write certificate verify" \
  4354. -S "skip parse certificate verify" \
  4355. -s "x509_verify_cert() returned" \
  4356. -S "! The certificate is not correctly signed by the trusted CA" \
  4357. -s "The certificate has been revoked (is on a CRL)"
  4358. # Tests for non-blocking I/O: exercise a variety of handshake flows
  4359. run_test "Non-blocking I/O: basic handshake" \
  4360. "$P_SRV nbio=2 tickets=0 auth_mode=none" \
  4361. "$P_CLI nbio=2 tickets=0" \
  4362. 0 \
  4363. -S "mbedtls_ssl_handshake returned" \
  4364. -C "mbedtls_ssl_handshake returned" \
  4365. -c "Read from server: .* bytes read"
  4366. run_test "Non-blocking I/O: client auth" \
  4367. "$P_SRV nbio=2 tickets=0 auth_mode=required" \
  4368. "$P_CLI nbio=2 tickets=0" \
  4369. 0 \
  4370. -S "mbedtls_ssl_handshake returned" \
  4371. -C "mbedtls_ssl_handshake returned" \
  4372. -c "Read from server: .* bytes read"
  4373. run_test "Non-blocking I/O: ticket" \
  4374. "$P_SRV nbio=2 tickets=1 auth_mode=none" \
  4375. "$P_CLI nbio=2 tickets=1" \
  4376. 0 \
  4377. -S "mbedtls_ssl_handshake returned" \
  4378. -C "mbedtls_ssl_handshake returned" \
  4379. -c "Read from server: .* bytes read"
  4380. run_test "Non-blocking I/O: ticket + client auth" \
  4381. "$P_SRV nbio=2 tickets=1 auth_mode=required" \
  4382. "$P_CLI nbio=2 tickets=1" \
  4383. 0 \
  4384. -S "mbedtls_ssl_handshake returned" \
  4385. -C "mbedtls_ssl_handshake returned" \
  4386. -c "Read from server: .* bytes read"
  4387. run_test "Non-blocking I/O: ticket + client auth + resume" \
  4388. "$P_SRV nbio=2 tickets=1 auth_mode=required" \
  4389. "$P_CLI nbio=2 tickets=1 reconnect=1" \
  4390. 0 \
  4391. -S "mbedtls_ssl_handshake returned" \
  4392. -C "mbedtls_ssl_handshake returned" \
  4393. -c "Read from server: .* bytes read"
  4394. run_test "Non-blocking I/O: ticket + resume" \
  4395. "$P_SRV nbio=2 tickets=1 auth_mode=none" \
  4396. "$P_CLI nbio=2 tickets=1 reconnect=1" \
  4397. 0 \
  4398. -S "mbedtls_ssl_handshake returned" \
  4399. -C "mbedtls_ssl_handshake returned" \
  4400. -c "Read from server: .* bytes read"
  4401. run_test "Non-blocking I/O: session-id resume" \
  4402. "$P_SRV nbio=2 tickets=0 auth_mode=none" \
  4403. "$P_CLI nbio=2 tickets=0 reconnect=1" \
  4404. 0 \
  4405. -S "mbedtls_ssl_handshake returned" \
  4406. -C "mbedtls_ssl_handshake returned" \
  4407. -c "Read from server: .* bytes read"
  4408. # Tests for event-driven I/O: exercise a variety of handshake flows
  4409. run_test "Event-driven I/O: basic handshake" \
  4410. "$P_SRV event=1 tickets=0 auth_mode=none" \
  4411. "$P_CLI event=1 tickets=0" \
  4412. 0 \
  4413. -S "mbedtls_ssl_handshake returned" \
  4414. -C "mbedtls_ssl_handshake returned" \
  4415. -c "Read from server: .* bytes read"
  4416. run_test "Event-driven I/O: client auth" \
  4417. "$P_SRV event=1 tickets=0 auth_mode=required" \
  4418. "$P_CLI event=1 tickets=0" \
  4419. 0 \
  4420. -S "mbedtls_ssl_handshake returned" \
  4421. -C "mbedtls_ssl_handshake returned" \
  4422. -c "Read from server: .* bytes read"
  4423. run_test "Event-driven I/O: ticket" \
  4424. "$P_SRV event=1 tickets=1 auth_mode=none" \
  4425. "$P_CLI event=1 tickets=1" \
  4426. 0 \
  4427. -S "mbedtls_ssl_handshake returned" \
  4428. -C "mbedtls_ssl_handshake returned" \
  4429. -c "Read from server: .* bytes read"
  4430. run_test "Event-driven I/O: ticket + client auth" \
  4431. "$P_SRV event=1 tickets=1 auth_mode=required" \
  4432. "$P_CLI event=1 tickets=1" \
  4433. 0 \
  4434. -S "mbedtls_ssl_handshake returned" \
  4435. -C "mbedtls_ssl_handshake returned" \
  4436. -c "Read from server: .* bytes read"
  4437. run_test "Event-driven I/O: ticket + client auth + resume" \
  4438. "$P_SRV event=1 tickets=1 auth_mode=required" \
  4439. "$P_CLI event=1 tickets=1 reconnect=1" \
  4440. 0 \
  4441. -S "mbedtls_ssl_handshake returned" \
  4442. -C "mbedtls_ssl_handshake returned" \
  4443. -c "Read from server: .* bytes read"
  4444. run_test "Event-driven I/O: ticket + resume" \
  4445. "$P_SRV event=1 tickets=1 auth_mode=none" \
  4446. "$P_CLI event=1 tickets=1 reconnect=1" \
  4447. 0 \
  4448. -S "mbedtls_ssl_handshake returned" \
  4449. -C "mbedtls_ssl_handshake returned" \
  4450. -c "Read from server: .* bytes read"
  4451. run_test "Event-driven I/O: session-id resume" \
  4452. "$P_SRV event=1 tickets=0 auth_mode=none" \
  4453. "$P_CLI event=1 tickets=0 reconnect=1" \
  4454. 0 \
  4455. -S "mbedtls_ssl_handshake returned" \
  4456. -C "mbedtls_ssl_handshake returned" \
  4457. -c "Read from server: .* bytes read"
  4458. run_test "Event-driven I/O, DTLS: basic handshake" \
  4459. "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
  4460. "$P_CLI dtls=1 event=1 tickets=0" \
  4461. 0 \
  4462. -c "Read from server: .* bytes read"
  4463. run_test "Event-driven I/O, DTLS: client auth" \
  4464. "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
  4465. "$P_CLI dtls=1 event=1 tickets=0" \
  4466. 0 \
  4467. -c "Read from server: .* bytes read"
  4468. run_test "Event-driven I/O, DTLS: ticket" \
  4469. "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
  4470. "$P_CLI dtls=1 event=1 tickets=1" \
  4471. 0 \
  4472. -c "Read from server: .* bytes read"
  4473. run_test "Event-driven I/O, DTLS: ticket + client auth" \
  4474. "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
  4475. "$P_CLI dtls=1 event=1 tickets=1" \
  4476. 0 \
  4477. -c "Read from server: .* bytes read"
  4478. run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
  4479. "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
  4480. "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
  4481. 0 \
  4482. -c "Read from server: .* bytes read"
  4483. run_test "Event-driven I/O, DTLS: ticket + resume" \
  4484. "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
  4485. "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
  4486. 0 \
  4487. -c "Read from server: .* bytes read"
  4488. run_test "Event-driven I/O, DTLS: session-id resume" \
  4489. "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
  4490. "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
  4491. 0 \
  4492. -c "Read from server: .* bytes read"
  4493. # This test demonstrates the need for the mbedtls_ssl_check_pending function.
  4494. # During session resumption, the client will send its ApplicationData record
  4495. # within the same datagram as the Finished messages. In this situation, the
  4496. # server MUST NOT idle on the underlying transport after handshake completion,
  4497. # because the ApplicationData request has already been queued internally.
  4498. run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
  4499. -p "$P_PXY pack=50" \
  4500. "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
  4501. "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
  4502. 0 \
  4503. -c "Read from server: .* bytes read"
  4504. # Tests for version negotiation
  4505. run_test "Version check: all -> 1.2" \
  4506. "$P_SRV" \
  4507. "$P_CLI" \
  4508. 0 \
  4509. -S "mbedtls_ssl_handshake returned" \
  4510. -C "mbedtls_ssl_handshake returned" \
  4511. -s "Protocol is TLSv1.2" \
  4512. -c "Protocol is TLSv1.2"
  4513. run_test "Version check: cli max 1.1 -> 1.1" \
  4514. "$P_SRV" \
  4515. "$P_CLI max_version=tls1_1" \
  4516. 0 \
  4517. -S "mbedtls_ssl_handshake returned" \
  4518. -C "mbedtls_ssl_handshake returned" \
  4519. -s "Protocol is TLSv1.1" \
  4520. -c "Protocol is TLSv1.1"
  4521. run_test "Version check: srv max 1.1 -> 1.1" \
  4522. "$P_SRV max_version=tls1_1" \
  4523. "$P_CLI" \
  4524. 0 \
  4525. -S "mbedtls_ssl_handshake returned" \
  4526. -C "mbedtls_ssl_handshake returned" \
  4527. -s "Protocol is TLSv1.1" \
  4528. -c "Protocol is TLSv1.1"
  4529. run_test "Version check: cli+srv max 1.1 -> 1.1" \
  4530. "$P_SRV max_version=tls1_1" \
  4531. "$P_CLI max_version=tls1_1" \
  4532. 0 \
  4533. -S "mbedtls_ssl_handshake returned" \
  4534. -C "mbedtls_ssl_handshake returned" \
  4535. -s "Protocol is TLSv1.1" \
  4536. -c "Protocol is TLSv1.1"
  4537. run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
  4538. "$P_SRV min_version=tls1_1" \
  4539. "$P_CLI max_version=tls1_1" \
  4540. 0 \
  4541. -S "mbedtls_ssl_handshake returned" \
  4542. -C "mbedtls_ssl_handshake returned" \
  4543. -s "Protocol is TLSv1.1" \
  4544. -c "Protocol is TLSv1.1"
  4545. run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
  4546. "$P_SRV max_version=tls1_1" \
  4547. "$P_CLI min_version=tls1_1" \
  4548. 0 \
  4549. -S "mbedtls_ssl_handshake returned" \
  4550. -C "mbedtls_ssl_handshake returned" \
  4551. -s "Protocol is TLSv1.1" \
  4552. -c "Protocol is TLSv1.1"
  4553. run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
  4554. "$P_SRV max_version=tls1_1" \
  4555. "$P_CLI min_version=tls1_2" \
  4556. 1 \
  4557. -s "mbedtls_ssl_handshake returned" \
  4558. -c "mbedtls_ssl_handshake returned" \
  4559. -c "SSL - Handshake protocol not within min/max boundaries"
  4560. run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
  4561. "$P_SRV min_version=tls1_2" \
  4562. "$P_CLI max_version=tls1_1" \
  4563. 1 \
  4564. -s "mbedtls_ssl_handshake returned" \
  4565. -c "mbedtls_ssl_handshake returned" \
  4566. -s "SSL - Handshake protocol not within min/max boundaries"
  4567. # Tests for ALPN extension
  4568. run_test "ALPN: none" \
  4569. "$P_SRV debug_level=3" \
  4570. "$P_CLI debug_level=3" \
  4571. 0 \
  4572. -C "client hello, adding alpn extension" \
  4573. -S "found alpn extension" \
  4574. -C "got an alert message, type: \\[2:120]" \
  4575. -S "server hello, adding alpn extension" \
  4576. -C "found alpn extension " \
  4577. -C "Application Layer Protocol is" \
  4578. -S "Application Layer Protocol is"
  4579. run_test "ALPN: client only" \
  4580. "$P_SRV debug_level=3" \
  4581. "$P_CLI debug_level=3 alpn=abc,1234" \
  4582. 0 \
  4583. -c "client hello, adding alpn extension" \
  4584. -s "found alpn extension" \
  4585. -C "got an alert message, type: \\[2:120]" \
  4586. -S "server hello, adding alpn extension" \
  4587. -C "found alpn extension " \
  4588. -c "Application Layer Protocol is (none)" \
  4589. -S "Application Layer Protocol is"
  4590. run_test "ALPN: server only" \
  4591. "$P_SRV debug_level=3 alpn=abc,1234" \
  4592. "$P_CLI debug_level=3" \
  4593. 0 \
  4594. -C "client hello, adding alpn extension" \
  4595. -S "found alpn extension" \
  4596. -C "got an alert message, type: \\[2:120]" \
  4597. -S "server hello, adding alpn extension" \
  4598. -C "found alpn extension " \
  4599. -C "Application Layer Protocol is" \
  4600. -s "Application Layer Protocol is (none)"
  4601. run_test "ALPN: both, common cli1-srv1" \
  4602. "$P_SRV debug_level=3 alpn=abc,1234" \
  4603. "$P_CLI debug_level=3 alpn=abc,1234" \
  4604. 0 \
  4605. -c "client hello, adding alpn extension" \
  4606. -s "found alpn extension" \
  4607. -C "got an alert message, type: \\[2:120]" \
  4608. -s "server hello, adding alpn extension" \
  4609. -c "found alpn extension" \
  4610. -c "Application Layer Protocol is abc" \
  4611. -s "Application Layer Protocol is abc"
  4612. run_test "ALPN: both, common cli2-srv1" \
  4613. "$P_SRV debug_level=3 alpn=abc,1234" \
  4614. "$P_CLI debug_level=3 alpn=1234,abc" \
  4615. 0 \
  4616. -c "client hello, adding alpn extension" \
  4617. -s "found alpn extension" \
  4618. -C "got an alert message, type: \\[2:120]" \
  4619. -s "server hello, adding alpn extension" \
  4620. -c "found alpn extension" \
  4621. -c "Application Layer Protocol is abc" \
  4622. -s "Application Layer Protocol is abc"
  4623. run_test "ALPN: both, common cli1-srv2" \
  4624. "$P_SRV debug_level=3 alpn=abc,1234" \
  4625. "$P_CLI debug_level=3 alpn=1234,abcde" \
  4626. 0 \
  4627. -c "client hello, adding alpn extension" \
  4628. -s "found alpn extension" \
  4629. -C "got an alert message, type: \\[2:120]" \
  4630. -s "server hello, adding alpn extension" \
  4631. -c "found alpn extension" \
  4632. -c "Application Layer Protocol is 1234" \
  4633. -s "Application Layer Protocol is 1234"
  4634. run_test "ALPN: both, no common" \
  4635. "$P_SRV debug_level=3 alpn=abc,123" \
  4636. "$P_CLI debug_level=3 alpn=1234,abcde" \
  4637. 1 \
  4638. -c "client hello, adding alpn extension" \
  4639. -s "found alpn extension" \
  4640. -c "got an alert message, type: \\[2:120]" \
  4641. -S "server hello, adding alpn extension" \
  4642. -C "found alpn extension" \
  4643. -C "Application Layer Protocol is 1234" \
  4644. -S "Application Layer Protocol is 1234"
  4645. # Tests for keyUsage in leaf certificates, part 1:
  4646. # server-side certificate/suite selection
  4647. run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
  4648. "$P_SRV key_file=data_files/server2.key \
  4649. crt_file=data_files/server2.ku-ds.crt" \
  4650. "$P_CLI" \
  4651. 0 \
  4652. -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
  4653. run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
  4654. "$P_SRV key_file=data_files/server2.key \
  4655. crt_file=data_files/server2.ku-ke.crt" \
  4656. "$P_CLI" \
  4657. 0 \
  4658. -c "Ciphersuite is TLS-RSA-WITH-"
  4659. run_test "keyUsage srv: RSA, keyAgreement -> fail" \
  4660. "$P_SRV key_file=data_files/server2.key \
  4661. crt_file=data_files/server2.ku-ka.crt" \
  4662. "$P_CLI" \
  4663. 1 \
  4664. -C "Ciphersuite is "
  4665. run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
  4666. "$P_SRV key_file=data_files/server5.key \
  4667. crt_file=data_files/server5.ku-ds.crt" \
  4668. "$P_CLI" \
  4669. 0 \
  4670. -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
  4671. run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
  4672. "$P_SRV key_file=data_files/server5.key \
  4673. crt_file=data_files/server5.ku-ka.crt" \
  4674. "$P_CLI" \
  4675. 0 \
  4676. -c "Ciphersuite is TLS-ECDH-"
  4677. run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
  4678. "$P_SRV key_file=data_files/server5.key \
  4679. crt_file=data_files/server5.ku-ke.crt" \
  4680. "$P_CLI" \
  4681. 1 \
  4682. -C "Ciphersuite is "
  4683. # Tests for keyUsage in leaf certificates, part 2:
  4684. # client-side checking of server cert
  4685. run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
  4686. "$O_SRV -key data_files/server2.key \
  4687. -cert data_files/server2.ku-ds_ke.crt" \
  4688. "$P_CLI debug_level=1 \
  4689. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  4690. 0 \
  4691. -C "bad certificate (usage extensions)" \
  4692. -C "Processing of the Certificate handshake message failed" \
  4693. -c "Ciphersuite is TLS-"
  4694. run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
  4695. "$O_SRV -key data_files/server2.key \
  4696. -cert data_files/server2.ku-ds_ke.crt" \
  4697. "$P_CLI debug_level=1 \
  4698. force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
  4699. 0 \
  4700. -C "bad certificate (usage extensions)" \
  4701. -C "Processing of the Certificate handshake message failed" \
  4702. -c "Ciphersuite is TLS-"
  4703. run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
  4704. "$O_SRV -key data_files/server2.key \
  4705. -cert data_files/server2.ku-ke.crt" \
  4706. "$P_CLI debug_level=1 \
  4707. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  4708. 0 \
  4709. -C "bad certificate (usage extensions)" \
  4710. -C "Processing of the Certificate handshake message failed" \
  4711. -c "Ciphersuite is TLS-"
  4712. run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
  4713. "$O_SRV -key data_files/server2.key \
  4714. -cert data_files/server2.ku-ke.crt" \
  4715. "$P_CLI debug_level=1 \
  4716. force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
  4717. 1 \
  4718. -c "bad certificate (usage extensions)" \
  4719. -c "Processing of the Certificate handshake message failed" \
  4720. -C "Ciphersuite is TLS-"
  4721. run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
  4722. "$O_SRV -key data_files/server2.key \
  4723. -cert data_files/server2.ku-ke.crt" \
  4724. "$P_CLI debug_level=1 auth_mode=optional \
  4725. force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
  4726. 0 \
  4727. -c "bad certificate (usage extensions)" \
  4728. -C "Processing of the Certificate handshake message failed" \
  4729. -c "Ciphersuite is TLS-" \
  4730. -c "! Usage does not match the keyUsage extension"
  4731. run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
  4732. "$O_SRV -key data_files/server2.key \
  4733. -cert data_files/server2.ku-ds.crt" \
  4734. "$P_CLI debug_level=1 \
  4735. force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
  4736. 0 \
  4737. -C "bad certificate (usage extensions)" \
  4738. -C "Processing of the Certificate handshake message failed" \
  4739. -c "Ciphersuite is TLS-"
  4740. run_test "keyUsage cli: DigitalSignature, RSA: fail" \
  4741. "$O_SRV -key data_files/server2.key \
  4742. -cert data_files/server2.ku-ds.crt" \
  4743. "$P_CLI debug_level=1 \
  4744. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  4745. 1 \
  4746. -c "bad certificate (usage extensions)" \
  4747. -c "Processing of the Certificate handshake message failed" \
  4748. -C "Ciphersuite is TLS-"
  4749. run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
  4750. "$O_SRV -key data_files/server2.key \
  4751. -cert data_files/server2.ku-ds.crt" \
  4752. "$P_CLI debug_level=1 auth_mode=optional \
  4753. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  4754. 0 \
  4755. -c "bad certificate (usage extensions)" \
  4756. -C "Processing of the Certificate handshake message failed" \
  4757. -c "Ciphersuite is TLS-" \
  4758. -c "! Usage does not match the keyUsage extension"
  4759. # Tests for keyUsage in leaf certificates, part 3:
  4760. # server-side checking of client cert
  4761. run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
  4762. "$P_SRV debug_level=1 auth_mode=optional" \
  4763. "$O_CLI -key data_files/server2.key \
  4764. -cert data_files/server2.ku-ds.crt" \
  4765. 0 \
  4766. -S "bad certificate (usage extensions)" \
  4767. -S "Processing of the Certificate handshake message failed"
  4768. run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
  4769. "$P_SRV debug_level=1 auth_mode=optional" \
  4770. "$O_CLI -key data_files/server2.key \
  4771. -cert data_files/server2.ku-ke.crt" \
  4772. 0 \
  4773. -s "bad certificate (usage extensions)" \
  4774. -S "Processing of the Certificate handshake message failed"
  4775. run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
  4776. "$P_SRV debug_level=1 auth_mode=required" \
  4777. "$O_CLI -key data_files/server2.key \
  4778. -cert data_files/server2.ku-ke.crt" \
  4779. 1 \
  4780. -s "bad certificate (usage extensions)" \
  4781. -s "Processing of the Certificate handshake message failed"
  4782. run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
  4783. "$P_SRV debug_level=1 auth_mode=optional" \
  4784. "$O_CLI -key data_files/server5.key \
  4785. -cert data_files/server5.ku-ds.crt" \
  4786. 0 \
  4787. -S "bad certificate (usage extensions)" \
  4788. -S "Processing of the Certificate handshake message failed"
  4789. run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
  4790. "$P_SRV debug_level=1 auth_mode=optional" \
  4791. "$O_CLI -key data_files/server5.key \
  4792. -cert data_files/server5.ku-ka.crt" \
  4793. 0 \
  4794. -s "bad certificate (usage extensions)" \
  4795. -S "Processing of the Certificate handshake message failed"
  4796. # Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
  4797. run_test "extKeyUsage srv: serverAuth -> OK" \
  4798. "$P_SRV key_file=data_files/server5.key \
  4799. crt_file=data_files/server5.eku-srv.crt" \
  4800. "$P_CLI" \
  4801. 0
  4802. run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
  4803. "$P_SRV key_file=data_files/server5.key \
  4804. crt_file=data_files/server5.eku-srv.crt" \
  4805. "$P_CLI" \
  4806. 0
  4807. run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
  4808. "$P_SRV key_file=data_files/server5.key \
  4809. crt_file=data_files/server5.eku-cs_any.crt" \
  4810. "$P_CLI" \
  4811. 0
  4812. run_test "extKeyUsage srv: codeSign -> fail" \
  4813. "$P_SRV key_file=data_files/server5.key \
  4814. crt_file=data_files/server5.eku-cli.crt" \
  4815. "$P_CLI" \
  4816. 1
  4817. # Tests for extendedKeyUsage, part 2: client-side checking of server cert
  4818. run_test "extKeyUsage cli: serverAuth -> OK" \
  4819. "$O_SRV -key data_files/server5.key \
  4820. -cert data_files/server5.eku-srv.crt" \
  4821. "$P_CLI debug_level=1" \
  4822. 0 \
  4823. -C "bad certificate (usage extensions)" \
  4824. -C "Processing of the Certificate handshake message failed" \
  4825. -c "Ciphersuite is TLS-"
  4826. run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
  4827. "$O_SRV -key data_files/server5.key \
  4828. -cert data_files/server5.eku-srv_cli.crt" \
  4829. "$P_CLI debug_level=1" \
  4830. 0 \
  4831. -C "bad certificate (usage extensions)" \
  4832. -C "Processing of the Certificate handshake message failed" \
  4833. -c "Ciphersuite is TLS-"
  4834. run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
  4835. "$O_SRV -key data_files/server5.key \
  4836. -cert data_files/server5.eku-cs_any.crt" \
  4837. "$P_CLI debug_level=1" \
  4838. 0 \
  4839. -C "bad certificate (usage extensions)" \
  4840. -C "Processing of the Certificate handshake message failed" \
  4841. -c "Ciphersuite is TLS-"
  4842. run_test "extKeyUsage cli: codeSign -> fail" \
  4843. "$O_SRV -key data_files/server5.key \
  4844. -cert data_files/server5.eku-cs.crt" \
  4845. "$P_CLI debug_level=1" \
  4846. 1 \
  4847. -c "bad certificate (usage extensions)" \
  4848. -c "Processing of the Certificate handshake message failed" \
  4849. -C "Ciphersuite is TLS-"
  4850. # Tests for extendedKeyUsage, part 3: server-side checking of client cert
  4851. run_test "extKeyUsage cli-auth: clientAuth -> OK" \
  4852. "$P_SRV debug_level=1 auth_mode=optional" \
  4853. "$O_CLI -key data_files/server5.key \
  4854. -cert data_files/server5.eku-cli.crt" \
  4855. 0 \
  4856. -S "bad certificate (usage extensions)" \
  4857. -S "Processing of the Certificate handshake message failed"
  4858. run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
  4859. "$P_SRV debug_level=1 auth_mode=optional" \
  4860. "$O_CLI -key data_files/server5.key \
  4861. -cert data_files/server5.eku-srv_cli.crt" \
  4862. 0 \
  4863. -S "bad certificate (usage extensions)" \
  4864. -S "Processing of the Certificate handshake message failed"
  4865. run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
  4866. "$P_SRV debug_level=1 auth_mode=optional" \
  4867. "$O_CLI -key data_files/server5.key \
  4868. -cert data_files/server5.eku-cs_any.crt" \
  4869. 0 \
  4870. -S "bad certificate (usage extensions)" \
  4871. -S "Processing of the Certificate handshake message failed"
  4872. run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
  4873. "$P_SRV debug_level=1 auth_mode=optional" \
  4874. "$O_CLI -key data_files/server5.key \
  4875. -cert data_files/server5.eku-cs.crt" \
  4876. 0 \
  4877. -s "bad certificate (usage extensions)" \
  4878. -S "Processing of the Certificate handshake message failed"
  4879. run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
  4880. "$P_SRV debug_level=1 auth_mode=required" \
  4881. "$O_CLI -key data_files/server5.key \
  4882. -cert data_files/server5.eku-cs.crt" \
  4883. 1 \
  4884. -s "bad certificate (usage extensions)" \
  4885. -s "Processing of the Certificate handshake message failed"
  4886. # Tests for DHM parameters loading
  4887. run_test "DHM parameters: reference" \
  4888. "$P_SRV" \
  4889. "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
  4890. debug_level=3" \
  4891. 0 \
  4892. -c "value of 'DHM: P ' (2048 bits)" \
  4893. -c "value of 'DHM: G ' (2 bits)"
  4894. run_test "DHM parameters: other parameters" \
  4895. "$P_SRV dhm_file=data_files/dhparams.pem" \
  4896. "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
  4897. debug_level=3" \
  4898. 0 \
  4899. -c "value of 'DHM: P ' (1024 bits)" \
  4900. -c "value of 'DHM: G ' (2 bits)"
  4901. # Tests for DHM client-side size checking
  4902. run_test "DHM size: server default, client default, OK" \
  4903. "$P_SRV" \
  4904. "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
  4905. debug_level=1" \
  4906. 0 \
  4907. -C "DHM prime too short:"
  4908. run_test "DHM size: server default, client 2048, OK" \
  4909. "$P_SRV" \
  4910. "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
  4911. debug_level=1 dhmlen=2048" \
  4912. 0 \
  4913. -C "DHM prime too short:"
  4914. run_test "DHM size: server 1024, client default, OK" \
  4915. "$P_SRV dhm_file=data_files/dhparams.pem" \
  4916. "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
  4917. debug_level=1" \
  4918. 0 \
  4919. -C "DHM prime too short:"
  4920. run_test "DHM size: server 1000, client default, rejected" \
  4921. "$P_SRV dhm_file=data_files/dh.1000.pem" \
  4922. "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
  4923. debug_level=1" \
  4924. 1 \
  4925. -c "DHM prime too short:"
  4926. run_test "DHM size: server default, client 2049, rejected" \
  4927. "$P_SRV" \
  4928. "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
  4929. debug_level=1 dhmlen=2049" \
  4930. 1 \
  4931. -c "DHM prime too short:"
  4932. # Tests for PSK callback
  4933. run_test "PSK callback: psk, no callback" \
  4934. "$P_SRV psk=abc123 psk_identity=foo" \
  4935. "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  4936. psk_identity=foo psk=abc123" \
  4937. 0 \
  4938. -S "SSL - None of the common ciphersuites is usable" \
  4939. -S "SSL - Unknown identity received" \
  4940. -S "SSL - Verification of the message MAC failed"
  4941. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  4942. run_test "PSK callback: opaque psk on client, no callback" \
  4943. "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
  4944. "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  4945. psk_identity=foo psk=abc123 psk_opaque=1" \
  4946. 0 \
  4947. -c "skip PMS generation for opaque PSK"\
  4948. -S "skip PMS generation for opaque PSK"\
  4949. -C "session hash for extended master secret"\
  4950. -S "session hash for extended master secret"\
  4951. -S "SSL - None of the common ciphersuites is usable" \
  4952. -S "SSL - Unknown identity received" \
  4953. -S "SSL - Verification of the message MAC failed"
  4954. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  4955. run_test "PSK callback: opaque psk on client, no callback, SHA-384" \
  4956. "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
  4957. "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
  4958. psk_identity=foo psk=abc123 psk_opaque=1" \
  4959. 0 \
  4960. -c "skip PMS generation for opaque PSK"\
  4961. -S "skip PMS generation for opaque PSK"\
  4962. -C "session hash for extended master secret"\
  4963. -S "session hash for extended master secret"\
  4964. -S "SSL - None of the common ciphersuites is usable" \
  4965. -S "SSL - Unknown identity received" \
  4966. -S "SSL - Verification of the message MAC failed"
  4967. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  4968. run_test "PSK callback: opaque psk on client, no callback, EMS" \
  4969. "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
  4970. "$P_CLI extended_ms=1 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  4971. psk_identity=foo psk=abc123 psk_opaque=1" \
  4972. 0 \
  4973. -c "skip PMS generation for opaque PSK"\
  4974. -S "skip PMS generation for opaque PSK"\
  4975. -c "session hash for extended master secret"\
  4976. -s "session hash for extended master secret"\
  4977. -S "SSL - None of the common ciphersuites is usable" \
  4978. -S "SSL - Unknown identity received" \
  4979. -S "SSL - Verification of the message MAC failed"
  4980. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  4981. run_test "PSK callback: opaque psk on client, no callback, SHA-384, EMS" \
  4982. "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
  4983. "$P_CLI extended_ms=1 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
  4984. psk_identity=foo psk=abc123 psk_opaque=1" \
  4985. 0 \
  4986. -c "skip PMS generation for opaque PSK"\
  4987. -S "skip PMS generation for opaque PSK"\
  4988. -c "session hash for extended master secret"\
  4989. -s "session hash for extended master secret"\
  4990. -S "SSL - None of the common ciphersuites is usable" \
  4991. -S "SSL - Unknown identity received" \
  4992. -S "SSL - Verification of the message MAC failed"
  4993. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  4994. run_test "PSK callback: raw psk on client, static opaque on server, no callback" \
  4995. "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
  4996. "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  4997. psk_identity=foo psk=abc123" \
  4998. 0 \
  4999. -C "skip PMS generation for opaque PSK"\
  5000. -s "skip PMS generation for opaque PSK"\
  5001. -C "session hash for extended master secret"\
  5002. -S "session hash for extended master secret"\
  5003. -S "SSL - None of the common ciphersuites is usable" \
  5004. -S "SSL - Unknown identity received" \
  5005. -S "SSL - Verification of the message MAC failed"
  5006. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5007. run_test "PSK callback: raw psk on client, static opaque on server, no callback, SHA-384" \
  5008. "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384" \
  5009. "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
  5010. psk_identity=foo psk=abc123" \
  5011. 0 \
  5012. -C "skip PMS generation for opaque PSK"\
  5013. -s "skip PMS generation for opaque PSK"\
  5014. -C "session hash for extended master secret"\
  5015. -S "session hash for extended master secret"\
  5016. -S "SSL - None of the common ciphersuites is usable" \
  5017. -S "SSL - Unknown identity received" \
  5018. -S "SSL - Verification of the message MAC failed"
  5019. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5020. run_test "PSK callback: raw psk on client, static opaque on server, no callback, EMS" \
  5021. "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 \
  5022. force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \
  5023. "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5024. psk_identity=foo psk=abc123 extended_ms=1" \
  5025. 0 \
  5026. -c "session hash for extended master secret"\
  5027. -s "session hash for extended master secret"\
  5028. -C "skip PMS generation for opaque PSK"\
  5029. -s "skip PMS generation for opaque PSK"\
  5030. -S "SSL - None of the common ciphersuites is usable" \
  5031. -S "SSL - Unknown identity received" \
  5032. -S "SSL - Verification of the message MAC failed"
  5033. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5034. run_test "PSK callback: raw psk on client, static opaque on server, no callback, EMS, SHA384" \
  5035. "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 \
  5036. force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \
  5037. "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
  5038. psk_identity=foo psk=abc123 extended_ms=1" \
  5039. 0 \
  5040. -c "session hash for extended master secret"\
  5041. -s "session hash for extended master secret"\
  5042. -C "skip PMS generation for opaque PSK"\
  5043. -s "skip PMS generation for opaque PSK"\
  5044. -S "SSL - None of the common ciphersuites is usable" \
  5045. -S "SSL - Unknown identity received" \
  5046. -S "SSL - Verification of the message MAC failed"
  5047. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5048. run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback" \
  5049. "$P_SRV extended_ms=0 debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
  5050. "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5051. psk_identity=def psk=beef" \
  5052. 0 \
  5053. -C "skip PMS generation for opaque PSK"\
  5054. -s "skip PMS generation for opaque PSK"\
  5055. -C "session hash for extended master secret"\
  5056. -S "session hash for extended master secret"\
  5057. -S "SSL - None of the common ciphersuites is usable" \
  5058. -S "SSL - Unknown identity received" \
  5059. -S "SSL - Verification of the message MAC failed"
  5060. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5061. run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, SHA-384" \
  5062. "$P_SRV extended_ms=0 debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384" \
  5063. "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
  5064. psk_identity=def psk=beef" \
  5065. 0 \
  5066. -C "skip PMS generation for opaque PSK"\
  5067. -s "skip PMS generation for opaque PSK"\
  5068. -C "session hash for extended master secret"\
  5069. -S "session hash for extended master secret"\
  5070. -S "SSL - None of the common ciphersuites is usable" \
  5071. -S "SSL - Unknown identity received" \
  5072. -S "SSL - Verification of the message MAC failed"
  5073. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5074. run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, EMS" \
  5075. "$P_SRV debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls1_2 \
  5076. force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \
  5077. "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5078. psk_identity=abc psk=dead extended_ms=1" \
  5079. 0 \
  5080. -c "session hash for extended master secret"\
  5081. -s "session hash for extended master secret"\
  5082. -C "skip PMS generation for opaque PSK"\
  5083. -s "skip PMS generation for opaque PSK"\
  5084. -S "SSL - None of the common ciphersuites is usable" \
  5085. -S "SSL - Unknown identity received" \
  5086. -S "SSL - Verification of the message MAC failed"
  5087. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5088. run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, EMS, SHA384" \
  5089. "$P_SRV debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls1_2 \
  5090. force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \
  5091. "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
  5092. psk_identity=abc psk=dead extended_ms=1" \
  5093. 0 \
  5094. -c "session hash for extended master secret"\
  5095. -s "session hash for extended master secret"\
  5096. -C "skip PMS generation for opaque PSK"\
  5097. -s "skip PMS generation for opaque PSK"\
  5098. -S "SSL - None of the common ciphersuites is usable" \
  5099. -S "SSL - Unknown identity received" \
  5100. -S "SSL - Verification of the message MAC failed"
  5101. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5102. run_test "PSK callback: raw psk on client, mismatching static raw PSK on server, opaque PSK from callback" \
  5103. "$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=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
  5104. "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5105. psk_identity=def psk=beef" \
  5106. 0 \
  5107. -C "skip PMS generation for opaque PSK"\
  5108. -s "skip PMS generation for opaque PSK"\
  5109. -C "session hash for extended master secret"\
  5110. -S "session hash for extended master secret"\
  5111. -S "SSL - None of the common ciphersuites is usable" \
  5112. -S "SSL - Unknown identity received" \
  5113. -S "SSL - Verification of the message MAC failed"
  5114. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5115. run_test "PSK callback: raw psk on client, mismatching static opaque PSK on server, opaque PSK from callback" \
  5116. "$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=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
  5117. "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5118. psk_identity=def psk=beef" \
  5119. 0 \
  5120. -C "skip PMS generation for opaque PSK"\
  5121. -s "skip PMS generation for opaque PSK"\
  5122. -C "session hash for extended master secret"\
  5123. -S "session hash for extended master secret"\
  5124. -S "SSL - None of the common ciphersuites is usable" \
  5125. -S "SSL - Unknown identity received" \
  5126. -S "SSL - Verification of the message MAC failed"
  5127. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5128. run_test "PSK callback: raw psk on client, mismatching static opaque PSK on server, raw PSK from callback" \
  5129. "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=foo psk=abc123 debug_level=3 psk_list=abc,dead,def,beef min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
  5130. "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5131. psk_identity=def psk=beef" \
  5132. 0 \
  5133. -C "skip PMS generation for opaque PSK"\
  5134. -C "session hash for extended master secret"\
  5135. -S "session hash for extended master secret"\
  5136. -S "SSL - None of the common ciphersuites is usable" \
  5137. -S "SSL - Unknown identity received" \
  5138. -S "SSL - Verification of the message MAC failed"
  5139. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5140. run_test "PSK callback: raw psk on client, id-matching but wrong raw PSK on server, opaque PSK from callback" \
  5141. "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=def psk=abc123 debug_level=3 psk_list=abc,dead,def,beef min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
  5142. "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5143. psk_identity=def psk=beef" \
  5144. 0 \
  5145. -C "skip PMS generation for opaque PSK"\
  5146. -C "session hash for extended master secret"\
  5147. -S "session hash for extended master secret"\
  5148. -S "SSL - None of the common ciphersuites is usable" \
  5149. -S "SSL - Unknown identity received" \
  5150. -S "SSL - Verification of the message MAC failed"
  5151. requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
  5152. run_test "PSK callback: raw psk on client, matching opaque PSK on server, wrong opaque PSK from callback" \
  5153. "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=def psk=beef debug_level=3 psk_list=abc,dead,def,abc123 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
  5154. "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5155. psk_identity=def psk=beef" \
  5156. 1 \
  5157. -s "SSL - Verification of the message MAC failed"
  5158. run_test "PSK callback: no psk, no callback" \
  5159. "$P_SRV" \
  5160. "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5161. psk_identity=foo psk=abc123" \
  5162. 1 \
  5163. -s "SSL - None of the common ciphersuites is usable" \
  5164. -S "SSL - Unknown identity received" \
  5165. -S "SSL - Verification of the message MAC failed"
  5166. run_test "PSK callback: callback overrides other settings" \
  5167. "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
  5168. "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5169. psk_identity=foo psk=abc123" \
  5170. 1 \
  5171. -S "SSL - None of the common ciphersuites is usable" \
  5172. -s "SSL - Unknown identity received" \
  5173. -S "SSL - Verification of the message MAC failed"
  5174. run_test "PSK callback: first id matches" \
  5175. "$P_SRV psk_list=abc,dead,def,beef" \
  5176. "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5177. psk_identity=abc psk=dead" \
  5178. 0 \
  5179. -S "SSL - None of the common ciphersuites is usable" \
  5180. -S "SSL - Unknown identity received" \
  5181. -S "SSL - Verification of the message MAC failed"
  5182. run_test "PSK callback: second id matches" \
  5183. "$P_SRV psk_list=abc,dead,def,beef" \
  5184. "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5185. psk_identity=def psk=beef" \
  5186. 0 \
  5187. -S "SSL - None of the common ciphersuites is usable" \
  5188. -S "SSL - Unknown identity received" \
  5189. -S "SSL - Verification of the message MAC failed"
  5190. run_test "PSK callback: no match" \
  5191. "$P_SRV psk_list=abc,dead,def,beef" \
  5192. "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5193. psk_identity=ghi psk=beef" \
  5194. 1 \
  5195. -S "SSL - None of the common ciphersuites is usable" \
  5196. -s "SSL - Unknown identity received" \
  5197. -S "SSL - Verification of the message MAC failed"
  5198. run_test "PSK callback: wrong key" \
  5199. "$P_SRV psk_list=abc,dead,def,beef" \
  5200. "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
  5201. psk_identity=abc psk=beef" \
  5202. 1 \
  5203. -S "SSL - None of the common ciphersuites is usable" \
  5204. -S "SSL - Unknown identity received" \
  5205. -s "SSL - Verification of the message MAC failed"
  5206. # Tests for EC J-PAKE
  5207. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
  5208. run_test "ECJPAKE: client not configured" \
  5209. "$P_SRV debug_level=3" \
  5210. "$P_CLI debug_level=3" \
  5211. 0 \
  5212. -C "add ciphersuite: 0xc0ff" \
  5213. -C "adding ecjpake_kkpp extension" \
  5214. -S "found ecjpake kkpp extension" \
  5215. -S "skip ecjpake kkpp extension" \
  5216. -S "ciphersuite mismatch: ecjpake not configured" \
  5217. -S "server hello, ecjpake kkpp extension" \
  5218. -C "found ecjpake_kkpp extension" \
  5219. -S "None of the common ciphersuites is usable"
  5220. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
  5221. run_test "ECJPAKE: server not configured" \
  5222. "$P_SRV debug_level=3" \
  5223. "$P_CLI debug_level=3 ecjpake_pw=bla \
  5224. force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
  5225. 1 \
  5226. -c "add ciphersuite: 0xc0ff" \
  5227. -c "adding ecjpake_kkpp extension" \
  5228. -s "found ecjpake kkpp extension" \
  5229. -s "skip ecjpake kkpp extension" \
  5230. -s "ciphersuite mismatch: ecjpake not configured" \
  5231. -S "server hello, ecjpake kkpp extension" \
  5232. -C "found ecjpake_kkpp extension" \
  5233. -s "None of the common ciphersuites is usable"
  5234. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
  5235. run_test "ECJPAKE: working, TLS" \
  5236. "$P_SRV debug_level=3 ecjpake_pw=bla" \
  5237. "$P_CLI debug_level=3 ecjpake_pw=bla \
  5238. force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
  5239. 0 \
  5240. -c "add ciphersuite: 0xc0ff" \
  5241. -c "adding ecjpake_kkpp extension" \
  5242. -C "re-using cached ecjpake parameters" \
  5243. -s "found ecjpake kkpp extension" \
  5244. -S "skip ecjpake kkpp extension" \
  5245. -S "ciphersuite mismatch: ecjpake not configured" \
  5246. -s "server hello, ecjpake kkpp extension" \
  5247. -c "found ecjpake_kkpp extension" \
  5248. -S "None of the common ciphersuites is usable" \
  5249. -S "SSL - Verification of the message MAC failed"
  5250. server_needs_more_time 1
  5251. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
  5252. run_test "ECJPAKE: password mismatch, TLS" \
  5253. "$P_SRV debug_level=3 ecjpake_pw=bla" \
  5254. "$P_CLI debug_level=3 ecjpake_pw=bad \
  5255. force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
  5256. 1 \
  5257. -C "re-using cached ecjpake parameters" \
  5258. -s "SSL - Verification of the message MAC failed"
  5259. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
  5260. run_test "ECJPAKE: working, DTLS" \
  5261. "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
  5262. "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
  5263. force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
  5264. 0 \
  5265. -c "re-using cached ecjpake parameters" \
  5266. -S "SSL - Verification of the message MAC failed"
  5267. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
  5268. run_test "ECJPAKE: working, DTLS, no cookie" \
  5269. "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
  5270. "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
  5271. force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
  5272. 0 \
  5273. -C "re-using cached ecjpake parameters" \
  5274. -S "SSL - Verification of the message MAC failed"
  5275. server_needs_more_time 1
  5276. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
  5277. run_test "ECJPAKE: password mismatch, DTLS" \
  5278. "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
  5279. "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
  5280. force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
  5281. 1 \
  5282. -c "re-using cached ecjpake parameters" \
  5283. -s "SSL - Verification of the message MAC failed"
  5284. # for tests with configs/config-thread.h
  5285. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
  5286. run_test "ECJPAKE: working, DTLS, nolog" \
  5287. "$P_SRV dtls=1 ecjpake_pw=bla" \
  5288. "$P_CLI dtls=1 ecjpake_pw=bla \
  5289. force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
  5290. 0
  5291. # Tests for ciphersuites per version
  5292. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  5293. requires_config_enabled MBEDTLS_CAMELLIA_C
  5294. requires_config_enabled MBEDTLS_AES_C
  5295. run_test "Per-version suites: SSL3" \
  5296. "$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" \
  5297. "$P_CLI force_version=ssl3" \
  5298. 0 \
  5299. -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
  5300. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
  5301. requires_config_enabled MBEDTLS_CAMELLIA_C
  5302. requires_config_enabled MBEDTLS_AES_C
  5303. run_test "Per-version suites: TLS 1.0" \
  5304. "$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" \
  5305. "$P_CLI force_version=tls1 arc4=1" \
  5306. 0 \
  5307. -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
  5308. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
  5309. requires_config_enabled MBEDTLS_CAMELLIA_C
  5310. requires_config_enabled MBEDTLS_AES_C
  5311. run_test "Per-version suites: TLS 1.1" \
  5312. "$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" \
  5313. "$P_CLI force_version=tls1_1" \
  5314. 0 \
  5315. -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
  5316. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
  5317. requires_config_enabled MBEDTLS_CAMELLIA_C
  5318. requires_config_enabled MBEDTLS_AES_C
  5319. run_test "Per-version suites: TLS 1.2" \
  5320. "$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" \
  5321. "$P_CLI force_version=tls1_2" \
  5322. 0 \
  5323. -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
  5324. # Test for ClientHello without extensions
  5325. requires_gnutls
  5326. run_test "ClientHello without extensions" \
  5327. "$P_SRV debug_level=3" \
  5328. "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
  5329. 0 \
  5330. -s "dumping 'client hello extensions' (0 bytes)"
  5331. # Tests for mbedtls_ssl_get_bytes_avail()
  5332. run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
  5333. "$P_SRV" \
  5334. "$P_CLI request_size=100" \
  5335. 0 \
  5336. -s "Read from client: 100 bytes read$"
  5337. run_test "mbedtls_ssl_get_bytes_avail: extra data" \
  5338. "$P_SRV" \
  5339. "$P_CLI request_size=500" \
  5340. 0 \
  5341. -s "Read from client: 500 bytes read (.*+.*)"
  5342. # Tests for small client packets
  5343. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  5344. run_test "Small client packet SSLv3 BlockCipher" \
  5345. "$P_SRV min_version=ssl3" \
  5346. "$P_CLI request_size=1 force_version=ssl3 \
  5347. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5348. 0 \
  5349. -s "Read from client: 1 bytes read"
  5350. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  5351. run_test "Small client packet SSLv3 StreamCipher" \
  5352. "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5353. "$P_CLI request_size=1 force_version=ssl3 \
  5354. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5355. 0 \
  5356. -s "Read from client: 1 bytes read"
  5357. run_test "Small client packet TLS 1.0 BlockCipher" \
  5358. "$P_SRV" \
  5359. "$P_CLI request_size=1 force_version=tls1 \
  5360. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5361. 0 \
  5362. -s "Read from client: 1 bytes read"
  5363. run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
  5364. "$P_SRV" \
  5365. "$P_CLI request_size=1 force_version=tls1 etm=0 \
  5366. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5367. 0 \
  5368. -s "Read from client: 1 bytes read"
  5369. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5370. run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
  5371. "$P_SRV trunc_hmac=1" \
  5372. "$P_CLI request_size=1 force_version=tls1 \
  5373. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  5374. 0 \
  5375. -s "Read from client: 1 bytes read"
  5376. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5377. run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
  5378. "$P_SRV trunc_hmac=1" \
  5379. "$P_CLI request_size=1 force_version=tls1 \
  5380. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
  5381. 0 \
  5382. -s "Read from client: 1 bytes read"
  5383. run_test "Small client packet TLS 1.0 StreamCipher" \
  5384. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5385. "$P_CLI request_size=1 force_version=tls1 \
  5386. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5387. 0 \
  5388. -s "Read from client: 1 bytes read"
  5389. run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
  5390. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5391. "$P_CLI request_size=1 force_version=tls1 \
  5392. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  5393. 0 \
  5394. -s "Read from client: 1 bytes read"
  5395. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5396. run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
  5397. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5398. "$P_CLI request_size=1 force_version=tls1 \
  5399. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5400. 0 \
  5401. -s "Read from client: 1 bytes read"
  5402. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5403. run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
  5404. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5405. "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
  5406. trunc_hmac=1 etm=0" \
  5407. 0 \
  5408. -s "Read from client: 1 bytes read"
  5409. run_test "Small client packet TLS 1.1 BlockCipher" \
  5410. "$P_SRV" \
  5411. "$P_CLI request_size=1 force_version=tls1_1 \
  5412. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5413. 0 \
  5414. -s "Read from client: 1 bytes read"
  5415. run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
  5416. "$P_SRV" \
  5417. "$P_CLI request_size=1 force_version=tls1_1 \
  5418. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
  5419. 0 \
  5420. -s "Read from client: 1 bytes read"
  5421. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5422. run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
  5423. "$P_SRV trunc_hmac=1" \
  5424. "$P_CLI request_size=1 force_version=tls1_1 \
  5425. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  5426. 0 \
  5427. -s "Read from client: 1 bytes read"
  5428. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5429. run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
  5430. "$P_SRV trunc_hmac=1" \
  5431. "$P_CLI request_size=1 force_version=tls1_1 \
  5432. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
  5433. 0 \
  5434. -s "Read from client: 1 bytes read"
  5435. run_test "Small client packet TLS 1.1 StreamCipher" \
  5436. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5437. "$P_CLI request_size=1 force_version=tls1_1 \
  5438. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5439. 0 \
  5440. -s "Read from client: 1 bytes read"
  5441. run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
  5442. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5443. "$P_CLI request_size=1 force_version=tls1_1 \
  5444. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  5445. 0 \
  5446. -s "Read from client: 1 bytes read"
  5447. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5448. run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
  5449. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5450. "$P_CLI request_size=1 force_version=tls1_1 \
  5451. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5452. 0 \
  5453. -s "Read from client: 1 bytes read"
  5454. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5455. run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
  5456. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5457. "$P_CLI request_size=1 force_version=tls1_1 \
  5458. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
  5459. 0 \
  5460. -s "Read from client: 1 bytes read"
  5461. run_test "Small client packet TLS 1.2 BlockCipher" \
  5462. "$P_SRV" \
  5463. "$P_CLI request_size=1 force_version=tls1_2 \
  5464. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5465. 0 \
  5466. -s "Read from client: 1 bytes read"
  5467. run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
  5468. "$P_SRV" \
  5469. "$P_CLI request_size=1 force_version=tls1_2 \
  5470. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
  5471. 0 \
  5472. -s "Read from client: 1 bytes read"
  5473. run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
  5474. "$P_SRV" \
  5475. "$P_CLI request_size=1 force_version=tls1_2 \
  5476. force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
  5477. 0 \
  5478. -s "Read from client: 1 bytes read"
  5479. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5480. run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
  5481. "$P_SRV trunc_hmac=1" \
  5482. "$P_CLI request_size=1 force_version=tls1_2 \
  5483. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  5484. 0 \
  5485. -s "Read from client: 1 bytes read"
  5486. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5487. run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
  5488. "$P_SRV trunc_hmac=1" \
  5489. "$P_CLI request_size=1 force_version=tls1_2 \
  5490. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
  5491. 0 \
  5492. -s "Read from client: 1 bytes read"
  5493. run_test "Small client packet TLS 1.2 StreamCipher" \
  5494. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5495. "$P_CLI request_size=1 force_version=tls1_2 \
  5496. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5497. 0 \
  5498. -s "Read from client: 1 bytes read"
  5499. run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
  5500. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5501. "$P_CLI request_size=1 force_version=tls1_2 \
  5502. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  5503. 0 \
  5504. -s "Read from client: 1 bytes read"
  5505. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5506. run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
  5507. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5508. "$P_CLI request_size=1 force_version=tls1_2 \
  5509. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5510. 0 \
  5511. -s "Read from client: 1 bytes read"
  5512. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5513. run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
  5514. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5515. "$P_CLI request_size=1 force_version=tls1_2 \
  5516. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
  5517. 0 \
  5518. -s "Read from client: 1 bytes read"
  5519. run_test "Small client packet TLS 1.2 AEAD" \
  5520. "$P_SRV" \
  5521. "$P_CLI request_size=1 force_version=tls1_2 \
  5522. force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
  5523. 0 \
  5524. -s "Read from client: 1 bytes read"
  5525. run_test "Small client packet TLS 1.2 AEAD shorter tag" \
  5526. "$P_SRV" \
  5527. "$P_CLI request_size=1 force_version=tls1_2 \
  5528. force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
  5529. 0 \
  5530. -s "Read from client: 1 bytes read"
  5531. # Tests for small client packets in DTLS
  5532. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5533. run_test "Small client packet DTLS 1.0" \
  5534. "$P_SRV dtls=1 force_version=dtls1" \
  5535. "$P_CLI dtls=1 request_size=1 \
  5536. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5537. 0 \
  5538. -s "Read from client: 1 bytes read"
  5539. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5540. run_test "Small client packet DTLS 1.0, without EtM" \
  5541. "$P_SRV dtls=1 force_version=dtls1 etm=0" \
  5542. "$P_CLI dtls=1 request_size=1 \
  5543. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5544. 0 \
  5545. -s "Read from client: 1 bytes read"
  5546. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5547. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5548. run_test "Small client packet DTLS 1.0, truncated hmac" \
  5549. "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
  5550. "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
  5551. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5552. 0 \
  5553. -s "Read from client: 1 bytes read"
  5554. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5555. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5556. run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
  5557. "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
  5558. "$P_CLI dtls=1 request_size=1 \
  5559. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
  5560. 0 \
  5561. -s "Read from client: 1 bytes read"
  5562. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5563. run_test "Small client packet DTLS 1.2" \
  5564. "$P_SRV dtls=1 force_version=dtls1_2" \
  5565. "$P_CLI dtls=1 request_size=1 \
  5566. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5567. 0 \
  5568. -s "Read from client: 1 bytes read"
  5569. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5570. run_test "Small client packet DTLS 1.2, without EtM" \
  5571. "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
  5572. "$P_CLI dtls=1 request_size=1 \
  5573. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5574. 0 \
  5575. -s "Read from client: 1 bytes read"
  5576. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5577. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5578. run_test "Small client packet DTLS 1.2, truncated hmac" \
  5579. "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
  5580. "$P_CLI dtls=1 request_size=1 \
  5581. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  5582. 0 \
  5583. -s "Read from client: 1 bytes read"
  5584. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5585. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5586. run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
  5587. "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
  5588. "$P_CLI dtls=1 request_size=1 \
  5589. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
  5590. 0 \
  5591. -s "Read from client: 1 bytes read"
  5592. # Tests for small server packets
  5593. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  5594. run_test "Small server packet SSLv3 BlockCipher" \
  5595. "$P_SRV response_size=1 min_version=ssl3" \
  5596. "$P_CLI force_version=ssl3 \
  5597. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5598. 0 \
  5599. -c "Read from server: 1 bytes read"
  5600. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  5601. run_test "Small server packet SSLv3 StreamCipher" \
  5602. "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5603. "$P_CLI force_version=ssl3 \
  5604. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5605. 0 \
  5606. -c "Read from server: 1 bytes read"
  5607. run_test "Small server packet TLS 1.0 BlockCipher" \
  5608. "$P_SRV response_size=1" \
  5609. "$P_CLI force_version=tls1 \
  5610. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5611. 0 \
  5612. -c "Read from server: 1 bytes read"
  5613. run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
  5614. "$P_SRV response_size=1" \
  5615. "$P_CLI force_version=tls1 etm=0 \
  5616. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5617. 0 \
  5618. -c "Read from server: 1 bytes read"
  5619. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5620. run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
  5621. "$P_SRV response_size=1 trunc_hmac=1" \
  5622. "$P_CLI force_version=tls1 \
  5623. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  5624. 0 \
  5625. -c "Read from server: 1 bytes read"
  5626. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5627. run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
  5628. "$P_SRV response_size=1 trunc_hmac=1" \
  5629. "$P_CLI force_version=tls1 \
  5630. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
  5631. 0 \
  5632. -c "Read from server: 1 bytes read"
  5633. run_test "Small server packet TLS 1.0 StreamCipher" \
  5634. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5635. "$P_CLI force_version=tls1 \
  5636. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5637. 0 \
  5638. -c "Read from server: 1 bytes read"
  5639. run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
  5640. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5641. "$P_CLI force_version=tls1 \
  5642. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  5643. 0 \
  5644. -c "Read from server: 1 bytes read"
  5645. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5646. run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
  5647. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5648. "$P_CLI force_version=tls1 \
  5649. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5650. 0 \
  5651. -c "Read from server: 1 bytes read"
  5652. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5653. run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
  5654. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5655. "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
  5656. trunc_hmac=1 etm=0" \
  5657. 0 \
  5658. -c "Read from server: 1 bytes read"
  5659. run_test "Small server packet TLS 1.1 BlockCipher" \
  5660. "$P_SRV response_size=1" \
  5661. "$P_CLI force_version=tls1_1 \
  5662. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5663. 0 \
  5664. -c "Read from server: 1 bytes read"
  5665. run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
  5666. "$P_SRV response_size=1" \
  5667. "$P_CLI force_version=tls1_1 \
  5668. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
  5669. 0 \
  5670. -c "Read from server: 1 bytes read"
  5671. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5672. run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
  5673. "$P_SRV response_size=1 trunc_hmac=1" \
  5674. "$P_CLI force_version=tls1_1 \
  5675. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  5676. 0 \
  5677. -c "Read from server: 1 bytes read"
  5678. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5679. run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
  5680. "$P_SRV response_size=1 trunc_hmac=1" \
  5681. "$P_CLI force_version=tls1_1 \
  5682. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
  5683. 0 \
  5684. -c "Read from server: 1 bytes read"
  5685. run_test "Small server packet TLS 1.1 StreamCipher" \
  5686. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5687. "$P_CLI force_version=tls1_1 \
  5688. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5689. 0 \
  5690. -c "Read from server: 1 bytes read"
  5691. run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
  5692. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5693. "$P_CLI force_version=tls1_1 \
  5694. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  5695. 0 \
  5696. -c "Read from server: 1 bytes read"
  5697. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5698. run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
  5699. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5700. "$P_CLI force_version=tls1_1 \
  5701. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5702. 0 \
  5703. -c "Read from server: 1 bytes read"
  5704. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5705. run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
  5706. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5707. "$P_CLI force_version=tls1_1 \
  5708. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
  5709. 0 \
  5710. -c "Read from server: 1 bytes read"
  5711. run_test "Small server packet TLS 1.2 BlockCipher" \
  5712. "$P_SRV response_size=1" \
  5713. "$P_CLI force_version=tls1_2 \
  5714. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5715. 0 \
  5716. -c "Read from server: 1 bytes read"
  5717. run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
  5718. "$P_SRV response_size=1" \
  5719. "$P_CLI force_version=tls1_2 \
  5720. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
  5721. 0 \
  5722. -c "Read from server: 1 bytes read"
  5723. run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
  5724. "$P_SRV response_size=1" \
  5725. "$P_CLI force_version=tls1_2 \
  5726. force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
  5727. 0 \
  5728. -c "Read from server: 1 bytes read"
  5729. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5730. run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
  5731. "$P_SRV response_size=1 trunc_hmac=1" \
  5732. "$P_CLI force_version=tls1_2 \
  5733. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  5734. 0 \
  5735. -c "Read from server: 1 bytes read"
  5736. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5737. run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
  5738. "$P_SRV response_size=1 trunc_hmac=1" \
  5739. "$P_CLI force_version=tls1_2 \
  5740. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
  5741. 0 \
  5742. -c "Read from server: 1 bytes read"
  5743. run_test "Small server packet TLS 1.2 StreamCipher" \
  5744. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5745. "$P_CLI force_version=tls1_2 \
  5746. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5747. 0 \
  5748. -c "Read from server: 1 bytes read"
  5749. run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
  5750. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5751. "$P_CLI force_version=tls1_2 \
  5752. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  5753. 0 \
  5754. -c "Read from server: 1 bytes read"
  5755. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5756. run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
  5757. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5758. "$P_CLI force_version=tls1_2 \
  5759. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5760. 0 \
  5761. -c "Read from server: 1 bytes read"
  5762. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5763. run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
  5764. "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5765. "$P_CLI force_version=tls1_2 \
  5766. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
  5767. 0 \
  5768. -c "Read from server: 1 bytes read"
  5769. run_test "Small server packet TLS 1.2 AEAD" \
  5770. "$P_SRV response_size=1" \
  5771. "$P_CLI force_version=tls1_2 \
  5772. force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
  5773. 0 \
  5774. -c "Read from server: 1 bytes read"
  5775. run_test "Small server packet TLS 1.2 AEAD shorter tag" \
  5776. "$P_SRV response_size=1" \
  5777. "$P_CLI force_version=tls1_2 \
  5778. force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
  5779. 0 \
  5780. -c "Read from server: 1 bytes read"
  5781. # Tests for small server packets in DTLS
  5782. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5783. run_test "Small server packet DTLS 1.0" \
  5784. "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
  5785. "$P_CLI dtls=1 \
  5786. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5787. 0 \
  5788. -c "Read from server: 1 bytes read"
  5789. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5790. run_test "Small server packet DTLS 1.0, without EtM" \
  5791. "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
  5792. "$P_CLI dtls=1 \
  5793. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5794. 0 \
  5795. -c "Read from server: 1 bytes read"
  5796. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5797. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5798. run_test "Small server packet DTLS 1.0, truncated hmac" \
  5799. "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
  5800. "$P_CLI dtls=1 trunc_hmac=1 \
  5801. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5802. 0 \
  5803. -c "Read from server: 1 bytes read"
  5804. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5805. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5806. run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
  5807. "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
  5808. "$P_CLI dtls=1 \
  5809. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
  5810. 0 \
  5811. -c "Read from server: 1 bytes read"
  5812. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5813. run_test "Small server packet DTLS 1.2" \
  5814. "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
  5815. "$P_CLI dtls=1 \
  5816. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5817. 0 \
  5818. -c "Read from server: 1 bytes read"
  5819. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5820. run_test "Small server packet DTLS 1.2, without EtM" \
  5821. "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
  5822. "$P_CLI dtls=1 \
  5823. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5824. 0 \
  5825. -c "Read from server: 1 bytes read"
  5826. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5827. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5828. run_test "Small server packet DTLS 1.2, truncated hmac" \
  5829. "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
  5830. "$P_CLI dtls=1 \
  5831. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  5832. 0 \
  5833. -c "Read from server: 1 bytes read"
  5834. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  5835. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5836. run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
  5837. "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
  5838. "$P_CLI dtls=1 \
  5839. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
  5840. 0 \
  5841. -c "Read from server: 1 bytes read"
  5842. # A test for extensions in SSLv3
  5843. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  5844. run_test "SSLv3 with extensions, server side" \
  5845. "$P_SRV min_version=ssl3 debug_level=3" \
  5846. "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
  5847. 0 \
  5848. -S "dumping 'client hello extensions'" \
  5849. -S "server hello, total extension length:"
  5850. # Test for large client packets
  5851. # How many fragments do we expect to write $1 bytes?
  5852. fragments_for_write() {
  5853. echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
  5854. }
  5855. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  5856. run_test "Large client packet SSLv3 BlockCipher" \
  5857. "$P_SRV min_version=ssl3" \
  5858. "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
  5859. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5860. 0 \
  5861. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  5862. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  5863. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  5864. run_test "Large client packet SSLv3 StreamCipher" \
  5865. "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5866. "$P_CLI request_size=16384 force_version=ssl3 \
  5867. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5868. 0 \
  5869. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  5870. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  5871. run_test "Large client packet TLS 1.0 BlockCipher" \
  5872. "$P_SRV" \
  5873. "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
  5874. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5875. 0 \
  5876. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  5877. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  5878. run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
  5879. "$P_SRV" \
  5880. "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
  5881. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5882. 0 \
  5883. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  5884. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5885. run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
  5886. "$P_SRV trunc_hmac=1" \
  5887. "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
  5888. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  5889. 0 \
  5890. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  5891. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  5892. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5893. run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
  5894. "$P_SRV trunc_hmac=1" \
  5895. "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
  5896. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  5897. 0 \
  5898. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  5899. run_test "Large client packet TLS 1.0 StreamCipher" \
  5900. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5901. "$P_CLI request_size=16384 force_version=tls1 \
  5902. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5903. 0 \
  5904. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  5905. run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
  5906. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5907. "$P_CLI request_size=16384 force_version=tls1 \
  5908. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  5909. 0 \
  5910. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  5911. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5912. run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
  5913. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5914. "$P_CLI request_size=16384 force_version=tls1 \
  5915. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5916. 0 \
  5917. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  5918. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5919. run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
  5920. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5921. "$P_CLI request_size=16384 force_version=tls1 \
  5922. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
  5923. 0 \
  5924. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  5925. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  5926. run_test "Large client packet TLS 1.1 BlockCipher" \
  5927. "$P_SRV" \
  5928. "$P_CLI request_size=16384 force_version=tls1_1 \
  5929. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5930. 0 \
  5931. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  5932. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  5933. run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
  5934. "$P_SRV" \
  5935. "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
  5936. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5937. 0 \
  5938. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  5939. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5940. run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
  5941. "$P_SRV trunc_hmac=1" \
  5942. "$P_CLI request_size=16384 force_version=tls1_1 \
  5943. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  5944. 0 \
  5945. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  5946. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5947. run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
  5948. "$P_SRV trunc_hmac=1" \
  5949. "$P_CLI request_size=16384 force_version=tls1_1 \
  5950. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
  5951. 0 \
  5952. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  5953. run_test "Large client packet TLS 1.1 StreamCipher" \
  5954. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5955. "$P_CLI request_size=16384 force_version=tls1_1 \
  5956. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5957. 0 \
  5958. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  5959. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  5960. run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
  5961. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  5962. "$P_CLI request_size=16384 force_version=tls1_1 \
  5963. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  5964. 0 \
  5965. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  5966. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  5967. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5968. run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
  5969. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5970. "$P_CLI request_size=16384 force_version=tls1_1 \
  5971. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5972. 0 \
  5973. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  5974. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  5975. run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
  5976. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  5977. "$P_CLI request_size=16384 force_version=tls1_1 \
  5978. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
  5979. 0 \
  5980. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  5981. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  5982. run_test "Large client packet TLS 1.2 BlockCipher" \
  5983. "$P_SRV" \
  5984. "$P_CLI request_size=16384 force_version=tls1_2 \
  5985. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5986. 0 \
  5987. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  5988. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  5989. run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
  5990. "$P_SRV" \
  5991. "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
  5992. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  5993. 0 \
  5994. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  5995. run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
  5996. "$P_SRV" \
  5997. "$P_CLI request_size=16384 force_version=tls1_2 \
  5998. force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
  5999. 0 \
  6000. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  6001. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6002. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6003. run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
  6004. "$P_SRV trunc_hmac=1" \
  6005. "$P_CLI request_size=16384 force_version=tls1_2 \
  6006. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
  6007. 0 \
  6008. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6009. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6010. run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
  6011. "$P_SRV trunc_hmac=1" \
  6012. "$P_CLI request_size=16384 force_version=tls1_2 \
  6013. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
  6014. 0 \
  6015. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  6016. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6017. run_test "Large client packet TLS 1.2 StreamCipher" \
  6018. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6019. "$P_CLI request_size=16384 force_version=tls1_2 \
  6020. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6021. 0 \
  6022. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  6023. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6024. run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
  6025. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6026. "$P_CLI request_size=16384 force_version=tls1_2 \
  6027. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  6028. 0 \
  6029. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6030. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6031. run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
  6032. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6033. "$P_CLI request_size=16384 force_version=tls1_2 \
  6034. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6035. 0 \
  6036. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6037. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6038. run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
  6039. "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6040. "$P_CLI request_size=16384 force_version=tls1_2 \
  6041. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
  6042. 0 \
  6043. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  6044. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6045. run_test "Large client packet TLS 1.2 AEAD" \
  6046. "$P_SRV" \
  6047. "$P_CLI request_size=16384 force_version=tls1_2 \
  6048. force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
  6049. 0 \
  6050. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  6051. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6052. run_test "Large client packet TLS 1.2 AEAD shorter tag" \
  6053. "$P_SRV" \
  6054. "$P_CLI request_size=16384 force_version=tls1_2 \
  6055. force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
  6056. 0 \
  6057. -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
  6058. -s "Read from client: $MAX_CONTENT_LEN bytes read"
  6059. # Test for large server packets
  6060. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  6061. run_test "Large server packet SSLv3 StreamCipher" \
  6062. "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6063. "$P_CLI force_version=ssl3 \
  6064. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6065. 0 \
  6066. -c "Read from server: 16384 bytes read"
  6067. # Checking next 4 tests logs for 1n-1 split against BEAST too
  6068. requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
  6069. run_test "Large server packet SSLv3 BlockCipher" \
  6070. "$P_SRV response_size=16384 min_version=ssl3" \
  6071. "$P_CLI force_version=ssl3 recsplit=0 \
  6072. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6073. 0 \
  6074. -c "Read from server: 1 bytes read"\
  6075. -c "16383 bytes read"\
  6076. -C "Read from server: 16384 bytes read"
  6077. run_test "Large server packet TLS 1.0 BlockCipher" \
  6078. "$P_SRV response_size=16384" \
  6079. "$P_CLI force_version=tls1 recsplit=0 \
  6080. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6081. 0 \
  6082. -c "Read from server: 1 bytes read"\
  6083. -c "16383 bytes read"\
  6084. -C "Read from server: 16384 bytes read"
  6085. run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
  6086. "$P_SRV response_size=16384" \
  6087. "$P_CLI force_version=tls1 etm=0 recsplit=0 \
  6088. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6089. 0 \
  6090. -c "Read from server: 1 bytes read"\
  6091. -c "16383 bytes read"\
  6092. -C "Read from server: 16384 bytes read"
  6093. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6094. run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
  6095. "$P_SRV response_size=16384" \
  6096. "$P_CLI force_version=tls1 recsplit=0 \
  6097. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
  6098. trunc_hmac=1" \
  6099. 0 \
  6100. -c "Read from server: 1 bytes read"\
  6101. -c "16383 bytes read"\
  6102. -C "Read from server: 16384 bytes read"
  6103. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6104. run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
  6105. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6106. "$P_CLI force_version=tls1 \
  6107. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
  6108. trunc_hmac=1" \
  6109. 0 \
  6110. -s "16384 bytes written in 1 fragments" \
  6111. -c "Read from server: 16384 bytes read"
  6112. run_test "Large server packet TLS 1.0 StreamCipher" \
  6113. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6114. "$P_CLI force_version=tls1 \
  6115. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6116. 0 \
  6117. -s "16384 bytes written in 1 fragments" \
  6118. -c "Read from server: 16384 bytes read"
  6119. run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
  6120. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6121. "$P_CLI force_version=tls1 \
  6122. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  6123. 0 \
  6124. -s "16384 bytes written in 1 fragments" \
  6125. -c "Read from server: 16384 bytes read"
  6126. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6127. run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
  6128. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6129. "$P_CLI force_version=tls1 \
  6130. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6131. 0 \
  6132. -s "16384 bytes written in 1 fragments" \
  6133. -c "Read from server: 16384 bytes read"
  6134. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6135. run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
  6136. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6137. "$P_CLI force_version=tls1 \
  6138. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
  6139. 0 \
  6140. -s "16384 bytes written in 1 fragments" \
  6141. -c "Read from server: 16384 bytes read"
  6142. run_test "Large server packet TLS 1.1 BlockCipher" \
  6143. "$P_SRV response_size=16384" \
  6144. "$P_CLI force_version=tls1_1 \
  6145. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6146. 0 \
  6147. -c "Read from server: 16384 bytes read"
  6148. run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
  6149. "$P_SRV response_size=16384" \
  6150. "$P_CLI force_version=tls1_1 etm=0 \
  6151. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6152. 0 \
  6153. -s "16384 bytes written in 1 fragments" \
  6154. -c "Read from server: 16384 bytes read"
  6155. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6156. run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
  6157. "$P_SRV response_size=16384" \
  6158. "$P_CLI force_version=tls1_1 \
  6159. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
  6160. trunc_hmac=1" \
  6161. 0 \
  6162. -c "Read from server: 16384 bytes read"
  6163. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6164. run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
  6165. "$P_SRV response_size=16384 trunc_hmac=1" \
  6166. "$P_CLI force_version=tls1_1 \
  6167. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
  6168. 0 \
  6169. -s "16384 bytes written in 1 fragments" \
  6170. -c "Read from server: 16384 bytes read"
  6171. run_test "Large server packet TLS 1.1 StreamCipher" \
  6172. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6173. "$P_CLI force_version=tls1_1 \
  6174. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6175. 0 \
  6176. -c "Read from server: 16384 bytes read"
  6177. run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
  6178. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6179. "$P_CLI force_version=tls1_1 \
  6180. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  6181. 0 \
  6182. -s "16384 bytes written in 1 fragments" \
  6183. -c "Read from server: 16384 bytes read"
  6184. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6185. run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
  6186. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6187. "$P_CLI force_version=tls1_1 \
  6188. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
  6189. trunc_hmac=1" \
  6190. 0 \
  6191. -c "Read from server: 16384 bytes read"
  6192. run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
  6193. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6194. "$P_CLI force_version=tls1_1 \
  6195. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
  6196. 0 \
  6197. -s "16384 bytes written in 1 fragments" \
  6198. -c "Read from server: 16384 bytes read"
  6199. run_test "Large server packet TLS 1.2 BlockCipher" \
  6200. "$P_SRV response_size=16384" \
  6201. "$P_CLI force_version=tls1_2 \
  6202. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6203. 0 \
  6204. -c "Read from server: 16384 bytes read"
  6205. run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
  6206. "$P_SRV response_size=16384" \
  6207. "$P_CLI force_version=tls1_2 etm=0 \
  6208. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
  6209. 0 \
  6210. -s "16384 bytes written in 1 fragments" \
  6211. -c "Read from server: 16384 bytes read"
  6212. run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
  6213. "$P_SRV response_size=16384" \
  6214. "$P_CLI force_version=tls1_2 \
  6215. force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
  6216. 0 \
  6217. -c "Read from server: 16384 bytes read"
  6218. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6219. run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
  6220. "$P_SRV response_size=16384" \
  6221. "$P_CLI force_version=tls1_2 \
  6222. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
  6223. trunc_hmac=1" \
  6224. 0 \
  6225. -c "Read from server: 16384 bytes read"
  6226. run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
  6227. "$P_SRV response_size=16384 trunc_hmac=1" \
  6228. "$P_CLI force_version=tls1_2 \
  6229. force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
  6230. 0 \
  6231. -s "16384 bytes written in 1 fragments" \
  6232. -c "Read from server: 16384 bytes read"
  6233. run_test "Large server packet TLS 1.2 StreamCipher" \
  6234. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6235. "$P_CLI force_version=tls1_2 \
  6236. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6237. 0 \
  6238. -s "16384 bytes written in 1 fragments" \
  6239. -c "Read from server: 16384 bytes read"
  6240. run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
  6241. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6242. "$P_CLI force_version=tls1_2 \
  6243. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
  6244. 0 \
  6245. -s "16384 bytes written in 1 fragments" \
  6246. -c "Read from server: 16384 bytes read"
  6247. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6248. run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
  6249. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
  6250. "$P_CLI force_version=tls1_2 \
  6251. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
  6252. trunc_hmac=1" \
  6253. 0 \
  6254. -c "Read from server: 16384 bytes read"
  6255. requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
  6256. run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
  6257. "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
  6258. "$P_CLI force_version=tls1_2 \
  6259. force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
  6260. 0 \
  6261. -s "16384 bytes written in 1 fragments" \
  6262. -c "Read from server: 16384 bytes read"
  6263. run_test "Large server packet TLS 1.2 AEAD" \
  6264. "$P_SRV response_size=16384" \
  6265. "$P_CLI force_version=tls1_2 \
  6266. force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
  6267. 0 \
  6268. -c "Read from server: 16384 bytes read"
  6269. run_test "Large server packet TLS 1.2 AEAD shorter tag" \
  6270. "$P_SRV response_size=16384" \
  6271. "$P_CLI force_version=tls1_2 \
  6272. force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
  6273. 0 \
  6274. -c "Read from server: 16384 bytes read"
  6275. # Tests for restartable ECC
  6276. requires_config_enabled MBEDTLS_ECP_RESTARTABLE
  6277. run_test "EC restart: TLS, default" \
  6278. "$P_SRV auth_mode=required" \
  6279. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  6280. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6281. debug_level=1" \
  6282. 0 \
  6283. -C "x509_verify_cert.*4b00" \
  6284. -C "mbedtls_pk_verify.*4b00" \
  6285. -C "mbedtls_ecdh_make_public.*4b00" \
  6286. -C "mbedtls_pk_sign.*4b00"
  6287. requires_config_enabled MBEDTLS_ECP_RESTARTABLE
  6288. run_test "EC restart: TLS, max_ops=0" \
  6289. "$P_SRV auth_mode=required" \
  6290. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  6291. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6292. debug_level=1 ec_max_ops=0" \
  6293. 0 \
  6294. -C "x509_verify_cert.*4b00" \
  6295. -C "mbedtls_pk_verify.*4b00" \
  6296. -C "mbedtls_ecdh_make_public.*4b00" \
  6297. -C "mbedtls_pk_sign.*4b00"
  6298. requires_config_enabled MBEDTLS_ECP_RESTARTABLE
  6299. run_test "EC restart: TLS, max_ops=65535" \
  6300. "$P_SRV auth_mode=required" \
  6301. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  6302. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6303. debug_level=1 ec_max_ops=65535" \
  6304. 0 \
  6305. -C "x509_verify_cert.*4b00" \
  6306. -C "mbedtls_pk_verify.*4b00" \
  6307. -C "mbedtls_ecdh_make_public.*4b00" \
  6308. -C "mbedtls_pk_sign.*4b00"
  6309. requires_config_enabled MBEDTLS_ECP_RESTARTABLE
  6310. run_test "EC restart: TLS, max_ops=1000" \
  6311. "$P_SRV auth_mode=required" \
  6312. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  6313. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6314. debug_level=1 ec_max_ops=1000" \
  6315. 0 \
  6316. -c "x509_verify_cert.*4b00" \
  6317. -c "mbedtls_pk_verify.*4b00" \
  6318. -c "mbedtls_ecdh_make_public.*4b00" \
  6319. -c "mbedtls_pk_sign.*4b00"
  6320. requires_config_enabled MBEDTLS_ECP_RESTARTABLE
  6321. run_test "EC restart: TLS, max_ops=1000, badsign" \
  6322. "$P_SRV auth_mode=required \
  6323. crt_file=data_files/server5-badsign.crt \
  6324. key_file=data_files/server5.key" \
  6325. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  6326. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6327. debug_level=1 ec_max_ops=1000" \
  6328. 1 \
  6329. -c "x509_verify_cert.*4b00" \
  6330. -C "mbedtls_pk_verify.*4b00" \
  6331. -C "mbedtls_ecdh_make_public.*4b00" \
  6332. -C "mbedtls_pk_sign.*4b00" \
  6333. -c "! The certificate is not correctly signed by the trusted CA" \
  6334. -c "! mbedtls_ssl_handshake returned" \
  6335. -c "X509 - Certificate verification failed"
  6336. requires_config_enabled MBEDTLS_ECP_RESTARTABLE
  6337. run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
  6338. "$P_SRV auth_mode=required \
  6339. crt_file=data_files/server5-badsign.crt \
  6340. key_file=data_files/server5.key" \
  6341. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  6342. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6343. debug_level=1 ec_max_ops=1000 auth_mode=optional" \
  6344. 0 \
  6345. -c "x509_verify_cert.*4b00" \
  6346. -c "mbedtls_pk_verify.*4b00" \
  6347. -c "mbedtls_ecdh_make_public.*4b00" \
  6348. -c "mbedtls_pk_sign.*4b00" \
  6349. -c "! The certificate is not correctly signed by the trusted CA" \
  6350. -C "! mbedtls_ssl_handshake returned" \
  6351. -C "X509 - Certificate verification failed"
  6352. requires_config_enabled MBEDTLS_ECP_RESTARTABLE
  6353. run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
  6354. "$P_SRV auth_mode=required \
  6355. crt_file=data_files/server5-badsign.crt \
  6356. key_file=data_files/server5.key" \
  6357. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  6358. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6359. debug_level=1 ec_max_ops=1000 auth_mode=none" \
  6360. 0 \
  6361. -C "x509_verify_cert.*4b00" \
  6362. -c "mbedtls_pk_verify.*4b00" \
  6363. -c "mbedtls_ecdh_make_public.*4b00" \
  6364. -c "mbedtls_pk_sign.*4b00" \
  6365. -C "! The certificate is not correctly signed by the trusted CA" \
  6366. -C "! mbedtls_ssl_handshake returned" \
  6367. -C "X509 - Certificate verification failed"
  6368. requires_config_enabled MBEDTLS_ECP_RESTARTABLE
  6369. run_test "EC restart: DTLS, max_ops=1000" \
  6370. "$P_SRV auth_mode=required dtls=1" \
  6371. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  6372. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6373. dtls=1 debug_level=1 ec_max_ops=1000" \
  6374. 0 \
  6375. -c "x509_verify_cert.*4b00" \
  6376. -c "mbedtls_pk_verify.*4b00" \
  6377. -c "mbedtls_ecdh_make_public.*4b00" \
  6378. -c "mbedtls_pk_sign.*4b00"
  6379. requires_config_enabled MBEDTLS_ECP_RESTARTABLE
  6380. run_test "EC restart: TLS, max_ops=1000 no client auth" \
  6381. "$P_SRV" \
  6382. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  6383. debug_level=1 ec_max_ops=1000" \
  6384. 0 \
  6385. -c "x509_verify_cert.*4b00" \
  6386. -c "mbedtls_pk_verify.*4b00" \
  6387. -c "mbedtls_ecdh_make_public.*4b00" \
  6388. -C "mbedtls_pk_sign.*4b00"
  6389. requires_config_enabled MBEDTLS_ECP_RESTARTABLE
  6390. run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
  6391. "$P_SRV psk=abc123" \
  6392. "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
  6393. psk=abc123 debug_level=1 ec_max_ops=1000" \
  6394. 0 \
  6395. -C "x509_verify_cert.*4b00" \
  6396. -C "mbedtls_pk_verify.*4b00" \
  6397. -C "mbedtls_ecdh_make_public.*4b00" \
  6398. -C "mbedtls_pk_sign.*4b00"
  6399. # Tests of asynchronous private key support in SSL
  6400. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6401. run_test "SSL async private: sign, delay=0" \
  6402. "$P_SRV \
  6403. async_operations=s async_private_delay1=0 async_private_delay2=0" \
  6404. "$P_CLI" \
  6405. 0 \
  6406. -s "Async sign callback: using key slot " \
  6407. -s "Async resume (slot [0-9]): sign done, status=0"
  6408. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6409. run_test "SSL async private: sign, delay=1" \
  6410. "$P_SRV \
  6411. async_operations=s async_private_delay1=1 async_private_delay2=1" \
  6412. "$P_CLI" \
  6413. 0 \
  6414. -s "Async sign callback: using key slot " \
  6415. -s "Async resume (slot [0-9]): call 0 more times." \
  6416. -s "Async resume (slot [0-9]): sign done, status=0"
  6417. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6418. run_test "SSL async private: sign, delay=2" \
  6419. "$P_SRV \
  6420. async_operations=s async_private_delay1=2 async_private_delay2=2" \
  6421. "$P_CLI" \
  6422. 0 \
  6423. -s "Async sign callback: using key slot " \
  6424. -U "Async sign callback: using key slot " \
  6425. -s "Async resume (slot [0-9]): call 1 more times." \
  6426. -s "Async resume (slot [0-9]): call 0 more times." \
  6427. -s "Async resume (slot [0-9]): sign done, status=0"
  6428. # Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
  6429. # with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
  6430. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6431. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
  6432. run_test "SSL async private: sign, RSA, TLS 1.1" \
  6433. "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
  6434. async_operations=s async_private_delay1=0 async_private_delay2=0" \
  6435. "$P_CLI force_version=tls1_1" \
  6436. 0 \
  6437. -s "Async sign callback: using key slot " \
  6438. -s "Async resume (slot [0-9]): sign done, status=0"
  6439. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6440. run_test "SSL async private: sign, SNI" \
  6441. "$P_SRV debug_level=3 \
  6442. async_operations=s async_private_delay1=0 async_private_delay2=0 \
  6443. crt_file=data_files/server5.crt key_file=data_files/server5.key \
  6444. sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
  6445. "$P_CLI server_name=polarssl.example" \
  6446. 0 \
  6447. -s "Async sign callback: using key slot " \
  6448. -s "Async resume (slot [0-9]): sign done, status=0" \
  6449. -s "parse ServerName extension" \
  6450. -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
  6451. -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
  6452. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6453. run_test "SSL async private: decrypt, delay=0" \
  6454. "$P_SRV \
  6455. async_operations=d async_private_delay1=0 async_private_delay2=0" \
  6456. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  6457. 0 \
  6458. -s "Async decrypt callback: using key slot " \
  6459. -s "Async resume (slot [0-9]): decrypt done, status=0"
  6460. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6461. run_test "SSL async private: decrypt, delay=1" \
  6462. "$P_SRV \
  6463. async_operations=d async_private_delay1=1 async_private_delay2=1" \
  6464. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  6465. 0 \
  6466. -s "Async decrypt callback: using key slot " \
  6467. -s "Async resume (slot [0-9]): call 0 more times." \
  6468. -s "Async resume (slot [0-9]): decrypt done, status=0"
  6469. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6470. run_test "SSL async private: decrypt RSA-PSK, delay=0" \
  6471. "$P_SRV psk=abc123 \
  6472. async_operations=d async_private_delay1=0 async_private_delay2=0" \
  6473. "$P_CLI psk=abc123 \
  6474. force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
  6475. 0 \
  6476. -s "Async decrypt callback: using key slot " \
  6477. -s "Async resume (slot [0-9]): decrypt done, status=0"
  6478. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6479. run_test "SSL async private: decrypt RSA-PSK, delay=1" \
  6480. "$P_SRV psk=abc123 \
  6481. async_operations=d async_private_delay1=1 async_private_delay2=1" \
  6482. "$P_CLI psk=abc123 \
  6483. force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
  6484. 0 \
  6485. -s "Async decrypt callback: using key slot " \
  6486. -s "Async resume (slot [0-9]): call 0 more times." \
  6487. -s "Async resume (slot [0-9]): decrypt done, status=0"
  6488. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6489. run_test "SSL async private: sign callback not present" \
  6490. "$P_SRV \
  6491. async_operations=d async_private_delay1=1 async_private_delay2=1" \
  6492. "$P_CLI; [ \$? -eq 1 ] &&
  6493. $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  6494. 0 \
  6495. -S "Async sign callback" \
  6496. -s "! mbedtls_ssl_handshake returned" \
  6497. -s "The own private key or pre-shared key is not set, but needed" \
  6498. -s "Async resume (slot [0-9]): decrypt done, status=0" \
  6499. -s "Successful connection"
  6500. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6501. run_test "SSL async private: decrypt callback not present" \
  6502. "$P_SRV debug_level=1 \
  6503. async_operations=s async_private_delay1=1 async_private_delay2=1" \
  6504. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
  6505. [ \$? -eq 1 ] && $P_CLI" \
  6506. 0 \
  6507. -S "Async decrypt callback" \
  6508. -s "! mbedtls_ssl_handshake returned" \
  6509. -s "got no RSA private key" \
  6510. -s "Async resume (slot [0-9]): sign done, status=0" \
  6511. -s "Successful connection"
  6512. # key1: ECDSA, key2: RSA; use key1 from slot 0
  6513. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6514. run_test "SSL async private: slot 0 used with key1" \
  6515. "$P_SRV \
  6516. async_operations=s async_private_delay1=1 \
  6517. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6518. key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
  6519. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
  6520. 0 \
  6521. -s "Async sign callback: using key slot 0," \
  6522. -s "Async resume (slot 0): call 0 more times." \
  6523. -s "Async resume (slot 0): sign done, status=0"
  6524. # key1: ECDSA, key2: RSA; use key2 from slot 0
  6525. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6526. run_test "SSL async private: slot 0 used with key2" \
  6527. "$P_SRV \
  6528. async_operations=s async_private_delay2=1 \
  6529. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6530. key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
  6531. "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
  6532. 0 \
  6533. -s "Async sign callback: using key slot 0," \
  6534. -s "Async resume (slot 0): call 0 more times." \
  6535. -s "Async resume (slot 0): sign done, status=0"
  6536. # key1: ECDSA, key2: RSA; use key2 from slot 1
  6537. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6538. run_test "SSL async private: slot 1 used with key2" \
  6539. "$P_SRV \
  6540. async_operations=s async_private_delay1=1 async_private_delay2=1 \
  6541. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6542. key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
  6543. "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
  6544. 0 \
  6545. -s "Async sign callback: using key slot 1," \
  6546. -s "Async resume (slot 1): call 0 more times." \
  6547. -s "Async resume (slot 1): sign done, status=0"
  6548. # key1: ECDSA, key2: RSA; use key2 directly
  6549. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6550. run_test "SSL async private: fall back to transparent key" \
  6551. "$P_SRV \
  6552. async_operations=s async_private_delay1=1 \
  6553. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6554. key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
  6555. "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
  6556. 0 \
  6557. -s "Async sign callback: no key matches this certificate."
  6558. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6559. run_test "SSL async private: sign, error in start" \
  6560. "$P_SRV \
  6561. async_operations=s async_private_delay1=1 async_private_delay2=1 \
  6562. async_private_error=1" \
  6563. "$P_CLI" \
  6564. 1 \
  6565. -s "Async sign callback: injected error" \
  6566. -S "Async resume" \
  6567. -S "Async cancel" \
  6568. -s "! mbedtls_ssl_handshake returned"
  6569. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6570. run_test "SSL async private: sign, cancel after start" \
  6571. "$P_SRV \
  6572. async_operations=s async_private_delay1=1 async_private_delay2=1 \
  6573. async_private_error=2" \
  6574. "$P_CLI" \
  6575. 1 \
  6576. -s "Async sign callback: using key slot " \
  6577. -S "Async resume" \
  6578. -s "Async cancel"
  6579. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6580. run_test "SSL async private: sign, error in resume" \
  6581. "$P_SRV \
  6582. async_operations=s async_private_delay1=1 async_private_delay2=1 \
  6583. async_private_error=3" \
  6584. "$P_CLI" \
  6585. 1 \
  6586. -s "Async sign callback: using key slot " \
  6587. -s "Async resume callback: sign done but injected error" \
  6588. -S "Async cancel" \
  6589. -s "! mbedtls_ssl_handshake returned"
  6590. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6591. run_test "SSL async private: decrypt, error in start" \
  6592. "$P_SRV \
  6593. async_operations=d async_private_delay1=1 async_private_delay2=1 \
  6594. async_private_error=1" \
  6595. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  6596. 1 \
  6597. -s "Async decrypt callback: injected error" \
  6598. -S "Async resume" \
  6599. -S "Async cancel" \
  6600. -s "! mbedtls_ssl_handshake returned"
  6601. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6602. run_test "SSL async private: decrypt, cancel after start" \
  6603. "$P_SRV \
  6604. async_operations=d async_private_delay1=1 async_private_delay2=1 \
  6605. async_private_error=2" \
  6606. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  6607. 1 \
  6608. -s "Async decrypt callback: using key slot " \
  6609. -S "Async resume" \
  6610. -s "Async cancel"
  6611. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6612. run_test "SSL async private: decrypt, error in resume" \
  6613. "$P_SRV \
  6614. async_operations=d async_private_delay1=1 async_private_delay2=1 \
  6615. async_private_error=3" \
  6616. "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  6617. 1 \
  6618. -s "Async decrypt callback: using key slot " \
  6619. -s "Async resume callback: decrypt done but injected error" \
  6620. -S "Async cancel" \
  6621. -s "! mbedtls_ssl_handshake returned"
  6622. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6623. run_test "SSL async private: cancel after start then operate correctly" \
  6624. "$P_SRV \
  6625. async_operations=s async_private_delay1=1 async_private_delay2=1 \
  6626. async_private_error=-2" \
  6627. "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
  6628. 0 \
  6629. -s "Async cancel" \
  6630. -s "! mbedtls_ssl_handshake returned" \
  6631. -s "Async resume" \
  6632. -s "Successful connection"
  6633. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6634. run_test "SSL async private: error in resume then operate correctly" \
  6635. "$P_SRV \
  6636. async_operations=s async_private_delay1=1 async_private_delay2=1 \
  6637. async_private_error=-3" \
  6638. "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
  6639. 0 \
  6640. -s "! mbedtls_ssl_handshake returned" \
  6641. -s "Async resume" \
  6642. -s "Successful connection"
  6643. # key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
  6644. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6645. run_test "SSL async private: cancel after start then fall back to transparent key" \
  6646. "$P_SRV \
  6647. async_operations=s async_private_delay1=1 async_private_error=-2 \
  6648. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6649. key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
  6650. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
  6651. [ \$? -eq 1 ] &&
  6652. $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
  6653. 0 \
  6654. -s "Async sign callback: using key slot 0" \
  6655. -S "Async resume" \
  6656. -s "Async cancel" \
  6657. -s "! mbedtls_ssl_handshake returned" \
  6658. -s "Async sign callback: no key matches this certificate." \
  6659. -s "Successful connection"
  6660. # key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
  6661. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6662. run_test "SSL async private: sign, error in resume then fall back to transparent key" \
  6663. "$P_SRV \
  6664. async_operations=s async_private_delay1=1 async_private_error=-3 \
  6665. key_file=data_files/server5.key crt_file=data_files/server5.crt \
  6666. key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
  6667. "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
  6668. [ \$? -eq 1 ] &&
  6669. $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
  6670. 0 \
  6671. -s "Async resume" \
  6672. -s "! mbedtls_ssl_handshake returned" \
  6673. -s "Async sign callback: no key matches this certificate." \
  6674. -s "Successful connection"
  6675. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6676. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  6677. run_test "SSL async private: renegotiation: client-initiated, sign" \
  6678. "$P_SRV \
  6679. async_operations=s async_private_delay1=1 async_private_delay2=1 \
  6680. exchanges=2 renegotiation=1" \
  6681. "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
  6682. 0 \
  6683. -s "Async sign callback: using key slot " \
  6684. -s "Async resume (slot [0-9]): sign done, status=0"
  6685. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6686. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  6687. run_test "SSL async private: renegotiation: server-initiated, sign" \
  6688. "$P_SRV \
  6689. async_operations=s async_private_delay1=1 async_private_delay2=1 \
  6690. exchanges=2 renegotiation=1 renegotiate=1" \
  6691. "$P_CLI exchanges=2 renegotiation=1" \
  6692. 0 \
  6693. -s "Async sign callback: using key slot " \
  6694. -s "Async resume (slot [0-9]): sign done, status=0"
  6695. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6696. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  6697. run_test "SSL async private: renegotiation: client-initiated, decrypt" \
  6698. "$P_SRV \
  6699. async_operations=d async_private_delay1=1 async_private_delay2=1 \
  6700. exchanges=2 renegotiation=1" \
  6701. "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
  6702. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  6703. 0 \
  6704. -s "Async decrypt callback: using key slot " \
  6705. -s "Async resume (slot [0-9]): decrypt done, status=0"
  6706. requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
  6707. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  6708. run_test "SSL async private: renegotiation: server-initiated, decrypt" \
  6709. "$P_SRV \
  6710. async_operations=d async_private_delay1=1 async_private_delay2=1 \
  6711. exchanges=2 renegotiation=1 renegotiate=1" \
  6712. "$P_CLI exchanges=2 renegotiation=1 \
  6713. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  6714. 0 \
  6715. -s "Async decrypt callback: using key slot " \
  6716. -s "Async resume (slot [0-9]): decrypt done, status=0"
  6717. # Tests for ECC extensions (rfc 4492)
  6718. requires_config_enabled MBEDTLS_AES_C
  6719. requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
  6720. requires_config_enabled MBEDTLS_SHA256_C
  6721. requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
  6722. run_test "Force a non ECC ciphersuite in the client side" \
  6723. "$P_SRV debug_level=3" \
  6724. "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
  6725. 0 \
  6726. -C "client hello, adding supported_elliptic_curves extension" \
  6727. -C "client hello, adding supported_point_formats extension" \
  6728. -S "found supported elliptic curves extension" \
  6729. -S "found supported point formats extension"
  6730. requires_config_enabled MBEDTLS_AES_C
  6731. requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
  6732. requires_config_enabled MBEDTLS_SHA256_C
  6733. requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
  6734. run_test "Force a non ECC ciphersuite in the server side" \
  6735. "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
  6736. "$P_CLI debug_level=3" \
  6737. 0 \
  6738. -C "found supported_point_formats extension" \
  6739. -S "server hello, supported_point_formats extension"
  6740. requires_config_enabled MBEDTLS_AES_C
  6741. requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
  6742. requires_config_enabled MBEDTLS_SHA256_C
  6743. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
  6744. run_test "Force an ECC ciphersuite in the client side" \
  6745. "$P_SRV debug_level=3" \
  6746. "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
  6747. 0 \
  6748. -c "client hello, adding supported_elliptic_curves extension" \
  6749. -c "client hello, adding supported_point_formats extension" \
  6750. -s "found supported elliptic curves extension" \
  6751. -s "found supported point formats extension"
  6752. requires_config_enabled MBEDTLS_AES_C
  6753. requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
  6754. requires_config_enabled MBEDTLS_SHA256_C
  6755. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
  6756. run_test "Force an ECC ciphersuite in the server side" \
  6757. "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
  6758. "$P_CLI debug_level=3" \
  6759. 0 \
  6760. -c "found supported_point_formats extension" \
  6761. -s "server hello, supported_point_formats extension"
  6762. # Tests for DTLS HelloVerifyRequest
  6763. run_test "DTLS cookie: enabled" \
  6764. "$P_SRV dtls=1 debug_level=2" \
  6765. "$P_CLI dtls=1 debug_level=2" \
  6766. 0 \
  6767. -s "cookie verification failed" \
  6768. -s "cookie verification passed" \
  6769. -S "cookie verification skipped" \
  6770. -c "received hello verify request" \
  6771. -s "hello verification requested" \
  6772. -S "SSL - The requested feature is not available"
  6773. run_test "DTLS cookie: disabled" \
  6774. "$P_SRV dtls=1 debug_level=2 cookies=0" \
  6775. "$P_CLI dtls=1 debug_level=2" \
  6776. 0 \
  6777. -S "cookie verification failed" \
  6778. -S "cookie verification passed" \
  6779. -s "cookie verification skipped" \
  6780. -C "received hello verify request" \
  6781. -S "hello verification requested" \
  6782. -S "SSL - The requested feature is not available"
  6783. run_test "DTLS cookie: default (failing)" \
  6784. "$P_SRV dtls=1 debug_level=2 cookies=-1" \
  6785. "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
  6786. 1 \
  6787. -s "cookie verification failed" \
  6788. -S "cookie verification passed" \
  6789. -S "cookie verification skipped" \
  6790. -C "received hello verify request" \
  6791. -S "hello verification requested" \
  6792. -s "SSL - The requested feature is not available"
  6793. requires_ipv6
  6794. run_test "DTLS cookie: enabled, IPv6" \
  6795. "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
  6796. "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
  6797. 0 \
  6798. -s "cookie verification failed" \
  6799. -s "cookie verification passed" \
  6800. -S "cookie verification skipped" \
  6801. -c "received hello verify request" \
  6802. -s "hello verification requested" \
  6803. -S "SSL - The requested feature is not available"
  6804. run_test "DTLS cookie: enabled, nbio" \
  6805. "$P_SRV dtls=1 nbio=2 debug_level=2" \
  6806. "$P_CLI dtls=1 nbio=2 debug_level=2" \
  6807. 0 \
  6808. -s "cookie verification failed" \
  6809. -s "cookie verification passed" \
  6810. -S "cookie verification skipped" \
  6811. -c "received hello verify request" \
  6812. -s "hello verification requested" \
  6813. -S "SSL - The requested feature is not available"
  6814. # Tests for client reconnecting from the same port with DTLS
  6815. not_with_valgrind # spurious resend
  6816. run_test "DTLS client reconnect from same port: reference" \
  6817. "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
  6818. "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
  6819. 0 \
  6820. -C "resend" \
  6821. -S "The operation timed out" \
  6822. -S "Client initiated reconnection from same port"
  6823. not_with_valgrind # spurious resend
  6824. run_test "DTLS client reconnect from same port: reconnect" \
  6825. "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
  6826. "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000 reconnect_hard=1" \
  6827. 0 \
  6828. -C "resend" \
  6829. -S "The operation timed out" \
  6830. -s "Client initiated reconnection from same port"
  6831. not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
  6832. run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
  6833. "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
  6834. "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000 reconnect_hard=1" \
  6835. 0 \
  6836. -S "The operation timed out" \
  6837. -s "Client initiated reconnection from same port"
  6838. only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
  6839. run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
  6840. "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
  6841. "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
  6842. 0 \
  6843. -S "The operation timed out" \
  6844. -s "Client initiated reconnection from same port"
  6845. run_test "DTLS client reconnect from same port: no cookies" \
  6846. "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
  6847. "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
  6848. 0 \
  6849. -s "The operation timed out" \
  6850. -S "Client initiated reconnection from same port"
  6851. run_test "DTLS client reconnect from same port: attacker-injected" \
  6852. -p "$P_PXY inject_clihlo=1" \
  6853. "$P_SRV dtls=1 exchanges=2 debug_level=1" \
  6854. "$P_CLI dtls=1 exchanges=2" \
  6855. 0 \
  6856. -s "possible client reconnect from the same port" \
  6857. -S "Client initiated reconnection from same port"
  6858. # Tests for various cases of client authentication with DTLS
  6859. # (focused on handshake flows and message parsing)
  6860. run_test "DTLS client auth: required" \
  6861. "$P_SRV dtls=1 auth_mode=required" \
  6862. "$P_CLI dtls=1" \
  6863. 0 \
  6864. -s "Verifying peer X.509 certificate... ok"
  6865. run_test "DTLS client auth: optional, client has no cert" \
  6866. "$P_SRV dtls=1 auth_mode=optional" \
  6867. "$P_CLI dtls=1 crt_file=none key_file=none" \
  6868. 0 \
  6869. -s "! Certificate was missing"
  6870. run_test "DTLS client auth: none, client has no cert" \
  6871. "$P_SRV dtls=1 auth_mode=none" \
  6872. "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
  6873. 0 \
  6874. -c "skip write certificate$" \
  6875. -s "! Certificate verification was skipped"
  6876. run_test "DTLS wrong PSK: badmac alert" \
  6877. "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
  6878. "$P_CLI dtls=1 psk=abc124" \
  6879. 1 \
  6880. -s "SSL - Verification of the message MAC failed" \
  6881. -c "SSL - A fatal alert message was received from our peer"
  6882. # Tests for receiving fragmented handshake messages with DTLS
  6883. requires_gnutls
  6884. run_test "DTLS reassembly: no fragmentation (gnutls server)" \
  6885. "$G_SRV -u --mtu 2048 -a" \
  6886. "$P_CLI dtls=1 debug_level=2" \
  6887. 0 \
  6888. -C "found fragmented DTLS handshake message" \
  6889. -C "error"
  6890. requires_gnutls
  6891. run_test "DTLS reassembly: some fragmentation (gnutls server)" \
  6892. "$G_SRV -u --mtu 512" \
  6893. "$P_CLI dtls=1 debug_level=2" \
  6894. 0 \
  6895. -c "found fragmented DTLS handshake message" \
  6896. -C "error"
  6897. requires_gnutls
  6898. run_test "DTLS reassembly: more fragmentation (gnutls server)" \
  6899. "$G_SRV -u --mtu 128" \
  6900. "$P_CLI dtls=1 debug_level=2" \
  6901. 0 \
  6902. -c "found fragmented DTLS handshake message" \
  6903. -C "error"
  6904. requires_gnutls
  6905. run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
  6906. "$G_SRV -u --mtu 128" \
  6907. "$P_CLI dtls=1 nbio=2 debug_level=2" \
  6908. 0 \
  6909. -c "found fragmented DTLS handshake message" \
  6910. -C "error"
  6911. requires_gnutls
  6912. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  6913. run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
  6914. "$G_SRV -u --mtu 256" \
  6915. "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
  6916. 0 \
  6917. -c "found fragmented DTLS handshake message" \
  6918. -c "client hello, adding renegotiation extension" \
  6919. -c "found renegotiation extension" \
  6920. -c "=> renegotiate" \
  6921. -C "mbedtls_ssl_handshake returned" \
  6922. -C "error" \
  6923. -s "Extra-header:"
  6924. requires_gnutls
  6925. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  6926. run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
  6927. "$G_SRV -u --mtu 256" \
  6928. "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
  6929. 0 \
  6930. -c "found fragmented DTLS handshake message" \
  6931. -c "client hello, adding renegotiation extension" \
  6932. -c "found renegotiation extension" \
  6933. -c "=> renegotiate" \
  6934. -C "mbedtls_ssl_handshake returned" \
  6935. -C "error" \
  6936. -s "Extra-header:"
  6937. run_test "DTLS reassembly: no fragmentation (openssl server)" \
  6938. "$O_SRV -dtls1 -mtu 2048" \
  6939. "$P_CLI dtls=1 debug_level=2" \
  6940. 0 \
  6941. -C "found fragmented DTLS handshake message" \
  6942. -C "error"
  6943. run_test "DTLS reassembly: some fragmentation (openssl server)" \
  6944. "$O_SRV -dtls1 -mtu 768" \
  6945. "$P_CLI dtls=1 debug_level=2" \
  6946. 0 \
  6947. -c "found fragmented DTLS handshake message" \
  6948. -C "error"
  6949. run_test "DTLS reassembly: more fragmentation (openssl server)" \
  6950. "$O_SRV -dtls1 -mtu 256" \
  6951. "$P_CLI dtls=1 debug_level=2" \
  6952. 0 \
  6953. -c "found fragmented DTLS handshake message" \
  6954. -C "error"
  6955. run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
  6956. "$O_SRV -dtls1 -mtu 256" \
  6957. "$P_CLI dtls=1 nbio=2 debug_level=2" \
  6958. 0 \
  6959. -c "found fragmented DTLS handshake message" \
  6960. -C "error"
  6961. # Tests for sending fragmented handshake messages with DTLS
  6962. #
  6963. # Use client auth when we need the client to send large messages,
  6964. # and use large cert chains on both sides too (the long chains we have all use
  6965. # both RSA and ECDSA, but ideally we should have long chains with either).
  6966. # Sizes reached (UDP payload):
  6967. # - 2037B for server certificate
  6968. # - 1542B for client certificate
  6969. # - 1013B for newsessionticket
  6970. # - all others below 512B
  6971. # All those tests assume MAX_CONTENT_LEN is at least 2048
  6972. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  6973. requires_config_enabled MBEDTLS_RSA_C
  6974. requires_config_enabled MBEDTLS_ECDSA_C
  6975. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  6976. run_test "DTLS fragmenting: none (for reference)" \
  6977. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  6978. crt_file=data_files/server7_int-ca.crt \
  6979. key_file=data_files/server7.key \
  6980. hs_timeout=2500-60000 \
  6981. max_frag_len=4096" \
  6982. "$P_CLI dtls=1 debug_level=2 \
  6983. crt_file=data_files/server8_int-ca2.crt \
  6984. key_file=data_files/server8.key \
  6985. hs_timeout=2500-60000 \
  6986. max_frag_len=4096" \
  6987. 0 \
  6988. -S "found fragmented DTLS handshake message" \
  6989. -C "found fragmented DTLS handshake message" \
  6990. -C "error"
  6991. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  6992. requires_config_enabled MBEDTLS_RSA_C
  6993. requires_config_enabled MBEDTLS_ECDSA_C
  6994. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  6995. run_test "DTLS fragmenting: server only (max_frag_len)" \
  6996. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  6997. crt_file=data_files/server7_int-ca.crt \
  6998. key_file=data_files/server7.key \
  6999. hs_timeout=2500-60000 \
  7000. max_frag_len=1024" \
  7001. "$P_CLI dtls=1 debug_level=2 \
  7002. crt_file=data_files/server8_int-ca2.crt \
  7003. key_file=data_files/server8.key \
  7004. hs_timeout=2500-60000 \
  7005. max_frag_len=2048" \
  7006. 0 \
  7007. -S "found fragmented DTLS handshake message" \
  7008. -c "found fragmented DTLS handshake message" \
  7009. -C "error"
  7010. # With the MFL extension, the server has no way of forcing
  7011. # the client to not exceed a certain MTU; hence, the following
  7012. # test can't be replicated with an MTU proxy such as the one
  7013. # `client-initiated, server only (max_frag_len)` below.
  7014. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7015. requires_config_enabled MBEDTLS_RSA_C
  7016. requires_config_enabled MBEDTLS_ECDSA_C
  7017. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  7018. run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
  7019. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7020. crt_file=data_files/server7_int-ca.crt \
  7021. key_file=data_files/server7.key \
  7022. hs_timeout=2500-60000 \
  7023. max_frag_len=512" \
  7024. "$P_CLI dtls=1 debug_level=2 \
  7025. crt_file=data_files/server8_int-ca2.crt \
  7026. key_file=data_files/server8.key \
  7027. hs_timeout=2500-60000 \
  7028. max_frag_len=4096" \
  7029. 0 \
  7030. -S "found fragmented DTLS handshake message" \
  7031. -c "found fragmented DTLS handshake message" \
  7032. -C "error"
  7033. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7034. requires_config_enabled MBEDTLS_RSA_C
  7035. requires_config_enabled MBEDTLS_ECDSA_C
  7036. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  7037. run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
  7038. "$P_SRV dtls=1 debug_level=2 auth_mode=none \
  7039. crt_file=data_files/server7_int-ca.crt \
  7040. key_file=data_files/server7.key \
  7041. hs_timeout=2500-60000 \
  7042. max_frag_len=2048" \
  7043. "$P_CLI dtls=1 debug_level=2 \
  7044. crt_file=data_files/server8_int-ca2.crt \
  7045. key_file=data_files/server8.key \
  7046. hs_timeout=2500-60000 \
  7047. max_frag_len=1024" \
  7048. 0 \
  7049. -S "found fragmented DTLS handshake message" \
  7050. -c "found fragmented DTLS handshake message" \
  7051. -C "error"
  7052. # While not required by the standard defining the MFL extension
  7053. # (according to which it only applies to records, not to datagrams),
  7054. # Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
  7055. # as otherwise there wouldn't be any means to communicate MTU restrictions
  7056. # to the peer.
  7057. # The next test checks that no datagrams significantly larger than the
  7058. # negotiated MFL are sent.
  7059. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7060. requires_config_enabled MBEDTLS_RSA_C
  7061. requires_config_enabled MBEDTLS_ECDSA_C
  7062. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  7063. run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
  7064. -p "$P_PXY mtu=1110" \
  7065. "$P_SRV dtls=1 debug_level=2 auth_mode=none \
  7066. crt_file=data_files/server7_int-ca.crt \
  7067. key_file=data_files/server7.key \
  7068. hs_timeout=2500-60000 \
  7069. max_frag_len=2048" \
  7070. "$P_CLI dtls=1 debug_level=2 \
  7071. crt_file=data_files/server8_int-ca2.crt \
  7072. key_file=data_files/server8.key \
  7073. hs_timeout=2500-60000 \
  7074. max_frag_len=1024" \
  7075. 0 \
  7076. -S "found fragmented DTLS handshake message" \
  7077. -c "found fragmented DTLS handshake message" \
  7078. -C "error"
  7079. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7080. requires_config_enabled MBEDTLS_RSA_C
  7081. requires_config_enabled MBEDTLS_ECDSA_C
  7082. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  7083. run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
  7084. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7085. crt_file=data_files/server7_int-ca.crt \
  7086. key_file=data_files/server7.key \
  7087. hs_timeout=2500-60000 \
  7088. max_frag_len=2048" \
  7089. "$P_CLI dtls=1 debug_level=2 \
  7090. crt_file=data_files/server8_int-ca2.crt \
  7091. key_file=data_files/server8.key \
  7092. hs_timeout=2500-60000 \
  7093. max_frag_len=1024" \
  7094. 0 \
  7095. -s "found fragmented DTLS handshake message" \
  7096. -c "found fragmented DTLS handshake message" \
  7097. -C "error"
  7098. # While not required by the standard defining the MFL extension
  7099. # (according to which it only applies to records, not to datagrams),
  7100. # Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
  7101. # as otherwise there wouldn't be any means to communicate MTU restrictions
  7102. # to the peer.
  7103. # The next test checks that no datagrams significantly larger than the
  7104. # negotiated MFL are sent.
  7105. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7106. requires_config_enabled MBEDTLS_RSA_C
  7107. requires_config_enabled MBEDTLS_ECDSA_C
  7108. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  7109. run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
  7110. -p "$P_PXY mtu=1110" \
  7111. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7112. crt_file=data_files/server7_int-ca.crt \
  7113. key_file=data_files/server7.key \
  7114. hs_timeout=2500-60000 \
  7115. max_frag_len=2048" \
  7116. "$P_CLI dtls=1 debug_level=2 \
  7117. crt_file=data_files/server8_int-ca2.crt \
  7118. key_file=data_files/server8.key \
  7119. hs_timeout=2500-60000 \
  7120. max_frag_len=1024" \
  7121. 0 \
  7122. -s "found fragmented DTLS handshake message" \
  7123. -c "found fragmented DTLS handshake message" \
  7124. -C "error"
  7125. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7126. requires_config_enabled MBEDTLS_RSA_C
  7127. requires_config_enabled MBEDTLS_ECDSA_C
  7128. run_test "DTLS fragmenting: none (for reference) (MTU)" \
  7129. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7130. crt_file=data_files/server7_int-ca.crt \
  7131. key_file=data_files/server7.key \
  7132. hs_timeout=2500-60000 \
  7133. mtu=4096" \
  7134. "$P_CLI dtls=1 debug_level=2 \
  7135. crt_file=data_files/server8_int-ca2.crt \
  7136. key_file=data_files/server8.key \
  7137. hs_timeout=2500-60000 \
  7138. mtu=4096" \
  7139. 0 \
  7140. -S "found fragmented DTLS handshake message" \
  7141. -C "found fragmented DTLS handshake message" \
  7142. -C "error"
  7143. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7144. requires_config_enabled MBEDTLS_RSA_C
  7145. requires_config_enabled MBEDTLS_ECDSA_C
  7146. run_test "DTLS fragmenting: client (MTU)" \
  7147. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7148. crt_file=data_files/server7_int-ca.crt \
  7149. key_file=data_files/server7.key \
  7150. hs_timeout=3500-60000 \
  7151. mtu=4096" \
  7152. "$P_CLI dtls=1 debug_level=2 \
  7153. crt_file=data_files/server8_int-ca2.crt \
  7154. key_file=data_files/server8.key \
  7155. hs_timeout=3500-60000 \
  7156. mtu=1024" \
  7157. 0 \
  7158. -s "found fragmented DTLS handshake message" \
  7159. -C "found fragmented DTLS handshake message" \
  7160. -C "error"
  7161. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7162. requires_config_enabled MBEDTLS_RSA_C
  7163. requires_config_enabled MBEDTLS_ECDSA_C
  7164. run_test "DTLS fragmenting: server (MTU)" \
  7165. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7166. crt_file=data_files/server7_int-ca.crt \
  7167. key_file=data_files/server7.key \
  7168. hs_timeout=2500-60000 \
  7169. mtu=512" \
  7170. "$P_CLI dtls=1 debug_level=2 \
  7171. crt_file=data_files/server8_int-ca2.crt \
  7172. key_file=data_files/server8.key \
  7173. hs_timeout=2500-60000 \
  7174. mtu=2048" \
  7175. 0 \
  7176. -S "found fragmented DTLS handshake message" \
  7177. -c "found fragmented DTLS handshake message" \
  7178. -C "error"
  7179. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7180. requires_config_enabled MBEDTLS_RSA_C
  7181. requires_config_enabled MBEDTLS_ECDSA_C
  7182. run_test "DTLS fragmenting: both (MTU=1024)" \
  7183. -p "$P_PXY mtu=1024" \
  7184. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7185. crt_file=data_files/server7_int-ca.crt \
  7186. key_file=data_files/server7.key \
  7187. hs_timeout=2500-60000 \
  7188. mtu=1024" \
  7189. "$P_CLI dtls=1 debug_level=2 \
  7190. crt_file=data_files/server8_int-ca2.crt \
  7191. key_file=data_files/server8.key \
  7192. hs_timeout=2500-60000 \
  7193. mtu=1024" \
  7194. 0 \
  7195. -s "found fragmented DTLS handshake message" \
  7196. -c "found fragmented DTLS handshake message" \
  7197. -C "error"
  7198. # Forcing ciphersuite for this test to fit the MTU of 512 with full config.
  7199. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7200. requires_config_enabled MBEDTLS_RSA_C
  7201. requires_config_enabled MBEDTLS_ECDSA_C
  7202. requires_config_enabled MBEDTLS_SHA256_C
  7203. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
  7204. requires_config_enabled MBEDTLS_AES_C
  7205. requires_config_enabled MBEDTLS_GCM_C
  7206. run_test "DTLS fragmenting: both (MTU=512)" \
  7207. -p "$P_PXY mtu=512" \
  7208. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7209. crt_file=data_files/server7_int-ca.crt \
  7210. key_file=data_files/server7.key \
  7211. hs_timeout=2500-60000 \
  7212. mtu=512" \
  7213. "$P_CLI dtls=1 debug_level=2 \
  7214. crt_file=data_files/server8_int-ca2.crt \
  7215. key_file=data_files/server8.key \
  7216. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  7217. hs_timeout=2500-60000 \
  7218. mtu=512" \
  7219. 0 \
  7220. -s "found fragmented DTLS handshake message" \
  7221. -c "found fragmented DTLS handshake message" \
  7222. -C "error"
  7223. # Test for automatic MTU reduction on repeated resend.
  7224. # Forcing ciphersuite for this test to fit the MTU of 508 with full config.
  7225. # The ratio of max/min timeout should ideally equal 4 to accept two
  7226. # retransmissions, but in some cases (like both the server and client using
  7227. # fragmentation and auto-reduction) an extra retransmission might occur,
  7228. # hence the ratio of 8.
  7229. not_with_valgrind
  7230. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7231. requires_config_enabled MBEDTLS_RSA_C
  7232. requires_config_enabled MBEDTLS_ECDSA_C
  7233. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
  7234. requires_config_enabled MBEDTLS_AES_C
  7235. requires_config_enabled MBEDTLS_GCM_C
  7236. run_test "DTLS fragmenting: proxy MTU: auto-reduction (not valgrind)" \
  7237. -p "$P_PXY mtu=508" \
  7238. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7239. crt_file=data_files/server7_int-ca.crt \
  7240. key_file=data_files/server7.key \
  7241. hs_timeout=400-3200" \
  7242. "$P_CLI dtls=1 debug_level=2 \
  7243. crt_file=data_files/server8_int-ca2.crt \
  7244. key_file=data_files/server8.key \
  7245. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  7246. hs_timeout=400-3200" \
  7247. 0 \
  7248. -s "found fragmented DTLS handshake message" \
  7249. -c "found fragmented DTLS handshake message" \
  7250. -C "error"
  7251. # Forcing ciphersuite for this test to fit the MTU of 508 with full config.
  7252. only_with_valgrind
  7253. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7254. requires_config_enabled MBEDTLS_RSA_C
  7255. requires_config_enabled MBEDTLS_ECDSA_C
  7256. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
  7257. requires_config_enabled MBEDTLS_AES_C
  7258. requires_config_enabled MBEDTLS_GCM_C
  7259. run_test "DTLS fragmenting: proxy MTU: auto-reduction (with valgrind)" \
  7260. -p "$P_PXY mtu=508" \
  7261. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7262. crt_file=data_files/server7_int-ca.crt \
  7263. key_file=data_files/server7.key \
  7264. hs_timeout=250-10000" \
  7265. "$P_CLI dtls=1 debug_level=2 \
  7266. crt_file=data_files/server8_int-ca2.crt \
  7267. key_file=data_files/server8.key \
  7268. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  7269. hs_timeout=250-10000" \
  7270. 0 \
  7271. -s "found fragmented DTLS handshake message" \
  7272. -c "found fragmented DTLS handshake message" \
  7273. -C "error"
  7274. # the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
  7275. # OTOH the client might resend if the server is to slow to reset after sending
  7276. # a HelloVerifyRequest, so only check for no retransmission server-side
  7277. not_with_valgrind # spurious autoreduction due to timeout
  7278. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7279. requires_config_enabled MBEDTLS_RSA_C
  7280. requires_config_enabled MBEDTLS_ECDSA_C
  7281. run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
  7282. -p "$P_PXY mtu=1024" \
  7283. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7284. crt_file=data_files/server7_int-ca.crt \
  7285. key_file=data_files/server7.key \
  7286. hs_timeout=10000-60000 \
  7287. mtu=1024" \
  7288. "$P_CLI dtls=1 debug_level=2 \
  7289. crt_file=data_files/server8_int-ca2.crt \
  7290. key_file=data_files/server8.key \
  7291. hs_timeout=10000-60000 \
  7292. mtu=1024" \
  7293. 0 \
  7294. -S "autoreduction" \
  7295. -s "found fragmented DTLS handshake message" \
  7296. -c "found fragmented DTLS handshake message" \
  7297. -C "error"
  7298. # Forcing ciphersuite for this test to fit the MTU of 512 with full config.
  7299. # the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
  7300. # OTOH the client might resend if the server is to slow to reset after sending
  7301. # a HelloVerifyRequest, so only check for no retransmission server-side
  7302. not_with_valgrind # spurious autoreduction due to timeout
  7303. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7304. requires_config_enabled MBEDTLS_RSA_C
  7305. requires_config_enabled MBEDTLS_ECDSA_C
  7306. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
  7307. requires_config_enabled MBEDTLS_AES_C
  7308. requires_config_enabled MBEDTLS_GCM_C
  7309. run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
  7310. -p "$P_PXY mtu=512" \
  7311. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7312. crt_file=data_files/server7_int-ca.crt \
  7313. key_file=data_files/server7.key \
  7314. hs_timeout=10000-60000 \
  7315. mtu=512" \
  7316. "$P_CLI dtls=1 debug_level=2 \
  7317. crt_file=data_files/server8_int-ca2.crt \
  7318. key_file=data_files/server8.key \
  7319. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  7320. hs_timeout=10000-60000 \
  7321. mtu=512" \
  7322. 0 \
  7323. -S "autoreduction" \
  7324. -s "found fragmented DTLS handshake message" \
  7325. -c "found fragmented DTLS handshake message" \
  7326. -C "error"
  7327. not_with_valgrind # spurious autoreduction due to timeout
  7328. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7329. requires_config_enabled MBEDTLS_RSA_C
  7330. requires_config_enabled MBEDTLS_ECDSA_C
  7331. run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
  7332. -p "$P_PXY mtu=1024" \
  7333. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7334. crt_file=data_files/server7_int-ca.crt \
  7335. key_file=data_files/server7.key \
  7336. hs_timeout=10000-60000 \
  7337. mtu=1024 nbio=2" \
  7338. "$P_CLI dtls=1 debug_level=2 \
  7339. crt_file=data_files/server8_int-ca2.crt \
  7340. key_file=data_files/server8.key \
  7341. hs_timeout=10000-60000 \
  7342. mtu=1024 nbio=2" \
  7343. 0 \
  7344. -S "autoreduction" \
  7345. -s "found fragmented DTLS handshake message" \
  7346. -c "found fragmented DTLS handshake message" \
  7347. -C "error"
  7348. # Forcing ciphersuite for this test to fit the MTU of 512 with full config.
  7349. not_with_valgrind # spurious autoreduction due to timeout
  7350. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7351. requires_config_enabled MBEDTLS_RSA_C
  7352. requires_config_enabled MBEDTLS_ECDSA_C
  7353. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
  7354. requires_config_enabled MBEDTLS_AES_C
  7355. requires_config_enabled MBEDTLS_GCM_C
  7356. run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
  7357. -p "$P_PXY mtu=512" \
  7358. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7359. crt_file=data_files/server7_int-ca.crt \
  7360. key_file=data_files/server7.key \
  7361. hs_timeout=10000-60000 \
  7362. mtu=512 nbio=2" \
  7363. "$P_CLI dtls=1 debug_level=2 \
  7364. crt_file=data_files/server8_int-ca2.crt \
  7365. key_file=data_files/server8.key \
  7366. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  7367. hs_timeout=10000-60000 \
  7368. mtu=512 nbio=2" \
  7369. 0 \
  7370. -S "autoreduction" \
  7371. -s "found fragmented DTLS handshake message" \
  7372. -c "found fragmented DTLS handshake message" \
  7373. -C "error"
  7374. # Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
  7375. # This ensures things still work after session_reset().
  7376. # It also exercises the "resumed handshake" flow.
  7377. # Since we don't support reading fragmented ClientHello yet,
  7378. # up the MTU to 1450 (larger than ClientHello with session ticket,
  7379. # but still smaller than client's Certificate to ensure fragmentation).
  7380. # An autoreduction on the client-side might happen if the server is
  7381. # slow to reset, therefore omitting '-C "autoreduction"' below.
  7382. # reco_delay avoids races where the client reconnects before the server has
  7383. # resumed listening, which would result in a spurious autoreduction.
  7384. not_with_valgrind # spurious autoreduction due to timeout
  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_KEY_EXCHANGE_ECDHE_ECDSA
  7389. requires_config_enabled MBEDTLS_AES_C
  7390. requires_config_enabled MBEDTLS_GCM_C
  7391. run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
  7392. -p "$P_PXY mtu=1450" \
  7393. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7394. crt_file=data_files/server7_int-ca.crt \
  7395. key_file=data_files/server7.key \
  7396. hs_timeout=10000-60000 \
  7397. mtu=1450" \
  7398. "$P_CLI dtls=1 debug_level=2 \
  7399. crt_file=data_files/server8_int-ca2.crt \
  7400. key_file=data_files/server8.key \
  7401. hs_timeout=10000-60000 \
  7402. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  7403. mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
  7404. 0 \
  7405. -S "autoreduction" \
  7406. -s "found fragmented DTLS handshake message" \
  7407. -c "found fragmented DTLS handshake message" \
  7408. -C "error"
  7409. # An autoreduction on the client-side might happen if the server is
  7410. # slow to reset, therefore omitting '-C "autoreduction"' below.
  7411. not_with_valgrind # spurious autoreduction due to timeout
  7412. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7413. requires_config_enabled MBEDTLS_RSA_C
  7414. requires_config_enabled MBEDTLS_ECDSA_C
  7415. requires_config_enabled MBEDTLS_SHA256_C
  7416. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
  7417. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  7418. requires_config_enabled MBEDTLS_CHACHAPOLY_C
  7419. run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
  7420. -p "$P_PXY mtu=512" \
  7421. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7422. crt_file=data_files/server7_int-ca.crt \
  7423. key_file=data_files/server7.key \
  7424. exchanges=2 renegotiation=1 \
  7425. hs_timeout=10000-60000 \
  7426. mtu=512" \
  7427. "$P_CLI dtls=1 debug_level=2 \
  7428. crt_file=data_files/server8_int-ca2.crt \
  7429. key_file=data_files/server8.key \
  7430. exchanges=2 renegotiation=1 renegotiate=1 \
  7431. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  7432. hs_timeout=10000-60000 \
  7433. mtu=512" \
  7434. 0 \
  7435. -S "autoreduction" \
  7436. -s "found fragmented DTLS handshake message" \
  7437. -c "found fragmented DTLS handshake message" \
  7438. -C "error"
  7439. # An autoreduction on the client-side might happen if the server is
  7440. # slow to reset, therefore omitting '-C "autoreduction"' below.
  7441. not_with_valgrind # spurious autoreduction due to timeout
  7442. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7443. requires_config_enabled MBEDTLS_RSA_C
  7444. requires_config_enabled MBEDTLS_ECDSA_C
  7445. requires_config_enabled MBEDTLS_SHA256_C
  7446. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
  7447. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  7448. requires_config_enabled MBEDTLS_AES_C
  7449. requires_config_enabled MBEDTLS_GCM_C
  7450. run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
  7451. -p "$P_PXY mtu=512" \
  7452. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7453. crt_file=data_files/server7_int-ca.crt \
  7454. key_file=data_files/server7.key \
  7455. exchanges=2 renegotiation=1 \
  7456. hs_timeout=10000-60000 \
  7457. mtu=512" \
  7458. "$P_CLI dtls=1 debug_level=2 \
  7459. crt_file=data_files/server8_int-ca2.crt \
  7460. key_file=data_files/server8.key \
  7461. exchanges=2 renegotiation=1 renegotiate=1 \
  7462. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  7463. hs_timeout=10000-60000 \
  7464. mtu=512" \
  7465. 0 \
  7466. -S "autoreduction" \
  7467. -s "found fragmented DTLS handshake message" \
  7468. -c "found fragmented DTLS handshake message" \
  7469. -C "error"
  7470. # An autoreduction on the client-side might happen if the server is
  7471. # slow to reset, therefore omitting '-C "autoreduction"' below.
  7472. not_with_valgrind # spurious autoreduction due to timeout
  7473. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7474. requires_config_enabled MBEDTLS_RSA_C
  7475. requires_config_enabled MBEDTLS_ECDSA_C
  7476. requires_config_enabled MBEDTLS_SHA256_C
  7477. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
  7478. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  7479. requires_config_enabled MBEDTLS_AES_C
  7480. requires_config_enabled MBEDTLS_CCM_C
  7481. run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
  7482. -p "$P_PXY mtu=1024" \
  7483. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7484. crt_file=data_files/server7_int-ca.crt \
  7485. key_file=data_files/server7.key \
  7486. exchanges=2 renegotiation=1 \
  7487. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
  7488. hs_timeout=10000-60000 \
  7489. mtu=1024" \
  7490. "$P_CLI dtls=1 debug_level=2 \
  7491. crt_file=data_files/server8_int-ca2.crt \
  7492. key_file=data_files/server8.key \
  7493. exchanges=2 renegotiation=1 renegotiate=1 \
  7494. hs_timeout=10000-60000 \
  7495. mtu=1024" \
  7496. 0 \
  7497. -S "autoreduction" \
  7498. -s "found fragmented DTLS handshake message" \
  7499. -c "found fragmented DTLS handshake message" \
  7500. -C "error"
  7501. # An autoreduction on the client-side might happen if the server is
  7502. # slow to reset, therefore omitting '-C "autoreduction"' below.
  7503. not_with_valgrind # spurious autoreduction due to timeout
  7504. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7505. requires_config_enabled MBEDTLS_RSA_C
  7506. requires_config_enabled MBEDTLS_ECDSA_C
  7507. requires_config_enabled MBEDTLS_SHA256_C
  7508. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
  7509. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  7510. requires_config_enabled MBEDTLS_AES_C
  7511. requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
  7512. requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
  7513. run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
  7514. -p "$P_PXY mtu=1024" \
  7515. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7516. crt_file=data_files/server7_int-ca.crt \
  7517. key_file=data_files/server7.key \
  7518. exchanges=2 renegotiation=1 \
  7519. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
  7520. hs_timeout=10000-60000 \
  7521. mtu=1024" \
  7522. "$P_CLI dtls=1 debug_level=2 \
  7523. crt_file=data_files/server8_int-ca2.crt \
  7524. key_file=data_files/server8.key \
  7525. exchanges=2 renegotiation=1 renegotiate=1 \
  7526. hs_timeout=10000-60000 \
  7527. mtu=1024" \
  7528. 0 \
  7529. -S "autoreduction" \
  7530. -s "found fragmented DTLS handshake message" \
  7531. -c "found fragmented DTLS handshake message" \
  7532. -C "error"
  7533. # An autoreduction on the client-side might happen if the server is
  7534. # slow to reset, therefore omitting '-C "autoreduction"' below.
  7535. not_with_valgrind # spurious autoreduction due to timeout
  7536. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7537. requires_config_enabled MBEDTLS_RSA_C
  7538. requires_config_enabled MBEDTLS_ECDSA_C
  7539. requires_config_enabled MBEDTLS_SHA256_C
  7540. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
  7541. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  7542. requires_config_enabled MBEDTLS_AES_C
  7543. requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
  7544. run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
  7545. -p "$P_PXY mtu=1024" \
  7546. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7547. crt_file=data_files/server7_int-ca.crt \
  7548. key_file=data_files/server7.key \
  7549. exchanges=2 renegotiation=1 \
  7550. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
  7551. hs_timeout=10000-60000 \
  7552. mtu=1024" \
  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. exchanges=2 renegotiation=1 renegotiate=1 \
  7557. hs_timeout=10000-60000 \
  7558. mtu=1024" \
  7559. 0 \
  7560. -S "autoreduction" \
  7561. -s "found fragmented DTLS handshake message" \
  7562. -c "found fragmented DTLS handshake message" \
  7563. -C "error"
  7564. # Forcing ciphersuite for this test to fit the MTU of 512 with full config.
  7565. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7566. requires_config_enabled MBEDTLS_RSA_C
  7567. requires_config_enabled MBEDTLS_ECDSA_C
  7568. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
  7569. requires_config_enabled MBEDTLS_AES_C
  7570. requires_config_enabled MBEDTLS_GCM_C
  7571. client_needs_more_time 2
  7572. run_test "DTLS fragmenting: proxy MTU + 3d" \
  7573. -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
  7574. "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
  7575. crt_file=data_files/server7_int-ca.crt \
  7576. key_file=data_files/server7.key \
  7577. hs_timeout=250-10000 mtu=512" \
  7578. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  7579. crt_file=data_files/server8_int-ca2.crt \
  7580. key_file=data_files/server8.key \
  7581. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  7582. hs_timeout=250-10000 mtu=512" \
  7583. 0 \
  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. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7589. requires_config_enabled MBEDTLS_RSA_C
  7590. requires_config_enabled MBEDTLS_ECDSA_C
  7591. requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
  7592. requires_config_enabled MBEDTLS_AES_C
  7593. requires_config_enabled MBEDTLS_GCM_C
  7594. client_needs_more_time 2
  7595. run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
  7596. -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
  7597. "$P_SRV dtls=1 debug_level=2 auth_mode=required \
  7598. crt_file=data_files/server7_int-ca.crt \
  7599. key_file=data_files/server7.key \
  7600. hs_timeout=250-10000 mtu=512 nbio=2" \
  7601. "$P_CLI dtls=1 debug_level=2 \
  7602. crt_file=data_files/server8_int-ca2.crt \
  7603. key_file=data_files/server8.key \
  7604. force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
  7605. hs_timeout=250-10000 mtu=512 nbio=2" \
  7606. 0 \
  7607. -s "found fragmented DTLS handshake message" \
  7608. -c "found fragmented DTLS handshake message" \
  7609. -C "error"
  7610. # interop tests for DTLS fragmentating with reliable connection
  7611. #
  7612. # here and below we just want to test that the we fragment in a way that
  7613. # pleases other implementations, so we don't need the peer to fragment
  7614. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7615. requires_config_enabled MBEDTLS_RSA_C
  7616. requires_config_enabled MBEDTLS_ECDSA_C
  7617. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
  7618. requires_gnutls
  7619. run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
  7620. "$G_SRV -u" \
  7621. "$P_CLI dtls=1 debug_level=2 \
  7622. crt_file=data_files/server8_int-ca2.crt \
  7623. key_file=data_files/server8.key \
  7624. mtu=512 force_version=dtls1_2" \
  7625. 0 \
  7626. -c "fragmenting handshake message" \
  7627. -C "error"
  7628. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7629. requires_config_enabled MBEDTLS_RSA_C
  7630. requires_config_enabled MBEDTLS_ECDSA_C
  7631. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
  7632. requires_gnutls
  7633. run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
  7634. "$G_SRV -u" \
  7635. "$P_CLI dtls=1 debug_level=2 \
  7636. crt_file=data_files/server8_int-ca2.crt \
  7637. key_file=data_files/server8.key \
  7638. mtu=512 force_version=dtls1" \
  7639. 0 \
  7640. -c "fragmenting handshake message" \
  7641. -C "error"
  7642. # We use --insecure for the GnuTLS client because it expects
  7643. # the hostname / IP it connects to to be the name used in the
  7644. # certificate obtained from the server. Here, however, it
  7645. # connects to 127.0.0.1 while our test certificates use 'localhost'
  7646. # as the server name in the certificate. This will make the
  7647. # certifiate validation fail, but passing --insecure makes
  7648. # GnuTLS continue the connection nonetheless.
  7649. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7650. requires_config_enabled MBEDTLS_RSA_C
  7651. requires_config_enabled MBEDTLS_ECDSA_C
  7652. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
  7653. requires_gnutls
  7654. requires_not_i686
  7655. run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
  7656. "$P_SRV dtls=1 debug_level=2 \
  7657. crt_file=data_files/server7_int-ca.crt \
  7658. key_file=data_files/server7.key \
  7659. mtu=512 force_version=dtls1_2" \
  7660. "$G_CLI -u --insecure 127.0.0.1" \
  7661. 0 \
  7662. -s "fragmenting handshake message"
  7663. # See previous test for the reason to use --insecure
  7664. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7665. requires_config_enabled MBEDTLS_RSA_C
  7666. requires_config_enabled MBEDTLS_ECDSA_C
  7667. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
  7668. requires_gnutls
  7669. requires_not_i686
  7670. run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
  7671. "$P_SRV dtls=1 debug_level=2 \
  7672. crt_file=data_files/server7_int-ca.crt \
  7673. key_file=data_files/server7.key \
  7674. mtu=512 force_version=dtls1" \
  7675. "$G_CLI -u --insecure 127.0.0.1" \
  7676. 0 \
  7677. -s "fragmenting handshake message"
  7678. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7679. requires_config_enabled MBEDTLS_RSA_C
  7680. requires_config_enabled MBEDTLS_ECDSA_C
  7681. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
  7682. run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
  7683. "$O_SRV -dtls1_2 -verify 10" \
  7684. "$P_CLI dtls=1 debug_level=2 \
  7685. crt_file=data_files/server8_int-ca2.crt \
  7686. key_file=data_files/server8.key \
  7687. mtu=512 force_version=dtls1_2" \
  7688. 0 \
  7689. -c "fragmenting handshake message" \
  7690. -C "error"
  7691. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7692. requires_config_enabled MBEDTLS_RSA_C
  7693. requires_config_enabled MBEDTLS_ECDSA_C
  7694. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
  7695. run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
  7696. "$O_SRV -dtls1 -verify 10" \
  7697. "$P_CLI dtls=1 debug_level=2 \
  7698. crt_file=data_files/server8_int-ca2.crt \
  7699. key_file=data_files/server8.key \
  7700. mtu=512 force_version=dtls1" \
  7701. 0 \
  7702. -c "fragmenting handshake message" \
  7703. -C "error"
  7704. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7705. requires_config_enabled MBEDTLS_RSA_C
  7706. requires_config_enabled MBEDTLS_ECDSA_C
  7707. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
  7708. run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
  7709. "$P_SRV dtls=1 debug_level=2 \
  7710. crt_file=data_files/server7_int-ca.crt \
  7711. key_file=data_files/server7.key \
  7712. mtu=512 force_version=dtls1_2" \
  7713. "$O_CLI -dtls1_2" \
  7714. 0 \
  7715. -s "fragmenting handshake message"
  7716. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7717. requires_config_enabled MBEDTLS_RSA_C
  7718. requires_config_enabled MBEDTLS_ECDSA_C
  7719. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
  7720. run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
  7721. "$P_SRV dtls=1 debug_level=2 \
  7722. crt_file=data_files/server7_int-ca.crt \
  7723. key_file=data_files/server7.key \
  7724. mtu=512 force_version=dtls1" \
  7725. "$O_CLI -dtls1" \
  7726. 0 \
  7727. -s "fragmenting handshake message"
  7728. # interop tests for DTLS fragmentating with unreliable connection
  7729. #
  7730. # again we just want to test that the we fragment in a way that
  7731. # pleases other implementations, so we don't need the peer to fragment
  7732. requires_gnutls_next
  7733. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7734. requires_config_enabled MBEDTLS_RSA_C
  7735. requires_config_enabled MBEDTLS_ECDSA_C
  7736. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
  7737. client_needs_more_time 4
  7738. run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
  7739. -p "$P_PXY drop=8 delay=8 duplicate=8" \
  7740. "$G_NEXT_SRV -u" \
  7741. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  7742. crt_file=data_files/server8_int-ca2.crt \
  7743. key_file=data_files/server8.key \
  7744. hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
  7745. 0 \
  7746. -c "fragmenting handshake message" \
  7747. -C "error"
  7748. requires_gnutls_next
  7749. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7750. requires_config_enabled MBEDTLS_RSA_C
  7751. requires_config_enabled MBEDTLS_ECDSA_C
  7752. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
  7753. client_needs_more_time 4
  7754. run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
  7755. -p "$P_PXY drop=8 delay=8 duplicate=8" \
  7756. "$G_NEXT_SRV -u" \
  7757. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  7758. crt_file=data_files/server8_int-ca2.crt \
  7759. key_file=data_files/server8.key \
  7760. hs_timeout=250-60000 mtu=512 force_version=dtls1" \
  7761. 0 \
  7762. -c "fragmenting handshake message" \
  7763. -C "error"
  7764. requires_gnutls_next
  7765. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7766. requires_config_enabled MBEDTLS_RSA_C
  7767. requires_config_enabled MBEDTLS_ECDSA_C
  7768. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
  7769. client_needs_more_time 4
  7770. run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
  7771. -p "$P_PXY drop=8 delay=8 duplicate=8" \
  7772. "$P_SRV dtls=1 debug_level=2 \
  7773. crt_file=data_files/server7_int-ca.crt \
  7774. key_file=data_files/server7.key \
  7775. hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
  7776. "$G_NEXT_CLI -u --insecure 127.0.0.1" \
  7777. 0 \
  7778. -s "fragmenting handshake message"
  7779. requires_gnutls_next
  7780. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7781. requires_config_enabled MBEDTLS_RSA_C
  7782. requires_config_enabled MBEDTLS_ECDSA_C
  7783. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
  7784. client_needs_more_time 4
  7785. run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
  7786. -p "$P_PXY drop=8 delay=8 duplicate=8" \
  7787. "$P_SRV dtls=1 debug_level=2 \
  7788. crt_file=data_files/server7_int-ca.crt \
  7789. key_file=data_files/server7.key \
  7790. hs_timeout=250-60000 mtu=512 force_version=dtls1" \
  7791. "$G_NEXT_CLI -u --insecure 127.0.0.1" \
  7792. 0 \
  7793. -s "fragmenting handshake message"
  7794. ## Interop test with OpenSSL might trigger a bug in recent versions (including
  7795. ## all versions installed on the CI machines), reported here:
  7796. ## Bug report: https://github.com/openssl/openssl/issues/6902
  7797. ## They should be re-enabled once a fixed version of OpenSSL is available
  7798. ## (this should happen in some 1.1.1_ release according to the ticket).
  7799. skip_next_test
  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_SSL_PROTO_TLS1_2
  7804. client_needs_more_time 4
  7805. run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
  7806. -p "$P_PXY drop=8 delay=8 duplicate=8" \
  7807. "$O_SRV -dtls1_2 -verify 10" \
  7808. "$P_CLI dtls=1 debug_level=2 \
  7809. crt_file=data_files/server8_int-ca2.crt \
  7810. key_file=data_files/server8.key \
  7811. hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
  7812. 0 \
  7813. -c "fragmenting handshake message" \
  7814. -C "error"
  7815. skip_next_test
  7816. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7817. requires_config_enabled MBEDTLS_RSA_C
  7818. requires_config_enabled MBEDTLS_ECDSA_C
  7819. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
  7820. client_needs_more_time 4
  7821. run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
  7822. -p "$P_PXY drop=8 delay=8 duplicate=8" \
  7823. "$O_SRV -dtls1 -verify 10" \
  7824. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  7825. crt_file=data_files/server8_int-ca2.crt \
  7826. key_file=data_files/server8.key \
  7827. hs_timeout=250-60000 mtu=512 force_version=dtls1" \
  7828. 0 \
  7829. -c "fragmenting handshake message" \
  7830. -C "error"
  7831. skip_next_test
  7832. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7833. requires_config_enabled MBEDTLS_RSA_C
  7834. requires_config_enabled MBEDTLS_ECDSA_C
  7835. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
  7836. client_needs_more_time 4
  7837. run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
  7838. -p "$P_PXY drop=8 delay=8 duplicate=8" \
  7839. "$P_SRV dtls=1 debug_level=2 \
  7840. crt_file=data_files/server7_int-ca.crt \
  7841. key_file=data_files/server7.key \
  7842. hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
  7843. "$O_CLI -dtls1_2" \
  7844. 0 \
  7845. -s "fragmenting handshake message"
  7846. # -nbio is added to prevent s_client from blocking in case of duplicated
  7847. # messages at the end of the handshake
  7848. skip_next_test
  7849. requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
  7850. requires_config_enabled MBEDTLS_RSA_C
  7851. requires_config_enabled MBEDTLS_ECDSA_C
  7852. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
  7853. client_needs_more_time 4
  7854. run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
  7855. -p "$P_PXY drop=8 delay=8 duplicate=8" \
  7856. "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
  7857. crt_file=data_files/server7_int-ca.crt \
  7858. key_file=data_files/server7.key \
  7859. hs_timeout=250-60000 mtu=512 force_version=dtls1" \
  7860. "$O_CLI -nbio -dtls1" \
  7861. 0 \
  7862. -s "fragmenting handshake message"
  7863. # Tests for DTLS-SRTP (RFC 5764)
  7864. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  7865. run_test "DTLS-SRTP all profiles supported" \
  7866. "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
  7867. "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
  7868. 0 \
  7869. -s "found use_srtp extension" \
  7870. -s "found srtp profile" \
  7871. -s "selected srtp profile" \
  7872. -s "server hello, adding use_srtp extension" \
  7873. -s "DTLS-SRTP key material is"\
  7874. -c "client hello, adding use_srtp extension" \
  7875. -c "found use_srtp extension" \
  7876. -c "found srtp profile" \
  7877. -c "selected srtp profile" \
  7878. -c "DTLS-SRTP key material is"\
  7879. -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
  7880. -C "error"
  7881. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  7882. run_test "DTLS-SRTP server supports all profiles. Client supports one profile." \
  7883. "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
  7884. "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=5 debug_level=3" \
  7885. 0 \
  7886. -s "found use_srtp extension" \
  7887. -s "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80" \
  7888. -s "selected srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80" \
  7889. -s "server hello, adding use_srtp extension" \
  7890. -s "DTLS-SRTP key material is"\
  7891. -c "client hello, adding use_srtp extension" \
  7892. -c "found use_srtp extension" \
  7893. -c "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80" \
  7894. -c "selected srtp profile" \
  7895. -c "DTLS-SRTP key material is"\
  7896. -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
  7897. -C "error"
  7898. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  7899. run_test "DTLS-SRTP server supports one profile. Client supports all profiles." \
  7900. "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \
  7901. "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
  7902. 0 \
  7903. -s "found use_srtp extension" \
  7904. -s "found srtp profile" \
  7905. -s "selected srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32" \
  7906. -s "server hello, adding use_srtp extension" \
  7907. -s "DTLS-SRTP key material is"\
  7908. -c "client hello, adding use_srtp extension" \
  7909. -c "found use_srtp extension" \
  7910. -c "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32" \
  7911. -c "selected srtp profile" \
  7912. -c "DTLS-SRTP key material is"\
  7913. -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
  7914. -C "error"
  7915. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  7916. run_test "DTLS-SRTP server and Client support only one matching profile." \
  7917. "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
  7918. "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
  7919. 0 \
  7920. -s "found use_srtp extension" \
  7921. -s "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
  7922. -s "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
  7923. -s "server hello, adding use_srtp extension" \
  7924. -s "DTLS-SRTP key material is"\
  7925. -c "client hello, adding use_srtp extension" \
  7926. -c "found use_srtp extension" \
  7927. -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
  7928. -c "selected srtp profile" \
  7929. -c "DTLS-SRTP key material is"\
  7930. -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
  7931. -C "error"
  7932. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  7933. run_test "DTLS-SRTP server and Client support only one different profile." \
  7934. "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
  7935. "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \
  7936. 0 \
  7937. -s "found use_srtp extension" \
  7938. -s "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32" \
  7939. -S "selected srtp profile" \
  7940. -S "server hello, adding use_srtp extension" \
  7941. -S "DTLS-SRTP key material is"\
  7942. -c "client hello, adding use_srtp extension" \
  7943. -C "found use_srtp extension" \
  7944. -C "found srtp profile" \
  7945. -C "selected srtp profile" \
  7946. -C "DTLS-SRTP key material is"\
  7947. -C "error"
  7948. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  7949. run_test "DTLS-SRTP server doesn't support use_srtp extension." \
  7950. "$P_SRV dtls=1 debug_level=3" \
  7951. "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
  7952. 0 \
  7953. -s "found use_srtp extension" \
  7954. -S "server hello, adding use_srtp extension" \
  7955. -S "DTLS-SRTP key material is"\
  7956. -c "client hello, adding use_srtp extension" \
  7957. -C "found use_srtp extension" \
  7958. -C "found srtp profile" \
  7959. -C "selected srtp profile" \
  7960. -C "DTLS-SRTP key material is"\
  7961. -C "error"
  7962. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  7963. run_test "DTLS-SRTP all profiles supported. mki used" \
  7964. "$P_SRV dtls=1 use_srtp=1 support_mki=1 debug_level=3" \
  7965. "$P_CLI dtls=1 use_srtp=1 mki=542310ab34290481 debug_level=3" \
  7966. 0 \
  7967. -s "found use_srtp extension" \
  7968. -s "found srtp profile" \
  7969. -s "selected srtp profile" \
  7970. -s "server hello, adding use_srtp extension" \
  7971. -s "dumping 'using mki' (8 bytes)" \
  7972. -s "DTLS-SRTP key material is"\
  7973. -c "client hello, adding use_srtp extension" \
  7974. -c "found use_srtp extension" \
  7975. -c "found srtp profile" \
  7976. -c "selected srtp profile" \
  7977. -c "dumping 'sending mki' (8 bytes)" \
  7978. -c "dumping 'received mki' (8 bytes)" \
  7979. -c "DTLS-SRTP key material is"\
  7980. -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
  7981. -g "find_in_both '^ *DTLS-SRTP mki value: [0-9A-F]*$'"\
  7982. -C "error"
  7983. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  7984. run_test "DTLS-SRTP all profiles supported. server doesn't support mki." \
  7985. "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
  7986. "$P_CLI dtls=1 use_srtp=1 mki=542310ab34290481 debug_level=3" \
  7987. 0 \
  7988. -s "found use_srtp extension" \
  7989. -s "found srtp profile" \
  7990. -s "selected srtp profile" \
  7991. -s "server hello, adding use_srtp extension" \
  7992. -s "DTLS-SRTP key material is"\
  7993. -s "DTLS-SRTP no mki value negotiated"\
  7994. -S "dumping 'using mki' (8 bytes)" \
  7995. -c "client hello, adding use_srtp extension" \
  7996. -c "found use_srtp extension" \
  7997. -c "found srtp profile" \
  7998. -c "selected srtp profile" \
  7999. -c "DTLS-SRTP key material is"\
  8000. -c "DTLS-SRTP no mki value negotiated"\
  8001. -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
  8002. -c "dumping 'sending mki' (8 bytes)" \
  8003. -C "dumping 'received mki' (8 bytes)" \
  8004. -C "error"
  8005. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8006. run_test "DTLS-SRTP all profiles supported. openssl client." \
  8007. "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
  8008. "$O_CLI -dtls1 -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8009. 0 \
  8010. -s "found use_srtp extension" \
  8011. -s "found srtp profile" \
  8012. -s "selected srtp profile" \
  8013. -s "server hello, adding use_srtp extension" \
  8014. -s "DTLS-SRTP key material is"\
  8015. -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
  8016. -c "SRTP Extension negotiated, profile=SRTP_AES128_CM_SHA1_80"
  8017. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8018. run_test "DTLS-SRTP server supports all profiles. Client supports all profiles, in different order. openssl client." \
  8019. "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
  8020. "$O_CLI -dtls1 -use_srtp SRTP_AES128_CM_SHA1_32:SRTP_AES128_CM_SHA1_80 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8021. 0 \
  8022. -s "found use_srtp extension" \
  8023. -s "found srtp profile" \
  8024. -s "selected srtp profile" \
  8025. -s "server hello, adding use_srtp extension" \
  8026. -s "DTLS-SRTP key material is"\
  8027. -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
  8028. -c "SRTP Extension negotiated, profile=SRTP_AES128_CM_SHA1_32"
  8029. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8030. run_test "DTLS-SRTP server supports all profiles. Client supports one profile. openssl client." \
  8031. "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
  8032. "$O_CLI -dtls1 -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8033. 0 \
  8034. -s "found use_srtp extension" \
  8035. -s "found srtp profile" \
  8036. -s "selected srtp profile" \
  8037. -s "server hello, adding use_srtp extension" \
  8038. -s "DTLS-SRTP key material is"\
  8039. -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
  8040. -c "SRTP Extension negotiated, profile=SRTP_AES128_CM_SHA1_32"
  8041. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8042. run_test "DTLS-SRTP server supports one profile. Client supports all profiles. openssl client." \
  8043. "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
  8044. "$O_CLI -dtls1 -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8045. 0 \
  8046. -s "found use_srtp extension" \
  8047. -s "found srtp profile" \
  8048. -s "selected srtp profile" \
  8049. -s "server hello, adding use_srtp extension" \
  8050. -s "DTLS-SRTP key material is"\
  8051. -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
  8052. -c "SRTP Extension negotiated, profile=SRTP_AES128_CM_SHA1_32"
  8053. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8054. run_test "DTLS-SRTP server and Client support only one matching profile. openssl client." \
  8055. "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
  8056. "$O_CLI -dtls1 -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8057. 0 \
  8058. -s "found use_srtp extension" \
  8059. -s "found srtp profile" \
  8060. -s "selected srtp profile" \
  8061. -s "server hello, adding use_srtp extension" \
  8062. -s "DTLS-SRTP key material is"\
  8063. -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
  8064. -c "SRTP Extension negotiated, profile=SRTP_AES128_CM_SHA1_32"
  8065. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8066. run_test "DTLS-SRTP server and Client support only one different profile. openssl client." \
  8067. "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=1 debug_level=3" \
  8068. "$O_CLI -dtls1 -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8069. 0 \
  8070. -s "found use_srtp extension" \
  8071. -s "found srtp profile" \
  8072. -S "selected srtp profile" \
  8073. -S "server hello, adding use_srtp extension" \
  8074. -S "DTLS-SRTP key material is"\
  8075. -C "SRTP Extension negotiated, profile"
  8076. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8077. run_test "DTLS-SRTP server doesn't support use_srtp extension. openssl client" \
  8078. "$P_SRV dtls=1 debug_level=3" \
  8079. "$O_CLI -dtls1 -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8080. 0 \
  8081. -s "found use_srtp extension" \
  8082. -S "server hello, adding use_srtp extension" \
  8083. -S "DTLS-SRTP key material is"\
  8084. -C "SRTP Extension negotiated, profile"
  8085. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8086. run_test "DTLS-SRTP all profiles supported. openssl server" \
  8087. "$O_SRV -dtls1 -verify 0 -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8088. "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
  8089. 0 \
  8090. -c "client hello, adding use_srtp extension" \
  8091. -c "found use_srtp extension" \
  8092. -c "found srtp profile" \
  8093. -c "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_80" \
  8094. -c "DTLS-SRTP key material is"\
  8095. -C "error"
  8096. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8097. run_test "DTLS-SRTP server supports all profiles. Client supports all profiles, in different order. openssl server." \
  8098. "$O_SRV -dtls1 -verify 0 -use_srtp SRTP_AES128_CM_SHA1_32:SRTP_AES128_CM_SHA1_80 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8099. "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
  8100. 0 \
  8101. -c "client hello, adding use_srtp extension" \
  8102. -c "found use_srtp extension" \
  8103. -c "found srtp profile" \
  8104. -c "selected srtp profile" \
  8105. -c "DTLS-SRTP key material is"\
  8106. -C "error"
  8107. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8108. run_test "DTLS-SRTP server supports all profiles. Client supports one profile. openssl server." \
  8109. "$O_SRV -dtls1 -verify 0 -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8110. "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
  8111. 0 \
  8112. -c "client hello, adding use_srtp extension" \
  8113. -c "found use_srtp extension" \
  8114. -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
  8115. -c "selected srtp profile" \
  8116. -c "DTLS-SRTP key material is"\
  8117. -C "error"
  8118. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8119. run_test "DTLS-SRTP server supports one profile. Client supports all profiles. openssl server." \
  8120. "$O_SRV -dtls1 -verify 0 -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8121. "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
  8122. 0 \
  8123. -c "client hello, adding use_srtp extension" \
  8124. -c "found use_srtp extension" \
  8125. -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
  8126. -c "selected srtp profile" \
  8127. -c "DTLS-SRTP key material is"\
  8128. -C "error"
  8129. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8130. run_test "DTLS-SRTP server and Client support only one matching profile. openssl server." \
  8131. "$O_SRV -dtls1 -verify 0 -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8132. "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
  8133. 0 \
  8134. -c "client hello, adding use_srtp extension" \
  8135. -c "found use_srtp extension" \
  8136. -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
  8137. -c "selected srtp profile" \
  8138. -c "DTLS-SRTP key material is"\
  8139. -C "error"
  8140. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8141. run_test "DTLS-SRTP server and Client support only one different profile. openssl server." \
  8142. "$O_SRV -dtls1 -verify 0 -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8143. "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \
  8144. 0 \
  8145. -c "client hello, adding use_srtp extension" \
  8146. -C "found use_srtp extension" \
  8147. -C "found srtp profile" \
  8148. -C "selected srtp profile" \
  8149. -C "DTLS-SRTP key material is"\
  8150. -C "error"
  8151. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8152. run_test "DTLS-SRTP server doesn't support use_srtp extension. openssl server" \
  8153. "$O_SRV -dtls1" \
  8154. "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
  8155. 0 \
  8156. -c "client hello, adding use_srtp extension" \
  8157. -C "found use_srtp extension" \
  8158. -C "found srtp profile" \
  8159. -C "selected srtp profile" \
  8160. -C "DTLS-SRTP key material is"\
  8161. -C "error"
  8162. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8163. run_test "DTLS-SRTP all profiles supported. server doesn't support mki. openssl server." \
  8164. "$O_SRV -dtls1 -verify 0 -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
  8165. "$P_CLI dtls=1 use_srtp=1 mki=542310ab34290481 debug_level=3" \
  8166. 0 \
  8167. -c "client hello, adding use_srtp extension" \
  8168. -c "found use_srtp extension" \
  8169. -c "found srtp profile" \
  8170. -c "selected srtp profile" \
  8171. -c "DTLS-SRTP key material is"\
  8172. -c "DTLS-SRTP no mki value negotiated"\
  8173. -c "dumping 'sending mki' (8 bytes)" \
  8174. -C "dumping 'received mki' (8 bytes)" \
  8175. -C "error"
  8176. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8177. requires_gnutls
  8178. run_test "DTLS-SRTP all profiles supported. gnutls client." \
  8179. "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
  8180. "$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" \
  8181. 0 \
  8182. -s "found use_srtp extension" \
  8183. -s "found srtp profile" \
  8184. -s "selected srtp profile" \
  8185. -s "server hello, adding use_srtp extension" \
  8186. -s "DTLS-SRTP key material is"\
  8187. -c "SRTP profile: SRTP_AES128_CM_HMAC_SHA1_80"
  8188. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8189. requires_gnutls
  8190. run_test "DTLS-SRTP server supports all profiles. Client supports all profiles, in different order. gnutls client." \
  8191. "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
  8192. "$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" \
  8193. 0 \
  8194. -s "found use_srtp extension" \
  8195. -s "found srtp profile" \
  8196. -s "selected srtp profile" \
  8197. -s "server hello, adding use_srtp extension" \
  8198. -s "DTLS-SRTP key material is"\
  8199. -c "SRTP profile: SRTP_NULL_HMAC_SHA1_80"
  8200. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8201. requires_gnutls
  8202. run_test "DTLS-SRTP server supports all profiles. Client supports one profile. gnutls client." \
  8203. "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
  8204. "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32 --insecure 127.0.0.1" \
  8205. 0 \
  8206. -s "found use_srtp extension" \
  8207. -s "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
  8208. -s "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
  8209. -s "server hello, adding use_srtp extension" \
  8210. -s "DTLS-SRTP key material is"\
  8211. -c "SRTP profile: SRTP_AES128_CM_HMAC_SHA1_32"
  8212. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8213. requires_gnutls
  8214. run_test "DTLS-SRTP server supports one profile. Client supports all profiles. gnutls client." \
  8215. "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \
  8216. "$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" \
  8217. 0 \
  8218. -s "found use_srtp extension" \
  8219. -s "found srtp profile" \
  8220. -s "selected srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32" \
  8221. -s "server hello, adding use_srtp extension" \
  8222. -s "DTLS-SRTP key material is"\
  8223. -c "SRTP profile: SRTP_NULL_SHA1_32"
  8224. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8225. requires_gnutls
  8226. run_test "DTLS-SRTP server and Client support only one matching profile. gnutls client." \
  8227. "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
  8228. "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32 --insecure 127.0.0.1" \
  8229. 0 \
  8230. -s "found use_srtp extension" \
  8231. -s "found srtp profile" \
  8232. -s "selected srtp profile" \
  8233. -s "server hello, adding use_srtp extension" \
  8234. -s "DTLS-SRTP key material is"\
  8235. -c "SRTP profile: SRTP_AES128_CM_HMAC_SHA1_32"
  8236. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8237. requires_gnutls
  8238. run_test "DTLS-SRTP server and Client support only one different profile. gnutls client." \
  8239. "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=1 debug_level=3" \
  8240. "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32 --insecure 127.0.0.1" \
  8241. 0 \
  8242. -s "found use_srtp extension" \
  8243. -s "found srtp profile" \
  8244. -S "selected srtp profile" \
  8245. -S "server hello, adding use_srtp extension" \
  8246. -S "DTLS-SRTP key material is"\
  8247. -C "SRTP profile:"
  8248. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8249. requires_gnutls
  8250. run_test "DTLS-SRTP server doesn't support use_srtp extension. gnutls client" \
  8251. "$P_SRV dtls=1 debug_level=3" \
  8252. "$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" \
  8253. 0 \
  8254. -s "found use_srtp extension" \
  8255. -S "server hello, adding use_srtp extension" \
  8256. -S "DTLS-SRTP key material is"\
  8257. -C "SRTP profile:"
  8258. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8259. requires_gnutls
  8260. run_test "DTLS-SRTP all profiles supported. gnutls server" \
  8261. "$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" \
  8262. "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
  8263. 0 \
  8264. -c "client hello, adding use_srtp extension" \
  8265. -c "found use_srtp extension" \
  8266. -c "found srtp profile" \
  8267. -c "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_80" \
  8268. -c "DTLS-SRTP key material is"\
  8269. -C "error"
  8270. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8271. requires_gnutls
  8272. run_test "DTLS-SRTP server supports all profiles. Client supports all profiles, in different order. gnutls server." \
  8273. "$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" \
  8274. "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
  8275. 0 \
  8276. -c "client hello, adding use_srtp extension" \
  8277. -c "found use_srtp extension" \
  8278. -c "found srtp profile" \
  8279. -c "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_80" \
  8280. -c "DTLS-SRTP key material is"\
  8281. -C "error"
  8282. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8283. requires_gnutls
  8284. run_test "DTLS-SRTP server supports all profiles. Client supports one profile. gnutls server." \
  8285. "$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" \
  8286. "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
  8287. 0 \
  8288. -c "client hello, adding use_srtp extension" \
  8289. -c "found use_srtp extension" \
  8290. -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
  8291. -c "selected srtp profile" \
  8292. -c "DTLS-SRTP key material is"\
  8293. -C "error"
  8294. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8295. requires_gnutls
  8296. run_test "DTLS-SRTP server supports one profile. Client supports all profiles. gnutls server." \
  8297. "$G_SRV -u --srtp-profiles=SRTP_NULL_HMAC_SHA1_80" \
  8298. "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
  8299. 0 \
  8300. -c "client hello, adding use_srtp extension" \
  8301. -c "found use_srtp extension" \
  8302. -c "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80" \
  8303. -c "selected srtp profile" \
  8304. -c "DTLS-SRTP key material is"\
  8305. -C "error"
  8306. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8307. requires_gnutls
  8308. run_test "DTLS-SRTP server and Client support only one matching profile. gnutls server." \
  8309. "$G_SRV -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32" \
  8310. "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
  8311. 0 \
  8312. -c "client hello, adding use_srtp extension" \
  8313. -c "found use_srtp extension" \
  8314. -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
  8315. -c "selected srtp profile" \
  8316. -c "DTLS-SRTP key material is"\
  8317. -C "error"
  8318. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8319. requires_gnutls
  8320. run_test "DTLS-SRTP server and Client support only one different profile. gnutls server." \
  8321. "$G_SRV -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32" \
  8322. "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \
  8323. 0 \
  8324. -c "client hello, adding use_srtp extension" \
  8325. -C "found use_srtp extension" \
  8326. -C "found srtp profile" \
  8327. -C "selected srtp profile" \
  8328. -C "DTLS-SRTP key material is"\
  8329. -C "error"
  8330. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8331. requires_gnutls
  8332. run_test "DTLS-SRTP server doesn't support use_srtp extension. gnutls server" \
  8333. "$G_SRV -u" \
  8334. "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
  8335. 0 \
  8336. -c "client hello, adding use_srtp extension" \
  8337. -C "found use_srtp extension" \
  8338. -C "found srtp profile" \
  8339. -C "selected srtp profile" \
  8340. -C "DTLS-SRTP key material is"\
  8341. -C "error"
  8342. requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
  8343. requires_gnutls
  8344. run_test "DTLS-SRTP all profiles supported. mki used. gnutls server." \
  8345. "$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" \
  8346. "$P_CLI dtls=1 use_srtp=1 mki=542310ab34290481 debug_level=3" \
  8347. 0 \
  8348. -c "client hello, adding use_srtp extension" \
  8349. -c "found use_srtp extension" \
  8350. -c "found srtp profile" \
  8351. -c "selected srtp profile" \
  8352. -c "DTLS-SRTP key material is"\
  8353. -c "DTLS-SRTP mki value:"\
  8354. -c "dumping 'sending mki' (8 bytes)" \
  8355. -c "dumping 'received mki' (8 bytes)" \
  8356. -C "error"
  8357. # Tests for specific things with "unreliable" UDP connection
  8358. not_with_valgrind # spurious resend due to timeout
  8359. run_test "DTLS proxy: reference" \
  8360. -p "$P_PXY" \
  8361. "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
  8362. "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
  8363. 0 \
  8364. -C "replayed record" \
  8365. -S "replayed record" \
  8366. -C "Buffer record from epoch" \
  8367. -S "Buffer record from epoch" \
  8368. -C "ssl_buffer_message" \
  8369. -S "ssl_buffer_message" \
  8370. -C "discarding invalid record" \
  8371. -S "discarding invalid record" \
  8372. -S "resend" \
  8373. -s "Extra-header:" \
  8374. -c "HTTP/1.0 200 OK"
  8375. not_with_valgrind # spurious resend due to timeout
  8376. run_test "DTLS proxy: duplicate every packet" \
  8377. -p "$P_PXY duplicate=1" \
  8378. "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
  8379. "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
  8380. 0 \
  8381. -c "replayed record" \
  8382. -s "replayed record" \
  8383. -c "record from another epoch" \
  8384. -s "record from another epoch" \
  8385. -S "resend" \
  8386. -s "Extra-header:" \
  8387. -c "HTTP/1.0 200 OK"
  8388. run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
  8389. -p "$P_PXY duplicate=1" \
  8390. "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
  8391. "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
  8392. 0 \
  8393. -c "replayed record" \
  8394. -S "replayed record" \
  8395. -c "record from another epoch" \
  8396. -s "record from another epoch" \
  8397. -c "resend" \
  8398. -s "resend" \
  8399. -s "Extra-header:" \
  8400. -c "HTTP/1.0 200 OK"
  8401. run_test "DTLS proxy: multiple records in same datagram" \
  8402. -p "$P_PXY pack=50" \
  8403. "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
  8404. "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
  8405. 0 \
  8406. -c "next record in same datagram" \
  8407. -s "next record in same datagram"
  8408. run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
  8409. -p "$P_PXY pack=50 duplicate=1" \
  8410. "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
  8411. "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
  8412. 0 \
  8413. -c "next record in same datagram" \
  8414. -s "next record in same datagram"
  8415. run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
  8416. -p "$P_PXY bad_ad=1" \
  8417. "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
  8418. "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
  8419. 0 \
  8420. -c "discarding invalid record (mac)" \
  8421. -s "discarding invalid record (mac)" \
  8422. -s "Extra-header:" \
  8423. -c "HTTP/1.0 200 OK" \
  8424. -S "too many records with bad MAC" \
  8425. -S "Verification of the message MAC failed"
  8426. run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
  8427. -p "$P_PXY bad_ad=1" \
  8428. "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
  8429. "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
  8430. 1 \
  8431. -C "discarding invalid record (mac)" \
  8432. -S "discarding invalid record (mac)" \
  8433. -S "Extra-header:" \
  8434. -C "HTTP/1.0 200 OK" \
  8435. -s "too many records with bad MAC" \
  8436. -s "Verification of the message MAC failed"
  8437. run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
  8438. -p "$P_PXY bad_ad=1" \
  8439. "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
  8440. "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
  8441. 0 \
  8442. -c "discarding invalid record (mac)" \
  8443. -s "discarding invalid record (mac)" \
  8444. -s "Extra-header:" \
  8445. -c "HTTP/1.0 200 OK" \
  8446. -S "too many records with bad MAC" \
  8447. -S "Verification of the message MAC failed"
  8448. run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
  8449. -p "$P_PXY bad_ad=1" \
  8450. "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
  8451. "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
  8452. 1 \
  8453. -c "discarding invalid record (mac)" \
  8454. -s "discarding invalid record (mac)" \
  8455. -s "Extra-header:" \
  8456. -c "HTTP/1.0 200 OK" \
  8457. -s "too many records with bad MAC" \
  8458. -s "Verification of the message MAC failed"
  8459. run_test "DTLS proxy: delay ChangeCipherSpec" \
  8460. -p "$P_PXY delay_ccs=1" \
  8461. "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
  8462. "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
  8463. 0 \
  8464. -c "record from another epoch" \
  8465. -s "record from another epoch" \
  8466. -s "Extra-header:" \
  8467. -c "HTTP/1.0 200 OK"
  8468. # Tests for reordering support with DTLS
  8469. run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
  8470. -p "$P_PXY delay_srv=ServerHello" \
  8471. "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
  8472. hs_timeout=2500-60000" \
  8473. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  8474. hs_timeout=2500-60000" \
  8475. 0 \
  8476. -c "Buffering HS message" \
  8477. -c "Next handshake message has been buffered - load"\
  8478. -S "Buffering HS message" \
  8479. -S "Next handshake message has been buffered - load"\
  8480. -C "Injecting buffered CCS message" \
  8481. -C "Remember CCS message" \
  8482. -S "Injecting buffered CCS message" \
  8483. -S "Remember CCS message"
  8484. run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
  8485. -p "$P_PXY delay_srv=ServerHello" \
  8486. "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
  8487. hs_timeout=2500-60000" \
  8488. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  8489. hs_timeout=2500-60000" \
  8490. 0 \
  8491. -c "Buffering HS message" \
  8492. -c "found fragmented DTLS handshake message"\
  8493. -c "Next handshake message 1 not or only partially bufffered" \
  8494. -c "Next handshake message has been buffered - load"\
  8495. -S "Buffering HS message" \
  8496. -S "Next handshake message has been buffered - load"\
  8497. -C "Injecting buffered CCS message" \
  8498. -C "Remember CCS message" \
  8499. -S "Injecting buffered CCS message" \
  8500. -S "Remember CCS message"
  8501. # The client buffers the ServerKeyExchange before receiving the fragmented
  8502. # Certificate message; at the time of writing, together these are aroudn 1200b
  8503. # in size, so that the bound below ensures that the certificate can be reassembled
  8504. # while keeping the ServerKeyExchange.
  8505. requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
  8506. run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
  8507. -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
  8508. "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
  8509. hs_timeout=2500-60000" \
  8510. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  8511. hs_timeout=2500-60000" \
  8512. 0 \
  8513. -c "Buffering HS message" \
  8514. -c "Next handshake message has been buffered - load"\
  8515. -C "attempt to make space by freeing buffered messages" \
  8516. -S "Buffering HS message" \
  8517. -S "Next handshake message has been buffered - load"\
  8518. -C "Injecting buffered CCS message" \
  8519. -C "Remember CCS message" \
  8520. -S "Injecting buffered CCS message" \
  8521. -S "Remember CCS message"
  8522. # The size constraints ensure that the delayed certificate message can't
  8523. # be reassembled while keeping the ServerKeyExchange message, but it can
  8524. # when dropping it first.
  8525. requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
  8526. requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
  8527. run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
  8528. -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
  8529. "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
  8530. hs_timeout=2500-60000" \
  8531. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  8532. hs_timeout=2500-60000" \
  8533. 0 \
  8534. -c "Buffering HS message" \
  8535. -c "attempt to make space by freeing buffered future messages" \
  8536. -c "Enough space available after freeing buffered HS messages" \
  8537. -S "Buffering HS message" \
  8538. -S "Next handshake message has been buffered - load"\
  8539. -C "Injecting buffered CCS message" \
  8540. -C "Remember CCS message" \
  8541. -S "Injecting buffered CCS message" \
  8542. -S "Remember CCS message"
  8543. run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
  8544. -p "$P_PXY delay_cli=Certificate" \
  8545. "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
  8546. hs_timeout=2500-60000" \
  8547. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  8548. hs_timeout=2500-60000" \
  8549. 0 \
  8550. -C "Buffering HS message" \
  8551. -C "Next handshake message has been buffered - load"\
  8552. -s "Buffering HS message" \
  8553. -s "Next handshake message has been buffered - load" \
  8554. -C "Injecting buffered CCS message" \
  8555. -C "Remember CCS message" \
  8556. -S "Injecting buffered CCS message" \
  8557. -S "Remember CCS message"
  8558. run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
  8559. -p "$P_PXY delay_srv=NewSessionTicket" \
  8560. "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
  8561. hs_timeout=2500-60000" \
  8562. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  8563. hs_timeout=2500-60000" \
  8564. 0 \
  8565. -C "Buffering HS message" \
  8566. -C "Next handshake message has been buffered - load"\
  8567. -S "Buffering HS message" \
  8568. -S "Next handshake message has been buffered - load" \
  8569. -c "Injecting buffered CCS message" \
  8570. -c "Remember CCS message" \
  8571. -S "Injecting buffered CCS message" \
  8572. -S "Remember CCS message"
  8573. run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
  8574. -p "$P_PXY delay_cli=ClientKeyExchange" \
  8575. "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
  8576. hs_timeout=2500-60000" \
  8577. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  8578. hs_timeout=2500-60000" \
  8579. 0 \
  8580. -C "Buffering HS message" \
  8581. -C "Next handshake message has been buffered - load"\
  8582. -S "Buffering HS message" \
  8583. -S "Next handshake message has been buffered - load" \
  8584. -C "Injecting buffered CCS message" \
  8585. -C "Remember CCS message" \
  8586. -s "Injecting buffered CCS message" \
  8587. -s "Remember CCS message"
  8588. run_test "DTLS reordering: Buffer encrypted Finished message" \
  8589. -p "$P_PXY delay_ccs=1" \
  8590. "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
  8591. hs_timeout=2500-60000" \
  8592. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
  8593. hs_timeout=2500-60000" \
  8594. 0 \
  8595. -s "Buffer record from epoch 1" \
  8596. -s "Found buffered record from current epoch - load" \
  8597. -c "Buffer record from epoch 1" \
  8598. -c "Found buffered record from current epoch - load"
  8599. # In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
  8600. # from the server are delayed, so that the encrypted Finished message
  8601. # is received and buffered. When the fragmented NewSessionTicket comes
  8602. # in afterwards, the encrypted Finished message must be freed in order
  8603. # to make space for the NewSessionTicket to be reassembled.
  8604. # This works only in very particular circumstances:
  8605. # - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
  8606. # of the NewSessionTicket, but small enough to also allow buffering of
  8607. # the encrypted Finished message.
  8608. # - The MTU setting on the server must be so small that the NewSessionTicket
  8609. # needs to be fragmented.
  8610. # - All messages sent by the server must be small enough to be either sent
  8611. # without fragmentation or be reassembled within the bounds of
  8612. # MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
  8613. # handshake, omitting CRTs.
  8614. requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 190
  8615. requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 230
  8616. run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
  8617. -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
  8618. "$P_SRV mtu=140 response_size=90 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
  8619. "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
  8620. 0 \
  8621. -s "Buffer record from epoch 1" \
  8622. -s "Found buffered record from current epoch - load" \
  8623. -c "Buffer record from epoch 1" \
  8624. -C "Found buffered record from current epoch - load" \
  8625. -c "Enough space available after freeing future epoch record"
  8626. # Tests for "randomly unreliable connection": try a variety of flows and peers
  8627. client_needs_more_time 2
  8628. run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
  8629. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  8630. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
  8631. psk=abc123" \
  8632. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
  8633. force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
  8634. 0 \
  8635. -s "Extra-header:" \
  8636. -c "HTTP/1.0 200 OK"
  8637. client_needs_more_time 2
  8638. run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
  8639. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  8640. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
  8641. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
  8642. force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
  8643. 0 \
  8644. -s "Extra-header:" \
  8645. -c "HTTP/1.0 200 OK"
  8646. client_needs_more_time 2
  8647. run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
  8648. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  8649. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
  8650. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
  8651. 0 \
  8652. -s "Extra-header:" \
  8653. -c "HTTP/1.0 200 OK"
  8654. client_needs_more_time 2
  8655. run_test "DTLS proxy: 3d, FS, client auth" \
  8656. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  8657. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
  8658. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
  8659. 0 \
  8660. -s "Extra-header:" \
  8661. -c "HTTP/1.0 200 OK"
  8662. client_needs_more_time 2
  8663. run_test "DTLS proxy: 3d, FS, ticket" \
  8664. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  8665. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
  8666. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
  8667. 0 \
  8668. -s "Extra-header:" \
  8669. -c "HTTP/1.0 200 OK"
  8670. client_needs_more_time 2
  8671. run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
  8672. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  8673. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
  8674. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
  8675. 0 \
  8676. -s "Extra-header:" \
  8677. -c "HTTP/1.0 200 OK"
  8678. client_needs_more_time 2
  8679. run_test "DTLS proxy: 3d, max handshake, nbio" \
  8680. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  8681. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
  8682. auth_mode=required" \
  8683. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
  8684. 0 \
  8685. -s "Extra-header:" \
  8686. -c "HTTP/1.0 200 OK"
  8687. client_needs_more_time 4
  8688. run_test "DTLS proxy: 3d, min handshake, resumption" \
  8689. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  8690. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
  8691. psk=abc123 debug_level=3" \
  8692. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
  8693. debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
  8694. force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
  8695. 0 \
  8696. -s "a session has been resumed" \
  8697. -c "a session has been resumed" \
  8698. -s "Extra-header:" \
  8699. -c "HTTP/1.0 200 OK"
  8700. client_needs_more_time 4
  8701. run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
  8702. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  8703. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
  8704. psk=abc123 debug_level=3 nbio=2" \
  8705. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
  8706. debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
  8707. force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
  8708. 0 \
  8709. -s "a session has been resumed" \
  8710. -c "a session has been resumed" \
  8711. -s "Extra-header:" \
  8712. -c "HTTP/1.0 200 OK"
  8713. client_needs_more_time 4
  8714. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  8715. run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
  8716. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  8717. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
  8718. psk=abc123 renegotiation=1 debug_level=2" \
  8719. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
  8720. renegotiate=1 debug_level=2 \
  8721. force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
  8722. 0 \
  8723. -c "=> renegotiate" \
  8724. -s "=> renegotiate" \
  8725. -s "Extra-header:" \
  8726. -c "HTTP/1.0 200 OK"
  8727. client_needs_more_time 4
  8728. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  8729. run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
  8730. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  8731. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
  8732. psk=abc123 renegotiation=1 debug_level=2" \
  8733. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
  8734. renegotiate=1 debug_level=2 \
  8735. force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
  8736. 0 \
  8737. -c "=> renegotiate" \
  8738. -s "=> renegotiate" \
  8739. -s "Extra-header:" \
  8740. -c "HTTP/1.0 200 OK"
  8741. client_needs_more_time 4
  8742. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  8743. run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
  8744. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  8745. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
  8746. psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
  8747. debug_level=2" \
  8748. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
  8749. renegotiation=1 exchanges=4 debug_level=2 \
  8750. force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
  8751. 0 \
  8752. -c "=> renegotiate" \
  8753. -s "=> renegotiate" \
  8754. -s "Extra-header:" \
  8755. -c "HTTP/1.0 200 OK"
  8756. client_needs_more_time 4
  8757. requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
  8758. run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
  8759. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  8760. "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
  8761. psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
  8762. debug_level=2 nbio=2" \
  8763. "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
  8764. renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
  8765. force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
  8766. 0 \
  8767. -c "=> renegotiate" \
  8768. -s "=> renegotiate" \
  8769. -s "Extra-header:" \
  8770. -c "HTTP/1.0 200 OK"
  8771. ## Interop tests with OpenSSL might trigger a bug in recent versions (including
  8772. ## all versions installed on the CI machines), reported here:
  8773. ## Bug report: https://github.com/openssl/openssl/issues/6902
  8774. ## They should be re-enabled once a fixed version of OpenSSL is available
  8775. ## (this should happen in some 1.1.1_ release according to the ticket).
  8776. skip_next_test
  8777. client_needs_more_time 6
  8778. not_with_valgrind # risk of non-mbedtls peer timing out
  8779. run_test "DTLS proxy: 3d, openssl server" \
  8780. -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
  8781. "$O_SRV -dtls1 -mtu 2048" \
  8782. "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
  8783. 0 \
  8784. -c "HTTP/1.0 200 OK"
  8785. skip_next_test # see above
  8786. client_needs_more_time 8
  8787. not_with_valgrind # risk of non-mbedtls peer timing out
  8788. run_test "DTLS proxy: 3d, openssl server, fragmentation" \
  8789. -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
  8790. "$O_SRV -dtls1 -mtu 768" \
  8791. "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
  8792. 0 \
  8793. -c "HTTP/1.0 200 OK"
  8794. skip_next_test # see above
  8795. client_needs_more_time 8
  8796. not_with_valgrind # risk of non-mbedtls peer timing out
  8797. run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
  8798. -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
  8799. "$O_SRV -dtls1 -mtu 768" \
  8800. "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
  8801. 0 \
  8802. -c "HTTP/1.0 200 OK"
  8803. requires_gnutls
  8804. client_needs_more_time 6
  8805. not_with_valgrind # risk of non-mbedtls peer timing out
  8806. run_test "DTLS proxy: 3d, gnutls server" \
  8807. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  8808. "$G_SRV -u --mtu 2048 -a" \
  8809. "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
  8810. 0 \
  8811. -s "Extra-header:" \
  8812. -c "Extra-header:"
  8813. requires_gnutls_next
  8814. client_needs_more_time 8
  8815. not_with_valgrind # risk of non-mbedtls peer timing out
  8816. run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
  8817. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  8818. "$G_NEXT_SRV -u --mtu 512" \
  8819. "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
  8820. 0 \
  8821. -s "Extra-header:" \
  8822. -c "Extra-header:"
  8823. requires_gnutls_next
  8824. client_needs_more_time 8
  8825. not_with_valgrind # risk of non-mbedtls peer timing out
  8826. run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
  8827. -p "$P_PXY drop=5 delay=5 duplicate=5" \
  8828. "$G_NEXT_SRV -u --mtu 512" \
  8829. "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
  8830. 0 \
  8831. -s "Extra-header:" \
  8832. -c "Extra-header:"
  8833. requires_config_enabled MBEDTLS_SSL_EXPORT_KEYS
  8834. run_test "export keys functionality" \
  8835. "$P_SRV eap_tls=1 debug_level=3" \
  8836. "$P_CLI eap_tls=1 debug_level=3" \
  8837. 0 \
  8838. -s "exported maclen is " \
  8839. -s "exported keylen is " \
  8840. -s "exported ivlen is " \
  8841. -c "exported maclen is " \
  8842. -c "exported keylen is " \
  8843. -c "exported ivlen is " \
  8844. -c "EAP-TLS key material is:"\
  8845. -s "EAP-TLS key material is:"\
  8846. -c "EAP-TLS IV is:" \
  8847. -s "EAP-TLS IV is:"
  8848. # Test heap memory usage after handshake
  8849. requires_config_enabled MBEDTLS_MEMORY_DEBUG
  8850. requires_config_enabled MBEDTLS_MEMORY_BUFFER_ALLOC_C
  8851. requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  8852. run_tests_memory_after_hanshake
  8853. # Final report
  8854. echo "------------------------------------------------------------------------"
  8855. if [ $FAILS = 0 ]; then
  8856. printf "PASSED"
  8857. else
  8858. printf "FAILED"
  8859. fi
  8860. PASSES=$(( $TESTS - $FAILS ))
  8861. echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
  8862. exit $FAILS